I have an app created with create-react-app
. I have extended the eslint functionality with an eslintrc.json
file with the following rules:
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/require-default-props": "off",
"no-param-reassign": "off",
"jsx-a11y/alt-text": "off",
"react/react-in-jsx-scope": "off",
"react/display-name": "off",
"import/no-unused-modules": [2, {"unusedExports": true}],
"unused-imports/no-unused-imports": "error"
},
I have noticed that rules such as unused-imports/no-unused-imports
will be used on every autorefresh, and notify me if something is wrong. However, import/no-unused-modules
won’t run when create-react-app
autorefreshes.
When I run npx eslint .
manually in the root directory, both of these rules are run fine and will pick up errors.
Theoretically, this seems sensible. My thinking is that create-react-app
only checks files and modules which are imported into the build. Since import/no-unused-modules
checks for files/modules which AREN’T imported by definition, this won’t be used by create-react-app
.
What I’m looking for is proof (e.g. code in the create-react-app
codebase) that this is the case. How does create-react-app
know not to run the import/no-unused-modules
rule? I have looked online and can’t find an answer to this…
Thanks!