【发布时间】:2021-09-14 10:27:59
【问题描述】:
我在我的 nx 项目 (.eslintrc.json) 中为 sort-imports 添加规则:
"rules": {
"sort-imports": ["error", {
"ignoreCase": false,
"ignoreDeclarationSort": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
"allowSeparatedGroups": false
}],
"@nrwl/nx/enforce-module-boundaries": [ ...
当我运行 --fix 标志时,文件中没有任何变化。
我得到的输出是:
➜ 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
文件内容为:
import { writeFileSync } from 'fs';
import path from 'path';
console.log({ path });
console.log({ writeFileSync });
console.log('Hello World!');
那么为什么 eslint 不修复文件呢?文档中说:
The --fix option on the command line automatically fixes some problems reported by this rule
【问题讨论】:
标签: javascript eslint nrwl-nx