lint-staged 16.1.2 → 16.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -304,7 +304,7 @@ Supported are any executables installed locally or globally via `npm` as well as
304
304
 
305
305
  > Using globally installed scripts is discouraged, since lint-staged may not work for someone who doesn't have it installed.
306
306
 
307
- `lint-staged` uses [execa](https://github.com/sindresorhus/execa#preferlocal) to locate locally installed scripts. So in your `.lintstagedrc` you can write:
307
+ `lint-staged` uses [nano-spawn](https://github.com/sindresorhus/nano-spawn?tab=readme-ov-file#optionspreferlocal) to locate locally installed scripts. So in your `.lintstagedrc` you can write:
308
308
 
309
309
  ```json
310
310
  {
@@ -15,14 +15,12 @@ const debugLog = debug('lint-staged:searchConfigs')
15
15
 
16
16
  const EXEC_GIT = ['ls-files', '-z', '--full-name', '-t']
17
17
 
18
- const filterPossibleConfigFiles = (file) => CONFIG_FILE_NAMES.includes(path.basename(file))
18
+ const CONFIG_PATHSPEC = CONFIG_FILE_NAMES.map((f) => `:(glob)**/${f}`)
19
19
 
20
20
  const numberOfLevels = (file) => file.split('/').length
21
21
 
22
22
  const sortDeepestParth = (a, b) => (numberOfLevels(a) > numberOfLevels(b) ? -1 : 1)
23
23
 
24
- const isInsideDirectory = (dir) => (file) => file.startsWith(normalizePath(dir))
25
-
26
24
  /**
27
25
  * Search all config files from the git repository, preferring those inside `cwd`.
28
26
  *
@@ -57,27 +55,37 @@ export const searchConfigs = async (
57
55
  return { [configPath]: validateConfig(config, filepath, logger) }
58
56
  }
59
57
 
60
- const [cachedFilesWithStatus, otherFilesWithStatus] = await Promise.all([
61
- /** Get all possible config files known to git */
62
- execGit(EXEC_GIT, { cwd: topLevelDir }).then(parseGitZOutput),
63
- /** Get all possible config files from uncommitted files */
64
- execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: topLevelDir }).then(
65
- parseGitZOutput
66
- ),
67
- ])
58
+ /** Get all possible config files from git (both cached and uncommitted) */
59
+ const gitListedFiles = await execGit(
60
+ [
61
+ ...EXEC_GIT,
62
+ '--cached', // show all tracked files
63
+ '--others', // show untracked files
64
+ '--exclude-standard', // apply standard git exclusions (.gitignore, etc.)
65
+ '--',
66
+ ...CONFIG_PATHSPEC,
67
+ ],
68
+ { cwd }
69
+ ).then(parseGitZOutput)
70
+
71
+ debugLog('Git listed files matching config files:', gitListedFiles)
68
72
 
69
73
  /** Sort possible config files so that deepest is first */
70
- const possibleConfigFiles = [...cachedFilesWithStatus, ...otherFilesWithStatus]
71
- .flatMap(
74
+ const possibleConfigFiles = gitListedFiles
75
+ .flatMap((line) => {
72
76
  /**
73
77
  * Leave out lines starting with "S " to ignore not-checked-out files in a sparse repo.
74
78
  * The "S" status means a tracked file that is "skip-worktree"
75
79
  * @see https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt--t
76
- */ (line) => (line.startsWith('S ') ? [] : [line.replace(/^[HSMRCK?U] /, '')])
77
- )
78
- .filter(filterPossibleConfigFiles)
79
- .map((file) => normalizePath(path.join(topLevelDir, file)))
80
- .filter(isInsideDirectory(cwd))
80
+ */
81
+ if (line.startsWith('S ')) {
82
+ return []
83
+ }
84
+
85
+ const relativePath = line.replace(/^[HSMRCK?U] /, '')
86
+ const absolutePath = normalizePath(path.join(topLevelDir, relativePath))
87
+ return [absolutePath]
88
+ })
81
89
  .sort(sortDeepestParth)
82
90
 
83
91
  debugLog('Found possible config files:', possibleConfigFiles)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "16.1.2",
3
+ "version": "16.1.3",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,10 @@
28
28
  "lint-staged": "bin/lint-staged.js"
29
29
  },
30
30
  "exports": {
31
- ".": "./lib/index.js",
31
+ ".": {
32
+ "types": "./lib/index.d.ts",
33
+ "default": "./lib/index.js"
34
+ },
32
35
  "./bin": "./bin/lint-staged.js",
33
36
  "./package.json": "./package.json"
34
37
  },
@@ -51,7 +54,7 @@
51
54
  "commander": "^14.0.0",
52
55
  "debug": "^4.4.1",
53
56
  "lilconfig": "^3.1.3",
54
- "listr2": "^8.3.3",
57
+ "listr2": "^9.0.1",
55
58
  "micromatch": "^4.0.8",
56
59
  "nano-spawn": "^1.0.2",
57
60
  "pidtree": "^0.6.0",
@@ -60,25 +63,25 @@
60
63
  },
61
64
  "devDependencies": {
62
65
  "@changesets/changelog-github": "0.5.1",
63
- "@changesets/cli": "2.29.4",
66
+ "@changesets/cli": "2.29.5",
64
67
  "@commitlint/cli": "19.8.1",
65
68
  "@commitlint/config-conventional": "19.8.1",
66
- "@eslint/js": "9.29.0",
69
+ "@eslint/js": "9.32.0",
67
70
  "consolemock": "1.1.0",
68
- "cross-env": "7.0.3",
69
- "eslint": "9.29.0",
70
- "eslint-config-prettier": "10.1.5",
71
- "eslint-plugin-jest": "28.13.5",
72
- "eslint-plugin-n": "17.20.0",
73
- "eslint-plugin-prettier": "5.4.1",
71
+ "cross-env": "10.0.0",
72
+ "eslint": "9.32.0",
73
+ "eslint-config-prettier": "10.1.8",
74
+ "eslint-plugin-jest": "29.0.1",
75
+ "eslint-plugin-n": "17.21.3",
76
+ "eslint-plugin-prettier": "5.5.3",
74
77
  "eslint-plugin-simple-import-sort": "12.1.1",
75
78
  "husky": "9.1.7",
76
- "jest": "30.0.0",
79
+ "jest": "30.0.5",
77
80
  "jest-snapshot-serializer-ansi": "2.2.1",
78
81
  "mock-stdin": "1.0.0",
79
- "prettier": "3.5.3",
82
+ "prettier": "3.6.2",
80
83
  "semver": "7.7.2",
81
- "typescript": "5.8.3"
84
+ "typescript": "5.9.2"
82
85
  },
83
86
  "keywords": [
84
87
  "lint",