lint-staged 17.0.2 → 17.0.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/README.md +7 -7
- package/lib/execGit.js +1 -0
- package/lib/gitWorkflow.js +28 -9
- package/lib/messages.js +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ See [examples](#examples) and [configuration](#configuration) for more informati
|
|
|
92
92
|
|
|
93
93
|
## Changelog
|
|
94
94
|
|
|
95
|
-
See [Releases](https://github.com/
|
|
95
|
+
See [Releases](https://github.com/lint-staged/lint-staged/releases).
|
|
96
96
|
|
|
97
97
|
### Migration
|
|
98
98
|
|
|
@@ -396,7 +396,7 @@ This will result in _lint-staged_ running `eslint file-1.js file-2.js`, when you
|
|
|
396
396
|
|
|
397
397
|
## Using JS configuration files
|
|
398
398
|
|
|
399
|
-
Writing the configuration file in JavaScript is the most powerful way to configure lint-staged (`lint-staged.config.js`, [similar](https://github.com/
|
|
399
|
+
Writing the configuration file in JavaScript is the most powerful way to configure lint-staged (`lint-staged.config.js`, [similar](https://github.com/lint-staged/lint-staged#configuration), or passed via `--config`). From the configuration file, you can export either a single function or an object.
|
|
400
400
|
|
|
401
401
|
If the `exports` value is a function, it will receive an array of all staged filenames. You can then build your own matchers for the files and return a command string or an array of command strings. These strings are considered complete and should include the filename arguments, if wanted.
|
|
402
402
|
|
|
@@ -497,7 +497,7 @@ export default {
|
|
|
497
497
|
<details>
|
|
498
498
|
<summary>Click to expand</summary>
|
|
499
499
|
|
|
500
|
-
It's better to use the [function-based configuration (seen above)](https://github.com/
|
|
500
|
+
It's better to use the [function-based configuration (seen above)](https://github.com/lint-staged/lint-staged#example-export-a-function-to-build-your-own-matchers), if your use case is this.
|
|
501
501
|
|
|
502
502
|
```js
|
|
503
503
|
// lint-staged.config.js
|
|
@@ -945,7 +945,7 @@ tl;dr: Yes, but the pattern should start with `../`.
|
|
|
945
945
|
|
|
946
946
|
By default, `lint-staged` executes tasks only on the files present inside the project folder(where `lint-staged` is installed and run from).
|
|
947
947
|
So this question is relevant _only_ when the project folder is a child folder inside the git repo.
|
|
948
|
-
In certain project setups, it might be desirable to bypass this restriction. See [#425](https://github.com/
|
|
948
|
+
In certain project setups, it might be desirable to bypass this restriction. See [#425](https://github.com/lint-staged/lint-staged/issues/425), [#487](https://github.com/lint-staged/lint-staged/issues/487) for more context.
|
|
949
949
|
|
|
950
950
|
`lint-staged` provides an escape hatch for the same(`>= v7.3.0`). For patterns that start with `../`, all the staged files are allowed to match against the pattern.
|
|
951
951
|
Note that patterns like `*.js`, `**/*.js` will still only match the project files and not any of the files in parent or sibling directories.
|
|
@@ -993,7 +993,7 @@ npx lint-staged --diff="$(git merge-base main HEAD)"
|
|
|
993
993
|
|
|
994
994
|
You should not use `ng lint` through _lint-staged_, because it's designed to lint an entire project. Instead, you can add `ng lint` to your git pre-commit hook the same way as you would run lint-staged.
|
|
995
995
|
|
|
996
|
-
See issue [!951](https://github.com/
|
|
996
|
+
See issue [!951](https://github.com/lint-staged/lint-staged/issues/951) for more details and possible workarounds.
|
|
997
997
|
|
|
998
998
|
</details>
|
|
999
999
|
|
|
@@ -1033,7 +1033,7 @@ export default {
|
|
|
1033
1033
|
|
|
1034
1034
|
In versions of ESLint > 7, [isPathIgnored](https://eslint.org/docs/developer-guide/nodejs-api#-eslintispathignoredfilepath) is an async function and now returns a promise. The code below can be used to reinstate the above functionality.
|
|
1035
1035
|
|
|
1036
|
-
Since [10.5.3](https://github.com/
|
|
1036
|
+
Since [10.5.3](https://github.com/lint-staged/lint-staged/releases), any errors due to a bad ESLint config will come through to the console.
|
|
1037
1037
|
|
|
1038
1038
|
```js
|
|
1039
1039
|
import { ESLint } from 'eslint'
|
|
@@ -1088,7 +1088,7 @@ When running `lint-staged` via Husky hooks, TypeScript may ignore `tsconfig.json
|
|
|
1088
1088
|
> **TS17004:** Cannot use JSX unless the '--jsx' flag is provided.
|
|
1089
1089
|
> **TS1056:** Accessors are only available when targeting ECMAScript 5 and higher.
|
|
1090
1090
|
|
|
1091
|
-
See issue [#825](https://github.com/
|
|
1091
|
+
See issue [#825](https://github.com/lint-staged/lint-staged/issues/825) for more details.
|
|
1092
1092
|
|
|
1093
1093
|
#### Root Cause
|
|
1094
1094
|
|
package/lib/execGit.js
CHANGED
package/lib/gitWorkflow.js
CHANGED
|
@@ -294,18 +294,37 @@ export class GitWorkflow {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
//
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
delete process.env.GIT_INDEX_FILE
|
|
297
|
+
// This looks confusing but the intent is to only normalize truthy values
|
|
298
|
+
const activeIndexFile = process.env.GIT_INDEX_FILE
|
|
299
|
+
? normalizePath(process.env.GIT_INDEX_FILE)
|
|
300
|
+
: process.env.GIT_INDEX_FILE
|
|
302
301
|
|
|
303
|
-
debugLog('Updating Git index again
|
|
304
|
-
|
|
305
|
-
// Update index for the files that were originally staged, ignore others
|
|
302
|
+
debugLog('Updating active Git index again: %s', activeIndexFile)
|
|
306
303
|
await this.execGit(['update-index', '--again'])
|
|
304
|
+
debugLog('Done updating Git index again: %s', activeIndexFile)
|
|
305
|
+
|
|
306
|
+
if (activeIndexFile?.endsWith('.lock')) {
|
|
307
|
+
const defaultIndexLock = normalizePath(
|
|
308
|
+
await this.execGit(['rev-parse', '--path-format=absolute', '--git-path', 'index.lock'])
|
|
309
|
+
)
|
|
307
310
|
|
|
308
|
-
|
|
311
|
+
/**
|
|
312
|
+
* If the active index file is a non-default lockfile, we are committing with a pathspec
|
|
313
|
+
* without having explicitly run `git add`. In this case we need to also update the
|
|
314
|
+
* default index, otherwise there will be leftover diff after committing
|
|
315
|
+
*/
|
|
316
|
+
if (activeIndexFile !== defaultIndexLock) {
|
|
317
|
+
debugLog('Updating default Git index lock again: %s', defaultIndexLock)
|
|
318
|
+
|
|
319
|
+
await this.execGit(['update-index', '--again'], {
|
|
320
|
+
env: {
|
|
321
|
+
GIT_INDEX_FILE: defaultIndexLock,
|
|
322
|
+
},
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
debugLog('Done updating default Git index lock again: %s', defaultIndexLock)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
309
328
|
|
|
310
329
|
const stagedFilesAfterAdd = await this.execGit([
|
|
311
330
|
...getDiffCommand(this.diff, this.diffFilter),
|
package/lib/messages.js
CHANGED
|
@@ -59,7 +59,7 @@ export const invalidOption = (name, value, message) => `${red(`${error} Validati
|
|
|
59
59
|
|
|
60
60
|
${message}
|
|
61
61
|
|
|
62
|
-
See https://github.com/
|
|
62
|
+
See https://github.com/lint-staged/lint-staged#command-line-flags`
|
|
63
63
|
|
|
64
64
|
export const PREVENTED_EMPTY_COMMIT = `
|
|
65
65
|
${yellow(`${warning} lint-staged prevented an empty git commit.
|
|
@@ -87,7 +87,7 @@ export const failedToParseConfig = (
|
|
|
87
87
|
|
|
88
88
|
${error}
|
|
89
89
|
|
|
90
|
-
See https://github.com/
|
|
90
|
+
See https://github.com/lint-staged/lint-staged#configuration.`
|
|
91
91
|
|
|
92
92
|
export const UNSTAGED_CHANGES_BACKUP_STASH_LOCATION = `Unstaged changes have been kept back in a patch file:`
|
|
93
93
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.4",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@changesets/changelog-github": "0.7.0",
|
|
61
61
|
"@changesets/cli": "2.31.0",
|
|
62
|
-
"@commitlint/cli": "
|
|
63
|
-
"@commitlint/config-conventional": "
|
|
62
|
+
"@commitlint/cli": "21.0.0",
|
|
63
|
+
"@commitlint/config-conventional": "21.0.0",
|
|
64
64
|
"@eslint/js": "10.0.1",
|
|
65
65
|
"@vitest/coverage-istanbul": "4.1.5",
|
|
66
|
-
"@vitest/eslint-plugin": "1.6.
|
|
66
|
+
"@vitest/eslint-plugin": "1.6.17",
|
|
67
67
|
"consolemock": "1.1.0",
|
|
68
68
|
"cross-env": "10.1.0",
|
|
69
69
|
"eslint": "10.3.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"husky": "9.1.7",
|
|
75
75
|
"mock-stdin": "1.0.0",
|
|
76
76
|
"prettier": "3.8.3",
|
|
77
|
-
"semver": "7.
|
|
77
|
+
"semver": "7.8.0",
|
|
78
78
|
"vitest": "4.1.5"
|
|
79
79
|
},
|
|
80
80
|
"keywords": [
|