question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot extend shared config in monorepo setup

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.0.1
  • Node Version: 10.4.1
  • npm Version: 6.1.0

What parser (default, Babel-ESLint, etc.) are you using? -

Please show your full configuration:

module.exports = {
  extends: '@org/eslint-config'
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Reproduction https://github.com/sqal/eslint-extends-bug-reproduction

Steps to reproduce:

  • After cloning, the repo run npm run bootstrap
  • Then go to packages/app and run npm run lint

What did you expect to happen? I expect eslint to find my config correctly

What actually happened? Please include the actual, raw output from ESLint.

> eslint src

Cannot find module '@org/eslint-config'
Referenced from: C:\dev\eslint-extends-bug\packages\app\.eslintrc.js
Error: Cannot find module '@org/eslint-config'
Referenced from: C:\dev\eslint-extends-bug\packages\app\.eslintrc.js
    at ModuleResolver.resolve (C:\dev\eslint-extends-bug\node_modules\eslint\lib\util\module-resolver.js:72:19)
    at resolve (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:484:28)
    at load (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:556:26)
    at configExtends.reduceRight (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:430:36)
    at Array.reduceRight (<anonymous>)
    at applyExtends (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:408:26)
    at loadFromDisk (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:528:22)
    at Object.load (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config\config-file.js:564:20)
    at Config.getLocalConfigHierarchy (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config.js:227:44)
    at Config.getConfigHierarchy (C:\dev\eslint-extends-bug\node_modules\eslint\lib\config.js:179:43)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! app@1.0.0 lint: `eslint src`
npm ERR! Exit status 2

In the error logs we see that the error originates at ModuleResolver.resolve (C:\dev\eslint-extends-bug\node_modules\eslint\lib\util\module-resolver.js:74:19). I added console log after line#62 and these are the paths that eslint tries to search through:

[ 
  'C:\\dev\\eslint-extends-bug\\node_modules\\node_modules',
  'C:\\dev\\eslint-extends-bug\\node_modules\\eslint\\lib\\util\\node_modules',
  'C:\\dev\\eslint-extends-bug\\node_modules\\eslint\\lib\\node_modules',
  'C:\\dev\\eslint-extends-bug\\node_modules\\eslint\\node_modules',
  'C:\\dev\\eslint-extends-bug\\node_modules',
  'C:\\dev\\node_modules',
  'C:\\node_modules',
  'C:\\Users\\pc\\.node_modules',
  'C:\\Users\\pc\\.node_libraries',
  'C:\\Program Files\\nodejs\\lib\\node'
]

so looks like we’re missing here path to node_modules relative to process.cwd().

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Sep 19, 2018

Closing in favor of #10125.

1reaction
kaicataldocommented, Jul 23, 2018

Should we close this in favor of that issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reduce maintenance effort with shared ESLint and Prettier ...
Monorepo setup for shared libraries​​ I aim to provide two npm packages to source out ESLint and Prettier configurations into individual npm ...
Read more >
Dealing with TypeScript configs for the mono-repo application.
So to do that create it and add this simple configuration — in the frontend folder/service. { "extends": "../tsconfig.json", "compilerOptions": {} }.
Read more >
monorepo Yarn workspaces - shared esLint and Prettier configs
I have a similar setup in my monorepo (Yarn v3.x). ... module.exports = { extends: ['@my-workspace/eslint-config-react'], };. Share.
Read more >
The Case for Monorepos: A sane Workspace Setup (Part 2)
So technically, it would be possible to add individual ESLint configs to all packages in your monorepo and extend shared configs where you...
Read more >
Shareable Configs - ESLint - Pluggable JavaScript Linter
The configuration that you have in your .eslintrc file is an important part of your project, and as such, you may want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found