How to correct lint-staged problems?

2.1k Views Asked by At

I´m getting an error with lint-staged trying to scan files outside 'src/**' dir, despite configuration file (below). Running eslint into console dont shows the same error (only show warnings). Considering lint-staged is called via Husky I cant commit my codes without --no-verify.

Any ideia how to solve it?

.lintstagedrc.json

{
  "*.ts": [
    "eslint 'src/**' --fix",
    "npm run test:staged"
  ]
}

Error running 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)

Without error in files outside 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)
1

There are 1 best solutions below

0
On

Verify if your have a folder src/ ande one file in src