My eslintrc.cjs and stylelintrc.json files are given below along with other config files:
Package.json
stylelintrc.json
eslintrc.cjs
tsconfig.json
Specifically, look at the scripts:
"lint:eslint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:eslint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"lint:stylelint": "stylelint '**/*.{css,scss}'",
"lint:stylelint:fix": "stylelint '**/*.{css,scss}' --fix",
npm run lint:stylelint
> [email protected] lint:stylelint
> stylelint '**/*.{css,scss}'
141:3 ✖ Unexpected empty line before declaration declaration-empty-line-before
✖ 1 problem (1 error, 0 warnings)
1 error potentially fixable with the "--fix" option.
PS C:Usersmubtairclient> npm run lint:stylelint -- --fix
> [email protected] lint:stylelint
> stylelint '**/*.{css,scss}'
scss/globalStyles.scss
141:3 ✖ Unexpected empty line before declaration declaration-empty-line-before
✖ 1 problem (1 error, 0 warnings)
1 error potentially fixable with the "--fix" option.
PS C:Usersmubtairclient> npm run lint:stylelint --fix
> [email protected] lint:stylelint
> stylelint '**/*.{css,scss}'
scss/globalStyles.scss
141:3 ✖ Unexpected empty line before declaration declaration-empty-line-before
✖ 1 problem (1 error, 0 warnings)
1 error potentially fixable with the "--fix" option.
The fix flags do not actually fix the problem. At some point, it did use to, but I do not know what change caused it to stop working. So I added the “:fix” extended script and that works.
npm run lint:stylelint:fix
> [email protected] lint:stylelint:fix
> stylelint '**/*.{css,scss}' --fix
Curiously, npx with –fix flaf works as well:
npx stylelint ‘**/*.{css,scss}’ –fix
The same behaviour can also be seen with eslint as well.
I have tried reinstalling node, npm and have also tried ncu. As a last resort, I tried deleting node modules along with package.lock.json. That did not work either. It should be noted that I am aware that there is a newer major version of eslint available, but I could not make my project work with flat config so decided go for the newest legacy config. Anyways I do not think that is major issue as stylelint with —fix is not working properly either.
Mubtasim Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.