lint-staged 7.1.0 → 7.2.0
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 +2 -2
- package/package.json +7 -7
- package/src/index.js +28 -12
package/README.md
CHANGED
|
@@ -71,12 +71,12 @@ $ ./node_modules/.bin/lint-staged --help
|
|
|
71
71
|
Options:
|
|
72
72
|
|
|
73
73
|
-V, --version output the version number
|
|
74
|
-
-c, --config [path]
|
|
74
|
+
-c, --config [path] Configuration file path or package
|
|
75
75
|
-d, --debug Enable debug mode
|
|
76
76
|
-h, --help output usage information
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
* **`--config [path]`**: This can be used to manually specify the `lint-staged` config file location. However, if the specified file cannot be found, it will error out instead of performing the usual search.
|
|
79
|
+
* **`--config [path]`**: This can be used to manually specify the `lint-staged` config file location. However, if the specified file cannot be found, it will error out instead of performing the usual search. You may pass a npm package name for configuration also.
|
|
80
80
|
* **`--debug`**: Enabling the debug mode does the following:
|
|
81
81
|
* `lint-staged` uses the [debug](https://github.com/visionmedia/debug) module internally to log 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*`.
|
|
82
82
|
* Use the [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/okonet/lint-staged",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"precommit": "node index.js",
|
|
22
22
|
"cz": "git-cz",
|
|
23
23
|
"lint:base": "eslint --rule \"prettier/prettier: 2\"",
|
|
24
|
-
"lint": "
|
|
25
|
-
"lint:fix": "
|
|
26
|
-
"pretest": "
|
|
24
|
+
"lint": "npm run lint:base -- .",
|
|
25
|
+
"lint:fix": "npm run lint --fix",
|
|
26
|
+
"pretest": "npm run lint",
|
|
27
27
|
"test": "jest --coverage",
|
|
28
28
|
"test:watch": "jest --watch"
|
|
29
29
|
},
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"app-root-path": "^2.0.1",
|
|
32
32
|
"chalk": "^2.3.1",
|
|
33
33
|
"commander": "^2.14.1",
|
|
34
|
-
"cosmiconfig": "^
|
|
34
|
+
"cosmiconfig": "^5.0.2",
|
|
35
35
|
"debug": "^3.1.0",
|
|
36
36
|
"dedent": "^0.7.0",
|
|
37
37
|
"execa": "^0.9.0",
|
|
38
38
|
"find-parent-dir": "^0.3.0",
|
|
39
39
|
"is-glob": "^4.0.0",
|
|
40
40
|
"is-windows": "^1.0.2",
|
|
41
|
-
"jest-validate": "^
|
|
42
|
-
"listr": "^0.
|
|
41
|
+
"jest-validate": "^23.0.0",
|
|
42
|
+
"listr": "^0.14.1",
|
|
43
43
|
"lodash": "^4.17.5",
|
|
44
44
|
"log-symbols": "^2.2.0",
|
|
45
45
|
"micromatch": "^3.1.8",
|
package/src/index.js
CHANGED
|
@@ -13,25 +13,42 @@ const debug = require('debug')('lint-staged')
|
|
|
13
13
|
// but do this only in TTY mode
|
|
14
14
|
if (process.stdout.isTTY) {
|
|
15
15
|
// istanbul ignore next
|
|
16
|
-
process.env.FORCE_COLOR =
|
|
16
|
+
process.env.FORCE_COLOR = '1'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const errConfigNotFound = new Error('Config could not be found')
|
|
20
20
|
|
|
21
|
+
function resolveConfig(configPath) {
|
|
22
|
+
try {
|
|
23
|
+
return require.resolve(configPath)
|
|
24
|
+
} catch (ignore) {
|
|
25
|
+
return configPath
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function loadConfig(configPath) {
|
|
30
|
+
const explorer = cosmiconfig('lint-staged', {
|
|
31
|
+
searchPlaces: [
|
|
32
|
+
'package.json',
|
|
33
|
+
'.lintstagedrc',
|
|
34
|
+
'.lintstagedrc.json',
|
|
35
|
+
'.lintstagedrc.yaml',
|
|
36
|
+
'.lintstagedrc.yml',
|
|
37
|
+
'.lintstagedrc.js',
|
|
38
|
+
'lint-staged.config.js'
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
|
|
43
|
+
}
|
|
44
|
+
|
|
21
45
|
/**
|
|
22
46
|
* Root lint-staged function that is called from .bin
|
|
23
47
|
*/
|
|
24
48
|
module.exports = function lintStaged(logger = console, configPath, debugMode) {
|
|
25
49
|
debug('Loading config using `cosmiconfig`')
|
|
26
50
|
|
|
27
|
-
|
|
28
|
-
configPath,
|
|
29
|
-
rc: '.lintstagedrc',
|
|
30
|
-
rcExtensions: true
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return explorer
|
|
34
|
-
.load()
|
|
51
|
+
return loadConfig(configPath)
|
|
35
52
|
.then(result => {
|
|
36
53
|
if (result == null) throw errConfigNotFound
|
|
37
54
|
|
|
@@ -53,15 +70,15 @@ module.exports = function lintStaged(logger = console, configPath, debugMode) {
|
|
|
53
70
|
.then(() => {
|
|
54
71
|
debug('linters were executed successfully!')
|
|
55
72
|
// No errors, exiting with 0
|
|
56
|
-
process.exitCode = 0
|
|
57
73
|
})
|
|
58
74
|
.catch(error => {
|
|
59
75
|
// Errors detected, printing and exiting with non-zero
|
|
60
|
-
printErrors(error)
|
|
61
76
|
process.exitCode = 1
|
|
77
|
+
printErrors(error)
|
|
62
78
|
})
|
|
63
79
|
})
|
|
64
80
|
.catch(err => {
|
|
81
|
+
process.exitCode = 1
|
|
65
82
|
if (err === errConfigNotFound) {
|
|
66
83
|
logger.error(`${err.message}.`)
|
|
67
84
|
} else {
|
|
@@ -78,6 +95,5 @@ module.exports = function lintStaged(logger = console, configPath, debugMode) {
|
|
|
78
95
|
Please make sure you have created it correctly.
|
|
79
96
|
See https://github.com/okonet/lint-staged#configuration.
|
|
80
97
|
`)
|
|
81
|
-
process.exitCode = 1
|
|
82
98
|
})
|
|
83
99
|
}
|