lint-staged is not taking .eslintrc.js configuration.
See original GitHub issue[BUG]
Description
I have created 2 package.json npm scripts:
"lint-staged:test": "lint-staged",
"eslint:test": "eslint --fix src/global/AppRouter/AppRouter.tsx",
My configuration for lint-staged looks like;
"lint-staged": {
"*.tsx": [
"eslint --fix",
"git add"
]
}
By running yarn eslint:test
or npm run eslint:test
I’ve got no errors.
Like on the image attached:
But by running second command (“lint-staged:test”) I’ve got some errors related with the file that was checked with the first command. Image shows it:
Those are my rules for eslint (.eslinrc.js file):
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: ['plugin:@typescript-eslint/recommended', 'plugin:react/recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
// note you must disable the base rule as it can report incorrect errors
indent: 'off',
'@typescript-eslint/indent': ['error', 2],
},
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
};
which are applied for the first command but are not applied for lint-staged.
Some possible solutions?
Environment
- OS: Windows 10,
- Node.js: v10.13.0,
lint-staged
: 9.2.1,eslint
: 5.3.0",
Issue Analytics
- State:
- Created 4 years ago
- Reactions:21
- Comments:19 (1 by maintainers)
Top Results From Across the Web
lint-staged - npm
Configure lint -staged to run linters and other tasks: for example: { "*.js": "eslint" } to run ESLint for all staged JS files;...
Read more >Eslint husky and lint staged does not work - Stack Overflow
I set in my react js application husky:.
Read more >Setting up ESLint, Prettier, and Husky with lint-staged for your ...
Otherwise, select Base which is the basic ESLint configuration that comes with Next.js. Once you select any of the options, it will install ......
Read more >Basic Features: ESLint - Next.js
js. If you do not have ESLint already configured in your application, we recommend using next lint to set up ESLint along with...
Read more >Set up a Next.js project with ESLint, Prettier, Husky, and Lint ...
ESLint ; Prettier; Husky; Lint Staged ... and minimal configuration that I have recently started using for Next.js ... 6 "no-console": "warn".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I started running into this issue too and running the
eslint --fix
command by itself works but when run vialint-staged
the config seems to be being droppedI think I found the issue. my changes to .eslintrc.js also needed to be staged, by the looks of it? either way,
git add
ing the eslintrc file stopped the error.