lint-staged 10.4.1 → 10.5.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/README.md +11 -8
- package/bin/lint-staged.js +20 -1
- package/lib/messages.js +3 -0
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ This project contains a script that will run arbitrary shell tasks with a list o
|
|
|
12
12
|
|
|
13
13
|
## Related blogs posts and talks
|
|
14
14
|
|
|
15
|
-
- [
|
|
16
|
-
- [Running Jest Tests Before Each Git Commit](https://benmccormick.org/2017/02/26/running-jest-tests-before-each-git-commit/)
|
|
17
|
-
- [AgentConf
|
|
18
|
-
- [SurviveJS
|
|
15
|
+
- [Introductory Medium post - Andrey Okonetchnikov, 2016](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8#.8qepn2b5l)
|
|
16
|
+
- [Running Jest Tests Before Each Git Commit - Ben McCormick, 2017](https://benmccormick.org/2017/02/26/running-jest-tests-before-each-git-commit/)
|
|
17
|
+
- [AgentConf presentation - Andrey Okonetchnikov, 2018](https://www.youtube.com/watch?v=-mhY7e-EsC4)
|
|
18
|
+
- [SurviveJS interview - Juho Vepsäläinen and Andrey Okonetchnikov, 2018](https://survivejs.com/blog/lint-staged-interview/)
|
|
19
19
|
|
|
20
20
|
> If you've written one, please submit a PR with the link to it!
|
|
21
21
|
|
|
@@ -62,7 +62,7 @@ Options:
|
|
|
62
62
|
-V, --version output the version number
|
|
63
63
|
--allow-empty allow empty commits when tasks revert all staged changes
|
|
64
64
|
(default: false)
|
|
65
|
-
-c, --config [path] path to configuration file
|
|
65
|
+
-c, --config [path] path to configuration file, or - to read from stdin
|
|
66
66
|
-d, --debug print additional debug information (default: false)
|
|
67
67
|
--no-stash disable the backup stash, and do not revert in case of
|
|
68
68
|
errors
|
|
@@ -78,7 +78,7 @@ Options:
|
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
- **`--allow-empty`**: By default, when linter tasks undo all staged changes, lint-staged will exit with an error and abort the commit. Use this flag to allow creating empty git commits.
|
|
81
|
-
- **`--config [path]`**: Manually specify a path to a config file or npm package name. Note: when used, lint-staged won't perform the config file search and print an error if the specified file cannot be found.
|
|
81
|
+
- **`--config [path]`**: Manually specify a path to a config file or npm package name. Note: when used, lint-staged won't perform the config file search and print an error if the specified file cannot be found. If '-' is provided as the filename then the config will be read from stdin, allowing piping in the config like `cat my-config.json | npx lint-staged --config -`.
|
|
82
82
|
- **`--debug`**: Run in debug mode. When set, it does the following:
|
|
83
83
|
- uses [debug](https://github.com/visionmedia/debug) internally to log additional information about staged files, commands being executed, location of binaries, etc. Debug logs, which are automatically enabled by passing the flag, can also be enabled by setting the environment variable `$DEBUG` to `lint-staged*`.
|
|
84
84
|
- uses [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`; this causes serial, uncoloured output to the terminal, instead of the default (beautified, dynamic) output.
|
|
@@ -97,8 +97,11 @@ Options:
|
|
|
97
97
|
Starting with v3.1 you can now use different ways of configuring it:
|
|
98
98
|
|
|
99
99
|
- `lint-staged` object in your `package.json`
|
|
100
|
-
- `.lintstagedrc` file in JSON or YML format
|
|
101
|
-
-
|
|
100
|
+
- `.lintstagedrc` file in JSON or YML format, or you can be explicit with the file extension:
|
|
101
|
+
- `.lintstagedrc.json`
|
|
102
|
+
- `.lintstagedrc.yaml`
|
|
103
|
+
- `.lintstagedrc.yml`
|
|
104
|
+
- `lint-staged.config.js`, `.lintstagedrc.js`, or `.lintstagedrc.cjs` file in JS format
|
|
102
105
|
- Pass a configuration file using the `--config` or `-c` flag
|
|
103
106
|
|
|
104
107
|
See [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for more details on what formats are supported.
|
package/bin/lint-staged.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
|
|
5
7
|
// Force colors for packages that depend on https://www.npmjs.com/package/supports-color
|
|
6
8
|
const { supportsColor } = require('chalk')
|
|
7
9
|
if (supportsColor && supportsColor.level) {
|
|
@@ -23,13 +25,14 @@ require('please-upgrade-node')(
|
|
|
23
25
|
const cmdline = require('commander')
|
|
24
26
|
const debugLib = require('debug')
|
|
25
27
|
const lintStaged = require('../lib')
|
|
28
|
+
const { CONFIG_STDIN_ERROR } = require('../lib/messages')
|
|
26
29
|
|
|
27
30
|
const debug = debugLib('lint-staged:bin')
|
|
28
31
|
|
|
29
32
|
cmdline
|
|
30
33
|
.version(pkg.version)
|
|
31
34
|
.option('--allow-empty', 'allow empty commits when tasks revert all staged changes', false)
|
|
32
|
-
.option('-c, --config [path]', 'path to configuration file')
|
|
35
|
+
.option('-c, --config [path]', 'path to configuration file, or - to read from stdin')
|
|
33
36
|
.option('-d, --debug', 'print additional debug information', false)
|
|
34
37
|
.option('--no-stash', 'disable the backup stash, and do not revert in case of errors', false)
|
|
35
38
|
.option(
|
|
@@ -86,6 +89,22 @@ const options = {
|
|
|
86
89
|
|
|
87
90
|
debug('Options parsed from command-line:', options)
|
|
88
91
|
|
|
92
|
+
if (options.configPath === '-') {
|
|
93
|
+
delete options.configPath
|
|
94
|
+
try {
|
|
95
|
+
options.config = fs.readFileSync(process.stdin.fd, 'utf8').toString().trim()
|
|
96
|
+
} catch {
|
|
97
|
+
console.error(CONFIG_STDIN_ERROR)
|
|
98
|
+
process.exit(1)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
options.config = JSON.parse(options.config)
|
|
103
|
+
} catch {
|
|
104
|
+
// Let config parsing complain if it's not JSON
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
89
108
|
lintStaged(options)
|
|
90
109
|
.then((passed) => {
|
|
91
110
|
process.exitCode = passed ? 0 : 1
|
package/lib/messages.js
CHANGED
|
@@ -39,6 +39,8 @@ const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored from a g
|
|
|
39
39
|
> git stash apply --index stash@{0}
|
|
40
40
|
`
|
|
41
41
|
|
|
42
|
+
const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'
|
|
43
|
+
|
|
42
44
|
module.exports = {
|
|
43
45
|
NOT_GIT_REPO,
|
|
44
46
|
FAILED_GET_STAGED_FILES,
|
|
@@ -51,4 +53,5 @@ module.exports = {
|
|
|
51
53
|
GIT_ERROR,
|
|
52
54
|
PREVENTED_EMPTY_COMMIT,
|
|
53
55
|
RESTORE_STASH_EXAMPLE,
|
|
56
|
+
CONFIG_STDIN_ERROR,
|
|
54
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.5.2",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/okonet/lint-staged",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"chalk": "^4.1.0",
|
|
36
36
|
"cli-truncate": "^2.1.0",
|
|
37
|
-
"commander": "^6.
|
|
37
|
+
"commander": "^6.2.0",
|
|
38
38
|
"cosmiconfig": "^7.0.0",
|
|
39
|
-
"debug": "^4.
|
|
39
|
+
"debug": "^4.2.0",
|
|
40
40
|
"dedent": "^0.7.0",
|
|
41
41
|
"enquirer": "^2.3.6",
|
|
42
|
-
"execa": "^4.0
|
|
43
|
-
"listr2": "^2.
|
|
42
|
+
"execa": "^4.1.0",
|
|
43
|
+
"listr2": "^3.2.2",
|
|
44
44
|
"log-symbols": "^4.0.0",
|
|
45
45
|
"micromatch": "^4.0.2",
|
|
46
46
|
"normalize-path": "^3.0.0",
|
|
@@ -49,22 +49,22 @@
|
|
|
49
49
|
"stringify-object": "^3.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
54
|
-
"@babel/preset-env": "^7.
|
|
52
|
+
"@babel/core": "^7.12.3",
|
|
53
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
|
|
54
|
+
"@babel/preset-env": "^7.12.1",
|
|
55
55
|
"babel-eslint": "10.1.0",
|
|
56
|
-
"babel-jest": "^26.
|
|
56
|
+
"babel-jest": "^26.6.1",
|
|
57
57
|
"consolemock": "^1.1.0",
|
|
58
|
-
"eslint": "^7.
|
|
59
|
-
"eslint-config-prettier": "^6.
|
|
60
|
-
"eslint-plugin-import": "^2.22.
|
|
58
|
+
"eslint": "^7.12.1",
|
|
59
|
+
"eslint-config-prettier": "^6.15.0",
|
|
60
|
+
"eslint-plugin-import": "^2.22.1",
|
|
61
61
|
"eslint-plugin-node": "^11.1.0",
|
|
62
62
|
"eslint-plugin-prettier": "^3.1.4",
|
|
63
63
|
"fs-extra": "^9.0.1",
|
|
64
|
-
"husky": "^4.
|
|
65
|
-
"jest": "^26.
|
|
64
|
+
"husky": "^4.3.0",
|
|
65
|
+
"jest": "^26.6.1",
|
|
66
66
|
"jest-snapshot-serializer-ansi": "^1.0.0",
|
|
67
|
-
"prettier": "^2.1.
|
|
67
|
+
"prettier": "^2.1.2"
|
|
68
68
|
},
|
|
69
69
|
"config": {
|
|
70
70
|
"commitizen": {
|