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.

Extending ESLint is not supporting overrides

See original GitHub issue

Extending ESLint got introduced originally in https://github.com/facebook/create-react-app/pull/7036 by @mrmckeb. It’s stated that this is limited currently to users configuring their ESLint in package.json:

  • this ain’t quite true - because used eslintCli.getConfigForFile is not limited to package.json configs
  • there is no such mention in the docs - not a biggie but brought a little bit of confusion for me.

What is actually stated in the docs and what doesn’t actually hold true is that overrides can be used to support TS rules etc (there is example of that).

This is not quite true, because whatever config gets loaded & resolved through that eslintCli.getConfigForFile call (with paths.appIndexJs as argument) gets set as “global” config for the whole eslint-loader.

So depending on what paths.appIndexJs is we either can get:

  • all TS-related rules being applied to ALL files (including JS) - when paths.appIndexJs is TS
  • no TS rules are applied at all - when paths.appIndexJs is JS

For this to work correctly it would be the easiest to allow ESLint to load configs on its own - without passing explicit single config to the eslint-loader.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
mrmckebcommented, Dec 19, 2019

@Andarist, sorry I think we were confused about what you were reporting.

I’ve managed to reproduce now and understand. Sorry for the inconvenience.

So, in short:

  • The config itself is fine.
  • Instructions need to be updated.
  • Return undefined to baseConfig when process.env.EXTEND_ESLINT === 'true'.
  • Change useEslintrc: false to useEslintrc: process.env.EXTEND_ESLINT === 'true'.

How do these changes sound to everyone? I’ve tested them by modifying the Webpack config (in node_modules directly) - if others can do the same and report back, I can make the change this weekend.

1reaction
ianschmitzcommented, Dec 5, 2019

Hi @Andarist. Sorry this fell through the cracks. Let me try to address your comments:

Extending ESLint got introduced originally in #7036 by @mrmckeb. It’s stated that this is limited currently to users configuring their ESLint in package.json:

Agreed. This should be clarified in the docs.

What is actually stated in the docs and what doesn’t actually hold true is that overrides can be used to support TS rules etc (there is example of that).

Yeah this should be explicitly stated in the language above that example.

So depending on what paths.appIndexJs is we either can get:

  • all TS-related rules being applied to ALL files (including JS) - when paths.appIndexJs is TS
  • no TS rules are applied at all - when paths.appIndexJs is JS

Can you confirm this? I seem to remember when testing this that getConfigForFile() resolves the entire configuration (both TS, and JS) irrespective of the file extension. That would be the intent anyways so that we support mixed JS/TS code bases.

Thanks for bringing this up. We’d gladly accept PRs to improve the documentation for points you raised.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Glob override configs do not support "extends" #8813 - GitHub
Suppose there is a config file in a project: .eslintrc.json . It extends from plugin:foo/default configuration which uses glob override to add ...
Read more >
eslint disable extends in override - javascript - Stack Overflow
Here are two ways to accomplish this: Separate files: You can place a different .eslintrc.js file inside vendor/ with root: true .
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
Nested overrides settings are applied only if the glob patterns of both the parent config and the child config are matched. This is...
Read more >
eslint-plugin-jest - npm
You can use overrides to have ESLint apply additional rules to specific files: { "extends": ["eslint:recommended"], "overrides": ...
Read more >
User Guide | eslint-plugin-vue
rules: { // override/add rules settings here, such as: // 'vue/no-unused-vars': 'error' } }. See the rule list to get the extends &...
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