lint-staged / lint-staged

🚫💩 — Run linters on git staged files
https://www.npmjs.com/package/lint-staged
MIT License
13.46k stars 423 forks source link

Version 12+ results in exit code 1 instead of working #1438

Open TimPaulaskasDS opened 5 months ago

TimPaulaskasDS commented 5 months ago

@iiroj I have an issue when trying to upgrade from version 11 to 12+. Even though I am using Node v20.

git commit -S -am "EASFDC-1399: bump version for lint-staged"
husky - pre-commit script failed (code 1)

I have manually run it instead of using husky to reproduce the issue.

Before with version 11

npx lint-staged --debug

Running lint-staged with the following config:
{
  '**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml}': [
    'prettier --write'
  ],
  '**/{aura,lwc}/**': [
    'eslint'
  ],
  '**/*.{yaml, yml}': [
    'yaml-verify',
    'eslint'
  ]
}
[STARTED] Preparing...
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for **/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml}
[STARTED] Running tasks for **/{aura,lwc}/**
[STARTED] Running tasks for **/*.{yaml, yml}
[SKIPPED] No staged files match **/{aura,lwc}/**
[SKIPPED] No staged files match **/*.{yaml, yml}
[STARTED] prettier --write
[SUCCESS] prettier --write
[SUCCESS] Running tasks for **/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml}
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SUCCESS] Applying modifications...
[STARTED] Cleaning up...
[SUCCESS] Cleaning up...

node --version
v20.12.0

git --version
git version 2.45.2

After upgrading to v15.2.6

npx lint-staged --debug

  lint-staged:bin Running `lint-staged@15.2.6` on Node.js v20.12.0 (darwin) +0ms
  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,
  hidePartiallyStaged: true,
  verbose: false
} +1ms
  lint-staged:validateOptions Validating options... +0ms
  lint-staged:validateOptions Validated options! +0ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `/Users/tim.paulaskas/git-repos/SalesforceCI` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `/Users/tim.paulaskas/git-repos/SalesforceCI` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
  lint-staged:execGit Running git command [ 'rev-parse', '--path-format=absolute', '--show-toplevel' ] +0ms
  lint-staged:resolveGitRepo Resolved git directory to be `/Users/tim.paulaskas/git-repos/SalesforceCI` +107ms
  lint-staged:execGit Running git command [ 'rev-parse', '--path-format=absolute', '--absolute-git-dir' ] +107ms
  lint-staged:resolveGitRepo Resolved git config directory to be `/Users/tim.paulaskas/git-repos/SalesforceCI/.git` +140ms
  lint-staged:execGit Running git command [ 'log', '-1' ] +140ms
  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +89ms
  lint-staged:runAll Loaded list of staged files in git:
  lint-staged:runAll [
  lint-staged:runAll   '/Users/tim.paulaskas/git-repos/SalesforceCI/package-lock.json',
  lint-staged:runAll   '/Users/tim.paulaskas/git-repos/SalesforceCI/package.json'
  lint-staged:runAll ] +1s
  lint-staged:searchConfigs Searching for configuration files... +0ms
  lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '-t' ] +924ms
  lint-staged:execGit Running git command [
  'ls-files',
  '-z',
  '--full-name',
  '-t',
  '--others',
  '--exclude-standard'
] +23ms

Exits with an error code 1

This is my lint-staged chunk from my package.json file:

    "lint-staged": {
        "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml}": [
            "prettier --write"
        ],
        "**/{aura,lwc}/**": [
            "eslint"
        ],
        "**/*.{yaml, yml}": [
            "yaml-verify",
            "eslint"
        ]
    },

Originally posted by @TimPaulaskasDS in https://github.com/lint-staged/lint-staged/issues/1341#issuecomment-2162602485

iiroj commented 5 months ago

Do you mean lint-staged abruptly exits at the last log line:

lint-staged:execGit Running git command [
  'ls-files',
  '-z',
  '--full-name',
  '-t',
  '--others',
  '--exclude-standard'
] +23ms

Does running that git command manually work?

TimPaulaskasDS commented 5 months ago

Correct, it just ends. And I can run the git command without error.

Screenshot 2024-06-12 at 4 51 29 AM