0

I'm running the npx lint-staged command and noticed that if I have the following tree:

src 
 /sub-folder-x
  - file-x
 /sub-folder-y
  - file-y

The eslint and prettier cannot find files in subfolders.

How do I get the stage to run on all subfolders and files of it?

enter image description here

.lintstagedrc.json

{
    "src/**/*.{js,jsx,ts,tsx}": ["prettier --check", "eslint"]
}

✖ prettier --check:

[warn] src/App.test.tsx
[warn] src/App.tsx
[warn] src/index.tsx
[warn] src/reportWebVitals.ts
[warn] Code style issues found in the above file(s). Forgot to run Prettier?

✖ eslint:

/POC/uber-web/src/App.test.tsx
/POC/uber-web/src/App.tsx
/POC/uber-web/src/index.tsx
/POC/uber-web/src/reportWebVitals.ts
THIAGO DE BONIS
  • 760
  • 7
  • 22

2 Answers2

0

It seems like your file pattern string in .lintstagedrc.json is wrong. Try remove dot before bracket and put it before each file extension definition like this:

{
   "src/**/*{.js,.jsx,.ts,.tsx}": ["prettier --check", "eslint"]
}
prodeje
  • 11
  • 1
0

If you are using lint-staged along with husky, you can simply change the directory in the git-hook.

cd ./client && npx lint-staged

And the package.json should be

"lint-staged": {
  "*.{js,jsx,ts,tsx}": [
    "prettier --write",
    "eslint -c .eslintrc.json --fix"
  ]
}
Ahamed Safnaj
  • 611
  • 1
  • 6
  • 18