lint-staged is very slow when script is npm run xxx
See original GitHub issueDescription
I found my lint-staged was very slow, so I debugged it and found when not use the npm run xxx commands it will be fine, it’s very strange, I want to know why.
Steps to reproduce
- Use this config
npm script:
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx",
lint-staged config:
"lint-staged": {
"**/*.{js,jsx}": "npm run lint-staged:js"
}
- modify a file (just one) and
git add .
npx lint-staged
In my computer it will take more than 3 min for result! But if I replace commands to:
"lint-staged": {
"**/*.{js,jsx}": "eslint --ext .js,.jsx,.ts,.tsx"
}
it will be ok. That’s strange.
Debug Logs
expand to view
$ npx lint-staged -d > log
2019-10-21T08:20:48.219Z lint-staged:bin Running `lint-staged@9.4.2`
2019-10-21T08:20:48.224Z lint-staged Loading config using `cosmiconfig`
2019-10-21T08:20:48.241Z lint-staged Successfully loaded config from `D:\projects\osms-web\package.json`:
{ '**/*.{js,jsx}': 'npm run lint-staged:js' }
2019-10-21T08:20:48.242Z lint-staged:cfg Validating config
2019-10-21T08:20:48.256Z lint-staged:run Running all linter scripts
2019-10-21T08:20:48.257Z lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ]
2019-10-21T08:20:48.759Z lint-staged:run Resolved git directory to be `D:/Projects/osms-web`
2019-10-21T08:20:48.759Z lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only' ]
2019-10-21T08:20:49.408Z lint-staged:run Loaded list of staged files in git:
[ 'src/pages/WorkloadConfirmation/index.jsx' ]
2019-10-21T08:20:49.408Z lint-staged:gen-tasks Generating linter tasks
2019-10-21T08:20:49.432Z lint-staged:gen-tasks Generated task:
{ pattern: '**/*.{js,jsx}',
commands: 'npm run lint-staged:js',
fileList:
[ 'D:/projects/osms-web/src/pages/WorkloadConfirmation/index.jsx' ] }
2019-10-21T08:20:49.444Z lint-staged:git Running git command [ 'status', '--porcelain' ]
2019-10-21T08:20:50.052Z lint-staged:make-cmd-tasks Creating listr tasks for commands 'npm run lint-staged:js'
2019-10-21T08:20:50.067Z lint-staged:task cmd: npm
2019-10-21T08:20:50.067Z lint-staged:task args: [ 'run',
'lint-staged:js',
'D:/projects/osms-web/src/pages/WorkloadConfirmation/index.jsx' ]
2019-10-21T08:20:50.068Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
× npm run lint-staged:js found some errors. Please fix them and try committing again.
> ant-design-pro@1.0.0 lint-staged:js D:\Projects\osms-web
> eslint --ext .js,.jsx,.ts,.tsx "D:/projects/osms-web/src/pages/WorkloadConfirmation/index.jsx"
D:\projects\osms-web\src\pages\WorkloadConfirmation\index.jsx
6:36 error 'React' is not defined no-undef
27:7 error 'React' must be in scope when using JSX react/react-in-jsx-scope
28:9 error 'React' must be in scope when using JSX react/react-in-jsx-scope
29:31 error 'React' must be in scope when using JSX react/react-in-jsx-scope
30:31 error 'React' must be in scope when using JSX react/react-in-jsx-scope
✖ 5 problems (5 errors, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ant-design-pro@1.0.0 lint-staged:js: `eslint --ext .js,.jsx,.ts,.tsx "D:/projects/osms-web/src/pages/WorkloadConfirmation/index.jsx"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ant-design-pro@1.0.0 lint-staged:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\w13269464702\AppData\Roaming
pm-cache\_logs\2019-10-21T08_21_01_390Z-debug.log
Environment
- OS: win7 64bit
- Node.js: 10.13.0
lint-staged
: 9.4.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (3 by maintainers)
Top Results From Across the Web
`npx mrm@2 lint-staged` throw err that `.git` can't be found ...
npx mrm@2 lint-staged. Failed. Fix the npm prepare script ... Reason: package.json file and .git directory are not at the same level.
Read more >Lint-staged - Run Linters on Git Staged Files - Morioh
lint -staged is a simple to use tool to enforce code quality in teams. ... Instead of writing instructions on “how to setup...
Read more >Setting up efficient workflows with ESLint, Prettier and ...
In this article I would like to start very easily and go into more depth from topic to topic. In the first step...
Read more >line 3: 'react' must be in scope when using jsx react/react-in-jsx ...
It seems that the react-scripts was causing the lint errors for me. ... dist", "prebuild": "npm run clean-dist && npm run lint &&...
Read more >xlsx - npm
Start using xlsx in your project by running `npm i xlsx`. ... a script tag: <script lang="javascript" src="dist/xlsx.full.min.js"></script>.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is that you provide ESLint with
--ext
option that runs it on the whole project. lint-staged passes staged files to it directly, so just remove everything from the command and leave it aseslint
Please provide the debug logs