3

尽管配置文件(如下),我在尝试扫描 'src/**' 目录之外的文件时遇到错误。在控制台中运行 eslint 不会显示相同的错误(仅显示警告)。考虑到 lint-staged 是通过 Husky 调用的,我无法在没有 --no-verify 的情况下提交我的代码。

任何想法如何解决它?

.lintstagedrc.json

{
  "*.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 目录之外的文件中没有错误:

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)
4

1 回答 1

-2

验证您是否在 src 中有一个文件夹 src/ande 一个文件

于 2020-11-18T20:40:54.360 回答