lint-staged 16.2.2 → 16.2.4
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/gitWorkflow.js +16 -12
- package/lib/loadConfig.js +1 -3
- package/lib/messages.js +3 -3
- package/lib/runAll.js +2 -1
- package/lib/state.js +3 -1
- package/package.json +10 -10
package/lib/gitWorkflow.js
CHANGED
|
@@ -277,15 +277,6 @@ export class GitWorkflow {
|
|
|
277
277
|
task.title = `Backed up original state in git stash (${ctx.backupHash})`
|
|
278
278
|
debugLog(task.title)
|
|
279
279
|
}
|
|
280
|
-
|
|
281
|
-
if (this.failOnChanges) {
|
|
282
|
-
debugLog(
|
|
283
|
-
'Calculating SHA-256 hash of unstaged changes because "--fail-on-changes" was used...'
|
|
284
|
-
)
|
|
285
|
-
const diff = await this.execGit(['diff', '--patch', '--unified=0'])
|
|
286
|
-
this.unstagedDiffSha256 = calculateSha256(diff)
|
|
287
|
-
debugLog('SHA-256 hash of unstaged changes is %S', this.unstagedDiffSha256)
|
|
288
|
-
}
|
|
289
280
|
} catch (error) {
|
|
290
281
|
handleError(error, ctx)
|
|
291
282
|
}
|
|
@@ -304,19 +295,32 @@ export class GitWorkflow {
|
|
|
304
295
|
}
|
|
305
296
|
}
|
|
306
297
|
|
|
298
|
+
async runTasks(ctx, task, { listrTasks, concurrent }) {
|
|
299
|
+
if (ctx.shouldFailOnChanges) {
|
|
300
|
+
debugLog(
|
|
301
|
+
'Calculating SHA-256 hash of unstaged changes because "--fail-on-changes" was used...'
|
|
302
|
+
)
|
|
303
|
+
const diff = await this.execGit(['diff', '--patch', '--unified=0'])
|
|
304
|
+
ctx.unstagedDiffSha256 = calculateSha256(diff)
|
|
305
|
+
debugLog('SHA-256 hash of unstaged changes is %s', ctx.unstagedDiffSha256)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return task.newListr(listrTasks, { concurrent })
|
|
309
|
+
}
|
|
310
|
+
|
|
307
311
|
/**
|
|
308
312
|
* Applies back task modifications, and unstaged changes hidden in the stash.
|
|
309
313
|
* In case of a merge-conflict retry with 3-way merge.
|
|
310
314
|
*/
|
|
311
315
|
async applyModifications(ctx) {
|
|
312
|
-
if (
|
|
316
|
+
if (ctx.shouldFailOnChanges) {
|
|
313
317
|
debugLog(
|
|
314
318
|
'Calculating SHA-256 hash of changes after tasks because "--fail-on-changes" was used...'
|
|
315
319
|
)
|
|
316
320
|
const diff = await this.execGit(['diff', '--patch', '--unified=0'])
|
|
317
321
|
const diffSha256 = calculateSha256(diff)
|
|
318
|
-
debugLog('SHA-256 hash of changes after tasks is %
|
|
319
|
-
if (
|
|
322
|
+
debugLog('SHA-256 hash of changes after tasks is %s', diffSha256)
|
|
323
|
+
if (ctx.unstagedDiffSha256 !== diffSha256) {
|
|
320
324
|
ctx.errors.add(FailOnChangesError)
|
|
321
325
|
throw new Error('Tasks modified files and --fail-on-changes was used!')
|
|
322
326
|
}
|
package/lib/loadConfig.js
CHANGED
|
@@ -4,8 +4,6 @@ import fs from 'node:fs/promises'
|
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { pathToFileURL } from 'node:url'
|
|
6
6
|
|
|
7
|
-
import YAML from 'yaml'
|
|
8
|
-
|
|
9
7
|
import { CONFIG_NAME, PACKAGE_JSON_FILE, PACKAGE_YAML_FILES } from './configFiles.js'
|
|
10
8
|
import { createDebug } from './debug.js'
|
|
11
9
|
import { failedToLoadConfig } from './messages.js'
|
|
@@ -34,7 +32,7 @@ const jsonParse = async (filename) => {
|
|
|
34
32
|
const yamlParse = async (filename) => {
|
|
35
33
|
const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filename))
|
|
36
34
|
try {
|
|
37
|
-
const content = await readFile(filename)
|
|
35
|
+
const [YAML, content] = await Promise.all([import('yaml'), readFile(filename)])
|
|
38
36
|
const yaml = YAML.parse(content)
|
|
39
37
|
return isPackageFile ? yaml[CONFIG_NAME] : yaml
|
|
40
38
|
} catch (error) {
|
package/lib/messages.js
CHANGED
|
@@ -20,11 +20,11 @@ export const incorrectBraces = (before, after) =>
|
|
|
20
20
|
`
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
-
export const NO_CONFIGURATION = `${error}
|
|
23
|
+
export const NO_CONFIGURATION = `${error} lint-staged could not find any valid configuration.`
|
|
24
24
|
|
|
25
|
-
export const NO_STAGED_FILES = `${info}
|
|
25
|
+
export const NO_STAGED_FILES = `${info} lint-staged could not find any staged files.`
|
|
26
26
|
|
|
27
|
-
export const NO_TASKS = `${info}
|
|
27
|
+
export const NO_TASKS = `${info} lint-staged could not find any staged files matching configured tasks.`
|
|
28
28
|
|
|
29
29
|
export const skippingBackup = (hasInitialCommit, diff) => {
|
|
30
30
|
const reason =
|
package/lib/runAll.js
CHANGED
|
@@ -110,6 +110,7 @@ export const runAll = async (
|
|
|
110
110
|
debugLog('Using working directory `%s`', cwd)
|
|
111
111
|
|
|
112
112
|
const ctx = getInitialState({
|
|
113
|
+
failOnChanges,
|
|
113
114
|
hidePartiallyStaged,
|
|
114
115
|
hideUnstaged,
|
|
115
116
|
quiet,
|
|
@@ -336,7 +337,7 @@ export const runAll = async (
|
|
|
336
337
|
},
|
|
337
338
|
{
|
|
338
339
|
title: `Running tasks for ${diff ? 'changed' : 'staged'} files...`,
|
|
339
|
-
task: (ctx, task) =>
|
|
340
|
+
task: (ctx, task) => git.runTasks(ctx, task, { listrTasks, concurrent }),
|
|
340
341
|
skip: () => listrTasks.every((task) => task.skip()),
|
|
341
342
|
},
|
|
342
343
|
{
|
package/lib/state.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from './symbols.js'
|
|
11
11
|
|
|
12
12
|
export const getInitialState = ({
|
|
13
|
+
failOnChanges = false,
|
|
13
14
|
hideUnstaged = false,
|
|
14
15
|
hidePartiallyStaged = !hideUnstaged,
|
|
15
16
|
quiet = false,
|
|
@@ -18,7 +19,7 @@ export const getInitialState = ({
|
|
|
18
19
|
backupHash: null,
|
|
19
20
|
errors: new Set([]),
|
|
20
21
|
events: new EventEmitter(),
|
|
21
|
-
shouldFailOnChanges:
|
|
22
|
+
shouldFailOnChanges: failOnChanges,
|
|
22
23
|
hasFilesToHide: null,
|
|
23
24
|
output: [],
|
|
24
25
|
quiet,
|
|
@@ -26,6 +27,7 @@ export const getInitialState = ({
|
|
|
26
27
|
shouldHidePartiallyStaged: hidePartiallyStaged,
|
|
27
28
|
shouldHideUnstaged: hideUnstaged,
|
|
28
29
|
shouldRevert: revert,
|
|
30
|
+
unstagedDiffSha256: null,
|
|
29
31
|
unstagedPatch: null,
|
|
30
32
|
})
|
|
31
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.4",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"commander": "^14.0.1",
|
|
52
52
|
"listr2": "^9.0.4",
|
|
53
53
|
"micromatch": "^4.0.8",
|
|
54
|
-
"nano-spawn": "^
|
|
54
|
+
"nano-spawn": "^2.0.0",
|
|
55
55
|
"pidtree": "^0.6.0",
|
|
56
56
|
"string-argv": "^0.3.2",
|
|
57
57
|
"yaml": "^2.8.1"
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@changesets/changelog-github": "0.5.1",
|
|
61
61
|
"@changesets/cli": "2.29.7",
|
|
62
|
-
"@commitlint/cli": "
|
|
63
|
-
"@commitlint/config-conventional": "
|
|
64
|
-
"@eslint/js": "9.
|
|
62
|
+
"@commitlint/cli": "20.1.0",
|
|
63
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
64
|
+
"@eslint/js": "9.37.0",
|
|
65
65
|
"@vitest/coverage-v8": "3.2.4",
|
|
66
|
-
"@vitest/eslint-plugin": "1.3.
|
|
66
|
+
"@vitest/eslint-plugin": "1.3.16",
|
|
67
67
|
"consolemock": "1.1.0",
|
|
68
|
-
"cross-env": "10.
|
|
69
|
-
"eslint": "9.
|
|
68
|
+
"cross-env": "10.1.0",
|
|
69
|
+
"eslint": "9.37.0",
|
|
70
70
|
"eslint-config-prettier": "10.1.8",
|
|
71
71
|
"eslint-plugin-n": "17.23.1",
|
|
72
72
|
"eslint-plugin-prettier": "5.5.4",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"husky": "9.1.7",
|
|
75
75
|
"mock-stdin": "1.0.0",
|
|
76
76
|
"prettier": "3.6.2",
|
|
77
|
-
"semver": "7.7.
|
|
78
|
-
"typescript": "5.9.
|
|
77
|
+
"semver": "7.7.3",
|
|
78
|
+
"typescript": "5.9.3",
|
|
79
79
|
"vitest": "3.2.4"
|
|
80
80
|
},
|
|
81
81
|
"keywords": [
|