I add rule for sort-imports in my nx project (.eslintrc.json):
"rules": {
"sort-imports": ["error", {
"ignoreCase": false,
"ignoreDeclarationSort": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
"allowSeparatedGroups": false
}],
"@nrwl/nx/enforce-module-boundaries": [ ...
And when I run this the --fix flag, nothing change in the file.
the output I get is:
➜ nx-app git:(master) ✗ yarn nx run nx-api:lint --fix
yarn run v1.22.10
$ nx run nx-api:lint --fix
> nx run nx-api:lint --fix
Linting "nx-api"...
/Users/.../nx-app/apps/nx-api/src/main.ts
2:1 error Imports should be sorted alphabetically sort-imports
✖ 1 problem (1 error, 0 warnings)
Lint errors found in the listed files.
———————————————————————————————————————————————
> NX ERROR Running target "nx-api:lint" failed
The file content is:
import { writeFileSync } from 'fs';
import path from 'path';
console.log({ path });
console.log({ writeFileSync });
console.log('Hello World!');
So why eslint doesn't fix the file? it's say in the docs:
The --fix option on the command line automatically fixes some problems reported by this rule