lint-staged: lint-staged execution of git commit is slow

Description

I only changed one line of code in a file, but when executing the git commit command, the execution speed of lint-staged is very slow. I don’t know if it is a problem with the configuration of my lint-staged.It’s probably not a problem with my computer’s performance. My colleagues also feel that the speed of submitting code is a bit slow. The code in this file has been formatted in advance. image I am using husky’s pre-commit for execution.This is my pre-commit code

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged

And the .lintstagedrc.json configuration file

{
  "*.{js,vue}": ["prettier --write", "eslint --fix"],
  "*.{md,yaml,json}": ["prettier --write"]
}

Steps to reproduce

Execute git commit -m "test"

Debug Logs

  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: true,
  verbose: false
} +0ms
  lint-staged:validateOptions Validating options... +0ms        
  lint-staged:validateOptions Validated options! +1ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `D:\Documents\编程练习\项目\kms-vue3-beta` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `D:\Documents\编程练习\项目\kms-vue3-beta` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +1ms
  lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
  lint-staged:resolveGitRepo Resolved git directory to be `D:/Documents/编程练习/项目/kms-vue3-beta` +121ms
  lint-staged:resolveGitRepo Resolved git config directory to be `D:/Documents/编程练习/项目/kms-vue3-beta/.git` +1ms
  lint-staged:execGit Running git command [ 'log', '-1' ] +123ms
  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +69ms
  lint-staged:runAll Loaded list of staged files in git:
  lint-staged:runAll [
  lint-staged:runAll   'D:/Documents/编程练习/项目/kms-vue3-beta/src/components/schedule/EditCalendar.vue'
  lint-staged:runAll ] +269ms
  lint-staged:searchConfigs Searching for configuration files... +0ms
  lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name' ] +78ms
  lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '--others', '--exclude-standard' ] +25ms
  lint-staged:searchConfigs Found possible config files: [
  'D:/Documents/编程练习/项目/kms-vue3-beta/.lintstagedrc.json',
  'D:/Documents/编程练习/项目/kms-vue3-beta/package.json'
] +109ms
  lint-staged:loadConfig Loading configuration from `D:/Documents/编程练习/项目/kms-vue3-beta/.lintstagedrc.json`... +0ms
  lint-staged:loadConfig Loading configuration from `D:/Documents/编程练习/项目/kms-vue3-beta/package.json`... +1ms 
  lint-staged:loadConfig Successfully loaded config from `D:\Documents\编程练习\项目\kms-vue3-beta\package.json`:   
  lint-staged:loadConfig null +2ms
  lint-staged:loadConfig Successfully loaded config from `D:\Documents\编程练习\项目\kms-vue3-beta\.lintstagedrc.json`:
  lint-staged:loadConfig {
  lint-staged:loadConfig   '*.{js,vue}': [ 'prettier --write', 'eslint --fix' ],
  lint-staged:loadConfig   '*.{md,yaml,json}': [ 'prettier --write' ]
  lint-staged:loadConfig } +0ms
  lint-staged:searchConfigs Config file "D:/Documents/编程练习/项目/kms-vue3-beta/.lintstagedrc.json" resolved to "D:\Documents\编程练习\项目\kms-vue3-beta\.lintstagedrc.json" +5ms
  lint-staged:validateConfig Validating config from `D:\Documents\编程练习\项目\kms-vue3-beta\.lintstagedrc.json`... +0ms
  lint-staged:validateConfig Validated config from `D:\Documents\编程练习\项目\kms-vue3-beta\.lintstagedrc.json`: +1ms
  lint-staged:validateConfig {
  lint-staged:validateConfig   '*.{js,vue}': [
  lint-staged:validateConfig     'prettier --write',
  lint-staged:validateConfig     'eslint --fix'
  lint-staged:validateConfig   ],
  lint-staged:validateConfig   '*.{md,yaml,json}': [
  lint-staged:validateConfig     'prettier --write'
  lint-staged:validateConfig   ]
  lint-staged:validateConfig } +0ms
  lint-staged:searchConfigs Found 1 config files +4ms
  lint-staged:groupFilesByConfig Grouping 1 files by 1 configurations +0ms
  lint-staged:chunkFiles Resolved an argument string length of 75 characters from 1 files +0ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 4095.5 +0ms
  lint-staged:generateTasks Generating linter tasks +0ms
  lint-staged:generateTasks Generated task: 
  lint-staged:generateTasks {
  lint-staged:generateTasks   pattern: '*.{js,vue}',
  lint-staged:generateTasks   commands: [ 'prettier --write', 'eslint --fix' ],
  lint-staged:generateTasks   fileList: [
  lint-staged:generateTasks     'D:/Documents/编程练习/项目/kms-vue3-beta/src/components/schedule/EditCalendar.vue' 
  lint-staged:generateTasks   ]
  lint-staged:generateTasks } +4ms
  lint-staged:generateTasks Generated task:
  lint-staged:generateTasks {
  lint-staged:generateTasks   pattern: '*.{md,yaml,json}',
  lint-staged:generateTasks   commands: [ 'prettier --write' ],
  lint-staged:generateTasks   fileList: []
  lint-staged:generateTasks } +5ms
  lint-staged:makeCmdTasks Creating listr tasks for commands [ 'prettier --write', 'eslint --fix' ] +0ms
  lint-staged:resolveTaskFn cmd: prettier +0ms
  lint-staged:resolveTaskFn args: [ '--write' ] +0ms
  lint-staged:resolveTaskFn execaOptions: {
  cwd: 'D:\\Documents\\编程练习\\项目\\kms-vue3-beta',
  preferLocal: true,
  reject: false,
  shell: false
} +0ms
  lint-staged:resolveTaskFn cmd: eslint +1ms
  lint-staged:resolveTaskFn args: [ '--fix' ] +0ms
  lint-staged:resolveTaskFn execaOptions: {
  cwd: 'D:\\Documents\\编程练习\\项目\\kms-vue3-beta',
  preferLocal: true,
  reject: false,
  shell: false
} +1ms
  lint-staged:makeCmdTasks Creating listr tasks for commands [ 'prettier --write' ] +4ms
  lint-staged:resolveTaskFn cmd: prettier +1ms
  lint-staged:resolveTaskFn args: [ '--write' ] +0ms
  lint-staged:resolveTaskFn execaOptions: {
  cwd: 'D:\\Documents\\编程练习\\项目\\kms-vue3-beta',
  preferLocal: true,
  reject: false,
  shell: false
} +1ms
  lint-staged:chunkFiles Resolved an argument string length of 75 characters from 1 files +20ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 4095.5 +0ms
[STARTED] Preparing lint-staged...
  lint-staged:GitWorkflow Backing up original state... +0ms
  lint-staged:GitWorkflow Getting partially staged files... +0ms
  lint-staged:execGit Running git command [ 'status', '-z' ] +119ms
  lint-staged:GitWorkflow Found partially staged files: [] +91ms
  lint-staged:GitWorkflow Backing up merge state... +0ms
  lint-staged:file Reading file `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_HEAD` +0ms
  lint-staged:file Reading file `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_MODE` +0ms
  lint-staged:file Reading file `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_MSG` +1ms
  lint-staged:file File `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_HEAD` doesn't exist, ignoring... +0ms  
  lint-staged:file File `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_MODE` doesn't exist, ignoring... +1ms  
  lint-staged:file File `D:\Documents\编程练习\项目\kms-vue3-beta\.git\MERGE_MSG` doesn't exist, ignoring... +1ms   
  lint-staged:GitWorkflow Done backing up merge state! +4ms
  lint-staged:GitWorkflow Getting deleted files... +1ms
  lint-staged:execGit Running git command [ 'ls-files', '--deleted' ] +96ms
  lint-staged:GitWorkflow Found deleted files: [] +73ms
  lint-staged:execGit Running git command [ 'stash', 'create' ] +73ms
  lint-staged:execGit Running git command [
  'stash',
  'store',
  '--quiet',
  '--message',
  'lint-staged automatic backup',
  '36e1ae0cf03aa2e8f727491f2a42da9fdf659704'
] +135ms
  lint-staged:GitWorkflow Done backing up original state! +212ms
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] .lintstagedrc.json — 1 file
[STARTED] *.{js,vue} — 1 file
[STARTED] *.{md,yaml,json} — 0 files
[SKIPPED] *.{md,yaml,json} — no files
[STARTED] prettier --write
[COMPLETED] prettier --write
[STARTED] eslint --fix
[COMPLETED] eslint --fix
[COMPLETED] *.{js,vue} — 1 file
[COMPLETED] .lintstagedrc.json — 1 file
  lint-staged:GitWorkflow Adding task modifications to index... +2s
[COMPLETED] Running tasks for staged files...
  lint-staged:execGit Running git command [
  'add',
  '--',
  'D:/Documents/编程练习/项目/kms-vue3-beta/src/components/schedule/EditCalendar.vue'
] +2s
[STARTED] Applying modifications from tasks...
  lint-staged:GitWorkflow Done adding task modifications to index! +80ms
  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +80ms   
[COMPLETED] Applying modifications from tasks...
[STARTED] Cleaning up temporary files...
  lint-staged:GitWorkflow Dropping backup stash... +80ms
  lint-staged:execGit Running git command [ 'stash', 'list' ] +81ms
  lint-staged:execGit Running git command [ 'stash', 'drop', '--quiet', '0' ] +110ms
  lint-staged:GitWorkflow Done dropping backup stash! +185ms
[COMPLETED] Cleaning up temporary files...
  lint-staged Tasks were executed successfully! +3s
[refactor 0b8617b] test
 1 file changed, 2 insertions(+)

Environment

  • OS: Windows 10 22H2
  • Node.js: 18.17.1
  • lint-staged: 14.0.1
  • husky: 8.0.3

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 28 (1 by maintainers)

Most upvoted comments

Thank you very much for your answer. Well, I feel that it is not a problem with lint-staged, but a performance problem with my computer. My colleague also has a MacOS M1 Pro, which is also very fast. I think this issue should be closed.

glad I could be some help

Thank you very much for your answer. Well, I feel that it is not a problem with lint-staged, but a performance problem with my computer. My colleague also has a MacOS M1 Pro, which is also very fast. I think this issue should be closed.