Using a custom ESLint version in Create React App
I'm maintaining my own ESLint rules for all my projects. With Create React App (CRA), custom configuration is always a hassle (by design). Custom rules are usually fine, unless the ESLint peer dependency version doesn't support them yet:
$ react-scripts build
Creating an optimized production build...
Failed to compile.
Definition for rule 'react/jsx-no-constructed-context-values' was not found react/jsx-no-constructed-context-values
Definition for rule 'no-unsafe-optional-chaining' was not found no-unsafe-optional-chaining
Notice that as of CRA version 4.0.0,
react-scripts build (and
react-scripts start) run
eslint implicitly, which sounds like a strange decision. As of version 4.0.2, it is possible to disable this behavior.
I thought defining a custom version in
package.json will solve the issue, but
react-scripts doesn't pick it up:
Finally, with yarn resolutions, I was able to override (peer) dependency versions:
Note: this method relies on using
yarn instead of
Want to leave a comment?
Join the discussion at Twitter or Mastodon. Feel free to drop me an email. 💌