lint-staged 16.1.6 → 16.2.1
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 +91 -25
- package/bin/lint-staged.js +84 -67
- package/lib/chunkFiles.js +2 -3
- package/lib/colors.js +106 -0
- package/lib/debug.js +27 -0
- package/lib/execGit.js +3 -2
- package/lib/figures.js +5 -4
- package/lib/file.js +2 -2
- package/lib/generateTasks.js +2 -2
- package/lib/getFunctionTask.js +2 -3
- package/lib/getRenderer.js +7 -8
- package/lib/getSpawnedTask.js +9 -6
- package/lib/getSpawnedTasks.js +14 -5
- package/lib/gitWorkflow.js +109 -60
- package/lib/groupFilesByConfig.js +2 -2
- package/lib/index.d.ts +30 -9
- package/lib/index.js +25 -8
- package/lib/loadConfig.js +30 -53
- package/lib/messages.js +21 -22
- package/lib/resolveGitRepo.js +2 -3
- package/lib/runAll.js +45 -24
- package/lib/searchConfigs.js +107 -60
- package/lib/state.js +22 -6
- package/lib/symbols.js +2 -0
- package/lib/validateConfig.js +2 -3
- package/lib/validateOptions.js +2 -3
- package/package.json +15 -21
- package/lib/dynamicImport.js +0 -3
package/lib/state.js
CHANGED
|
@@ -2,27 +2,37 @@ import EventEmitter from 'events'
|
|
|
2
2
|
|
|
3
3
|
import { GIT_ERROR, TASK_ERROR } from './messages.js'
|
|
4
4
|
import {
|
|
5
|
+
ExitCodeError,
|
|
5
6
|
GitError,
|
|
6
7
|
RestoreOriginalStateError,
|
|
7
8
|
RestoreUnstagedChangesError,
|
|
8
9
|
TaskError,
|
|
9
10
|
} from './symbols.js'
|
|
10
11
|
|
|
11
|
-
export const getInitialState = ({
|
|
12
|
+
export const getInitialState = ({
|
|
13
|
+
hideUnstaged = false,
|
|
14
|
+
hidePartiallyStaged = !hideUnstaged,
|
|
15
|
+
quiet = false,
|
|
16
|
+
revert = true,
|
|
17
|
+
} = {}) => ({
|
|
12
18
|
backupHash: null,
|
|
13
19
|
errors: new Set([]),
|
|
14
20
|
events: new EventEmitter(),
|
|
15
|
-
|
|
21
|
+
hasFilesToHide: null,
|
|
16
22
|
output: [],
|
|
17
23
|
quiet,
|
|
18
24
|
shouldBackup: null,
|
|
19
|
-
shouldHidePartiallyStaged:
|
|
25
|
+
shouldHidePartiallyStaged: hidePartiallyStaged,
|
|
26
|
+
shouldHideUnstaged: hideUnstaged,
|
|
20
27
|
shouldRevert: revert,
|
|
21
28
|
unstagedPatch: null,
|
|
22
29
|
})
|
|
23
30
|
|
|
24
31
|
export const shouldHidePartiallyStagedFiles = (ctx) =>
|
|
25
|
-
ctx.
|
|
32
|
+
ctx.shouldHidePartiallyStaged && ctx.hasFilesToHide
|
|
33
|
+
|
|
34
|
+
export const shouldRestoreUnstagedChanges = (ctx) =>
|
|
35
|
+
(ctx.shouldHideUnstaged || ctx.shouldHidePartiallyStaged) && ctx.hasFilesToHide
|
|
26
36
|
|
|
27
37
|
export const applyModificationsSkipped = (ctx) => {
|
|
28
38
|
// Always apply back unstaged modifications when skipping revert or backup
|
|
@@ -52,11 +62,17 @@ export const restoreUnstagedChangesSkipped = (ctx) => {
|
|
|
52
62
|
export const restoreOriginalStateEnabled = (ctx) =>
|
|
53
63
|
!!ctx.shouldRevert &&
|
|
54
64
|
!!ctx.shouldBackup &&
|
|
55
|
-
(ctx.errors.has(
|
|
65
|
+
(ctx.errors.has(ExitCodeError) ||
|
|
66
|
+
ctx.errors.has(TaskError) ||
|
|
67
|
+
ctx.errors.has(RestoreUnstagedChangesError))
|
|
56
68
|
|
|
57
69
|
export const restoreOriginalStateSkipped = (ctx) => {
|
|
58
70
|
// Should be skipped in case of unknown git errors
|
|
59
|
-
if (
|
|
71
|
+
if (
|
|
72
|
+
ctx.errors.has(GitError) &&
|
|
73
|
+
!ctx.errors.has(RestoreUnstagedChangesError) &&
|
|
74
|
+
!ctx.errors.has(ExitCodeError)
|
|
75
|
+
) {
|
|
60
76
|
return GIT_ERROR
|
|
61
77
|
}
|
|
62
78
|
}
|
package/lib/symbols.js
CHANGED
|
@@ -25,3 +25,5 @@ export const RestoreOriginalStateError = Symbol('RestoreOriginalStateError')
|
|
|
25
25
|
export const RestoreUnstagedChangesError = Symbol('RestoreUnstagedChangesError')
|
|
26
26
|
|
|
27
27
|
export const TaskError = Symbol('TaskError')
|
|
28
|
+
|
|
29
|
+
export const ExitCodeError = Symbol('ExitCodeError')
|
package/lib/validateConfig.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { inspect } from 'node:util'
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { createDebug } from './debug.js'
|
|
7
6
|
import { configurationError, failedToParseConfig } from './messages.js'
|
|
8
7
|
import { ConfigEmptyError, ConfigFormatError } from './symbols.js'
|
|
9
8
|
import { validateBraces } from './validateBraces.js'
|
|
10
9
|
|
|
11
|
-
const debugLog =
|
|
10
|
+
const debugLog = createDebug('lint-staged:validateConfig')
|
|
12
11
|
|
|
13
12
|
export const validateConfigLogic = (config, configPath, logger) => {
|
|
14
13
|
debugLog('Validating config from `%s`...', configPath)
|
package/lib/validateOptions.js
CHANGED
|
@@ -2,12 +2,11 @@ import { constants } from 'node:fs'
|
|
|
2
2
|
import fs from 'node:fs/promises'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { createDebug } from './debug.js'
|
|
7
6
|
import { invalidOption } from './messages.js'
|
|
8
7
|
import { InvalidOptionsError } from './symbols.js'
|
|
9
8
|
|
|
10
|
-
const debugLog =
|
|
9
|
+
const debugLog = createDebug('lint-staged:validateOptions')
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Validate lint-staged options, either from the Node.js API or the command line flags.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "16.1
|
|
3
|
+
"version": "16.2.1",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
},
|
|
14
14
|
"author": "Andrey Okonetchnikov <andrey@okonet.ru>",
|
|
15
15
|
"maintainers": [
|
|
16
|
-
"Lufty Wiranda <lufty.wiranda@gmail.com>",
|
|
17
|
-
"Suhas Karanth <sudo.suhas@gmail.com>",
|
|
18
16
|
"Iiro Jäppinen <iiro@jappinen.fi> (https://iiro.fi)"
|
|
19
17
|
],
|
|
20
18
|
"funding": {
|
|
@@ -42,47 +40,43 @@
|
|
|
42
40
|
"MIGRATION.md"
|
|
43
41
|
],
|
|
44
42
|
"scripts": {
|
|
45
|
-
"lint": "eslint
|
|
46
|
-
"test": "
|
|
47
|
-
"
|
|
48
|
-
"typecheck": "tsc --noEmit --strict test/types/index.ts",
|
|
43
|
+
"lint": "eslint",
|
|
44
|
+
"test": "vitest",
|
|
45
|
+
"typecheck": "tsc",
|
|
49
46
|
"version": "npx changeset version",
|
|
50
47
|
"postversion": "npm i --package-lock-only && git commit -am \"chore(changeset): release\"",
|
|
51
48
|
"tag": "npx changeset tag"
|
|
52
49
|
},
|
|
53
50
|
"dependencies": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"debug": "^4.4.1",
|
|
57
|
-
"lilconfig": "^3.1.3",
|
|
58
|
-
"listr2": "^9.0.3",
|
|
51
|
+
"commander": "^14.0.1",
|
|
52
|
+
"listr2": "^9.0.4",
|
|
59
53
|
"micromatch": "^4.0.8",
|
|
60
|
-
"nano-spawn": "^1.0.
|
|
54
|
+
"nano-spawn": "^1.0.3",
|
|
61
55
|
"pidtree": "^0.6.0",
|
|
62
56
|
"string-argv": "^0.3.2",
|
|
63
57
|
"yaml": "^2.8.1"
|
|
64
58
|
},
|
|
65
59
|
"devDependencies": {
|
|
66
60
|
"@changesets/changelog-github": "0.5.1",
|
|
67
|
-
"@changesets/cli": "2.29.
|
|
61
|
+
"@changesets/cli": "2.29.7",
|
|
68
62
|
"@commitlint/cli": "19.8.1",
|
|
69
63
|
"@commitlint/config-conventional": "19.8.1",
|
|
70
|
-
"@eslint/js": "9.
|
|
64
|
+
"@eslint/js": "9.36.0",
|
|
65
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
66
|
+
"@vitest/eslint-plugin": "1.3.12",
|
|
71
67
|
"consolemock": "1.1.0",
|
|
72
68
|
"cross-env": "10.0.0",
|
|
73
|
-
"eslint": "9.
|
|
69
|
+
"eslint": "9.36.0",
|
|
74
70
|
"eslint-config-prettier": "10.1.8",
|
|
75
|
-
"eslint-plugin-
|
|
76
|
-
"eslint-plugin-n": "17.21.3",
|
|
71
|
+
"eslint-plugin-n": "17.23.1",
|
|
77
72
|
"eslint-plugin-prettier": "5.5.4",
|
|
78
73
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
79
74
|
"husky": "9.1.7",
|
|
80
|
-
"jest": "30.1.1",
|
|
81
|
-
"jest-snapshot-serializer-ansi": "2.2.1",
|
|
82
75
|
"mock-stdin": "1.0.0",
|
|
83
76
|
"prettier": "3.6.2",
|
|
84
77
|
"semver": "7.7.2",
|
|
85
|
-
"typescript": "5.9.2"
|
|
78
|
+
"typescript": "5.9.2",
|
|
79
|
+
"vitest": "3.2.4"
|
|
86
80
|
},
|
|
87
81
|
"keywords": [
|
|
88
82
|
"lint",
|
package/lib/dynamicImport.js
DELETED