lint-staged
Advanced tools
Comparing version 15.2.1 to 15.2.2
@@ -16,6 +16,5 @@ /** @typedef {import('./index').Logger} Logger */ | ||
const EXEC_GIT = ['ls-files', '-z', '--full-name'] | ||
const EXEC_GIT = ['ls-files', '-z', '--full-name', '-t'] | ||
const filterPossibleConfigFiles = (files) => | ||
files.filter((file) => CONFIG_FILE_NAMES.includes(path.basename(file))) | ||
const filterPossibleConfigFiles = (file) => CONFIG_FILE_NAMES.includes(path.basename(file)) | ||
@@ -62,13 +61,19 @@ const numberOfLevels = (file) => file.split('/').length | ||
const [cachedFiles, otherFiles] = await Promise.all([ | ||
const [cachedFilesWithStatus, otherFilesWithStatus] = await Promise.all([ | ||
/** Get all possible config files known to git */ | ||
execGit(EXEC_GIT, { cwd: gitDir }).then(parseGitZOutput).then(filterPossibleConfigFiles), | ||
execGit(EXEC_GIT, { cwd: gitDir }).then(parseGitZOutput), | ||
/** Get all possible config files from uncommitted files */ | ||
execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir }) | ||
.then(parseGitZOutput) | ||
.then(filterPossibleConfigFiles), | ||
execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir }).then(parseGitZOutput), | ||
]) | ||
/** Sort possible config files so that deepest is first */ | ||
const possibleConfigFiles = [...cachedFiles, ...otherFiles] | ||
const possibleConfigFiles = [...cachedFilesWithStatus, ...otherFilesWithStatus] | ||
.flatMap( | ||
/** | ||
* Leave out lines starting with "S " to ignore not-checked-out files in a sparse repo. | ||
* The "S" status means a tracked file that is "skip-worktree" | ||
* @see https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt--t | ||
*/ (line) => (line.startsWith('S ') ? [] : [line.replace(/^[HSMRCK?U] /, '')]) | ||
) | ||
.filter(filterPossibleConfigFiles) | ||
.map((file) => normalizePath(path.join(gitDir, file))) | ||
@@ -75,0 +80,0 @@ .filter(isInsideDirectory(cwd)) |
{ | ||
"name": "lint-staged", | ||
"version": "15.2.1", | ||
"version": "15.2.2", | ||
"description": "Lint files staged by git", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
120058
2076