如何更正皮棉问题?

问题描述

尽管配置文件(如下所示),但尝试扫描'src / **'目录之外的文件时,lint暂存阶段出现错误。在控制台中运行eslint不会显示相同的错误(仅显示警告)。 考虑到lint-staged是通过赫斯基调用的,如果没有--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)

解决方法

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