15

I am updating some repos and would like to migrate from 5.x to 7.x eslint. But we use the file .eslintrc in all our repos. According to eslints's official configuration docs it seems to be deprecated, now. What format should we use instead?

I suppose .eslintrc.js format would be the most flexible while .eslintrc.json may be enough as long as we don't need any dynamic code? In the same configuration docs, the eslint team uses .eslintrc all the time by theirselves and I see the .eslintrc file a lot in other repos, too. So I am a little bit confused about how serious this deprecation really is, what is best practice, now, and what is most future proof.

Henke
  • 4,445
  • 3
  • 31
  • 44
Helge Drews
  • 459
  • 1
  • 4
  • 11
  • 2
    To explicitly answer the question: _is the config file .eslintrc deprecated in favor of .eslintrc.* files?_ -- The answer is YES! See [**.eslintrc without file extension is deprecated**](https://dev.to/ohbarye/eslintrc-without-file-extension-is-deprecated-3ngg), and [Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.](https://eslint.org/docs/user-guide/configuring/#configuration-file-formats). – Henke Feb 22 '22 at 13:42
  • Well, the warning line I get includes `DeprecationWarning: '~/.eslintrc.*' config files have been deprecated` which clearly says that ANY .eslintrc file — including extensions - is deprecated. Can’t have it both ways. – JESii Dec 07 '22 at 13:28

1 Answers1

19

Is the config file .eslintrc deprecated in favor of .eslintrc.* files?

Yes, but it's still supported.

What format should we use instead?

.eslintrc.json is the most similar to what you're used to, it's the same format but with an explicit JSON extension. If you'd like to avoid extra files, you can alternatively add your config to the eslintConfig field of package.json. If you need dynamic code, use .eslintrc.js or .eslintrc.cjs.

Configuration Guide

Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82