lint-staged 15.2.1 → 15.2.2
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/lib/searchConfigs.js +14 -9
- package/package.json +1 -1
package/lib/searchConfigs.js
CHANGED
|
@@ -13,10 +13,9 @@ import { CONFIG_FILE_NAMES } from './configFiles.js'
|
|
|
13
13
|
|
|
14
14
|
const debugLog = debug('lint-staged:searchConfigs')
|
|
15
15
|
|
|
16
|
-
const EXEC_GIT = ['ls-files', '-z', '--full-name']
|
|
16
|
+
const EXEC_GIT = ['ls-files', '-z', '--full-name', '-t']
|
|
17
17
|
|
|
18
|
-
const filterPossibleConfigFiles = (
|
|
19
|
-
files.filter((file) => CONFIG_FILE_NAMES.includes(path.basename(file)))
|
|
18
|
+
const filterPossibleConfigFiles = (file) => CONFIG_FILE_NAMES.includes(path.basename(file))
|
|
20
19
|
|
|
21
20
|
const numberOfLevels = (file) => file.split('/').length
|
|
22
21
|
|
|
@@ -58,17 +57,23 @@ export const searchConfigs = async (
|
|
|
58
57
|
return { [configPath]: validateConfig(config, filepath, logger) }
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
const [
|
|
60
|
+
const [cachedFilesWithStatus, otherFilesWithStatus] = await Promise.all([
|
|
62
61
|
/** Get all possible config files known to git */
|
|
63
|
-
execGit(EXEC_GIT, { cwd: gitDir }).then(parseGitZOutput)
|
|
62
|
+
execGit(EXEC_GIT, { cwd: gitDir }).then(parseGitZOutput),
|
|
64
63
|
/** Get all possible config files from uncommitted files */
|
|
65
|
-
execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir })
|
|
66
|
-
.then(parseGitZOutput)
|
|
67
|
-
.then(filterPossibleConfigFiles),
|
|
64
|
+
execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir }).then(parseGitZOutput),
|
|
68
65
|
])
|
|
69
66
|
|
|
70
67
|
/** Sort possible config files so that deepest is first */
|
|
71
|
-
const possibleConfigFiles = [...
|
|
68
|
+
const possibleConfigFiles = [...cachedFilesWithStatus, ...otherFilesWithStatus]
|
|
69
|
+
.flatMap(
|
|
70
|
+
/**
|
|
71
|
+
* Leave out lines starting with "S " to ignore not-checked-out files in a sparse repo.
|
|
72
|
+
* The "S" status means a tracked file that is "skip-worktree"
|
|
73
|
+
* @see https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt--t
|
|
74
|
+
*/ (line) => (line.startsWith('S ') ? [] : [line.replace(/^[HSMRCK?U] /, '')])
|
|
75
|
+
)
|
|
76
|
+
.filter(filterPossibleConfigFiles)
|
|
72
77
|
.map((file) => normalizePath(path.join(gitDir, file)))
|
|
73
78
|
.filter(isInsideDirectory(cwd))
|
|
74
79
|
.sort(sortDeepestParth)
|