Node.js 如何纠正lint阶段性问题?
我在尝试扫描'src/**'目录之外的文件时遇到了一个错误,尽管下面有配置文件。在console中运行eslint不会显示相同的错误,只显示警告。 考虑到lint staged是通过Husky调用的,我不能在没有验证的情况下提交我的代码 有没有办法解决这个问题 .lintstagedrc.jsonNode.js 如何纠正lint阶段性问题?,node.js,eslint,lint-staged,Node.js,Eslint,Lint Staged,我在尝试扫描'src/**'目录之外的文件时遇到了一个错误,尽管下面有配置文件。在console中运行eslint不会显示相同的错误,只显示警告。 考虑到lint staged是通过Husky调用的,我不能在没有验证的情况下提交我的代码 有没有办法解决这个问题 .lintstagedrc.json { "*.ts": [ "eslint 'src/**' --fix", "npm run test:staged"
{
"*.ts": [
"eslint 'src/**' --fix",
"npm run test:staged"
]
}
运行lint staged时出错:
node@2d6c88d1fbea:/workspaces/TDD$ lint-staged
✔ Preparing...
⚠ Running tasks...
❯ Running tasks for *.ts
✖ eslint 'src/**' --fix [FAILED]
◼ npm run test:staged
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up...
✖ eslint 'src/**' --fix:
/workspaces/TDD/jest-integration-config.ts
1:16 error Require statement not part of import statement @typescript-eslint/no-var-requires
/workspaces/TDD/jest-unit-config.ts
1:16 error Require statement not part of import statement @typescript-eslint/no-var-requires
/workspaces/TDD/src/presentantion/controllers/signup/signup.spec.ts
25:18 warning 'email' is defined but never used @typescript-eslint/no-unused-vars
34:20 warning 'account' is defined but never used @typescript-eslint/no-unused-vars
/workspaces/TDD/src/presentantion/helpers/http-helper.ts
14:20 warning Argument 'data' should be typed with a non-any type @typescript-eslint/explicit-module-boundary-types
14:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
/workspaces/TDD/src/presentantion/protocols/http.ts
3:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
7:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
✖ 8 problems (2 errors, 6 warnings)
src dir之外的文件中没有错误:
node@2d6c88d1fbea:/workspaces/TDD$ eslint 'src/**' --fix
/workspaces/TDD/src/presentantion/controllers/signup/signup.spec.ts
25:18 warning 'email' is defined but never used @typescript-eslint/no-unused-vars
34:20 warning 'account' is defined but never used @typescript-eslint/no-unused-vars
/workspaces/TDD/src/presentantion/helpers/http-helper.ts
14:20 warning Argument 'data' should be typed with a non-any type @typescript-eslint/explicit-module-boundary-types
14:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
/workspaces/TDD/src/presentantion/protocols/http.ts
3:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
7:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
✖ 6 problems (0 errors, 6 warnings)
验证您的src中是否有文件夹src/ande one file验证您的src中是否有文件夹src/ande one file