lint-staged 15.2.4 → 15.2.5
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/loadConfig.js +3 -2
- package/lib/messages.js +12 -0
- package/lib/validateConfig.js +19 -14
- package/package.json +11 -11
package/lib/loadConfig.js
CHANGED
|
@@ -7,6 +7,7 @@ import debug from 'debug'
|
|
|
7
7
|
import YAML from 'yaml'
|
|
8
8
|
|
|
9
9
|
import { dynamicImport } from './dynamicImport.js'
|
|
10
|
+
import { failedToLoadConfig } from './messages.js'
|
|
10
11
|
import { resolveConfig } from './resolveConfig.js'
|
|
11
12
|
import {
|
|
12
13
|
CONFIG_FILE_NAMES,
|
|
@@ -117,8 +118,8 @@ export const loadConfig = async ({ configPath, cwd }, logger) => {
|
|
|
117
118
|
|
|
118
119
|
return { config, filepath }
|
|
119
120
|
} catch (error) {
|
|
120
|
-
debugLog('Failed to load configuration
|
|
121
|
-
logger.error(
|
|
121
|
+
debugLog('Failed to load configuration from `%s` with error:\n', configPath, error)
|
|
122
|
+
logger.error(failedToLoadConfig(configPath))
|
|
122
123
|
return {}
|
|
123
124
|
}
|
|
124
125
|
}
|
package/lib/messages.js
CHANGED
|
@@ -85,3 +85,15 @@ export const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored f
|
|
|
85
85
|
`
|
|
86
86
|
|
|
87
87
|
export const CONFIG_STDIN_ERROR = chalk.redBright(`${error} Failed to read config from stdin.`)
|
|
88
|
+
|
|
89
|
+
export const failedToLoadConfig = (filepath) =>
|
|
90
|
+
chalk.redBright(`${error} Failed to read config from file "${filepath}".`)
|
|
91
|
+
|
|
92
|
+
export const failedToParseConfig = (
|
|
93
|
+
filepath,
|
|
94
|
+
error
|
|
95
|
+
) => `${chalk.redBright(`${error} Failed to parse config from file "${filepath}".`)}
|
|
96
|
+
|
|
97
|
+
${error}
|
|
98
|
+
|
|
99
|
+
See https://github.com/okonet/lint-staged#configuration.`
|
package/lib/validateConfig.js
CHANGED
|
@@ -4,7 +4,7 @@ import { inspect } from 'node:util'
|
|
|
4
4
|
|
|
5
5
|
import debug from 'debug'
|
|
6
6
|
|
|
7
|
-
import { configurationError } from './messages.js'
|
|
7
|
+
import { configurationError, failedToParseConfig } from './messages.js'
|
|
8
8
|
import { ConfigEmptyError, ConfigFormatError } from './symbols.js'
|
|
9
9
|
import { validateBraces } from './validateBraces.js'
|
|
10
10
|
|
|
@@ -23,14 +23,7 @@ const TEST_DEPRECATED_KEYS = new Map([
|
|
|
23
23
|
['relative', (key) => typeof key === 'boolean'],
|
|
24
24
|
])
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
* Runs config validation. Throws error if the config is not valid.
|
|
28
|
-
* @param {Object} config
|
|
29
|
-
* @param {string} configPath
|
|
30
|
-
* @param {Logger} logger
|
|
31
|
-
* @returns {Object} config
|
|
32
|
-
*/
|
|
33
|
-
export const validateConfig = (config, configPath, logger) => {
|
|
26
|
+
export const validateConfigLogic = (config, configPath, logger) => {
|
|
34
27
|
debugLog('Validating config from `%s`...', configPath)
|
|
35
28
|
|
|
36
29
|
if (!config || (typeof config !== 'object' && typeof config !== 'function')) {
|
|
@@ -100,11 +93,7 @@ export const validateConfig = (config, configPath, logger) => {
|
|
|
100
93
|
if (errors.length) {
|
|
101
94
|
const message = errors.join('\n\n')
|
|
102
95
|
|
|
103
|
-
logger.error(
|
|
104
|
-
|
|
105
|
-
${message}
|
|
106
|
-
|
|
107
|
-
See https://github.com/okonet/lint-staged#configuration.`)
|
|
96
|
+
logger.error(failedToParseConfig(configPath, message))
|
|
108
97
|
|
|
109
98
|
throw new Error(message)
|
|
110
99
|
}
|
|
@@ -114,3 +103,19 @@ See https://github.com/okonet/lint-staged#configuration.`)
|
|
|
114
103
|
|
|
115
104
|
return validatedConfig
|
|
116
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Runs config validation. Throws error if the config is not valid.
|
|
109
|
+
* @param {Object} config
|
|
110
|
+
* @param {string} configPath
|
|
111
|
+
* @param {Logger} logger
|
|
112
|
+
* @returns {Object} config
|
|
113
|
+
*/
|
|
114
|
+
export const validateConfig = (config, configPath, logger) => {
|
|
115
|
+
try {
|
|
116
|
+
return validateConfigLogic(config, configPath, logger)
|
|
117
|
+
} catch (error) {
|
|
118
|
+
logger.error(failedToParseConfig(configPath, error))
|
|
119
|
+
throw error
|
|
120
|
+
}
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.5",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/okonet/lint-staged",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"tag": "npx changeset tag"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"chalk": "5.3.0",
|
|
40
|
-
"commander": "12.1.0",
|
|
41
|
-
"debug": "4.3.4",
|
|
42
|
-
"execa": "8.0.1",
|
|
43
|
-
"lilconfig": "3.1.1",
|
|
44
|
-
"listr2": "8.2.1",
|
|
45
|
-
"micromatch": "4.0.
|
|
46
|
-
"pidtree": "0.6.0",
|
|
47
|
-
"string-argv": "0.3.2",
|
|
48
|
-
"yaml": "2.4.2"
|
|
39
|
+
"chalk": "~5.3.0",
|
|
40
|
+
"commander": "~12.1.0",
|
|
41
|
+
"debug": "~4.3.4",
|
|
42
|
+
"execa": "~8.0.1",
|
|
43
|
+
"lilconfig": "~3.1.1",
|
|
44
|
+
"listr2": "~8.2.1",
|
|
45
|
+
"micromatch": "~4.0.7",
|
|
46
|
+
"pidtree": "~0.6.0",
|
|
47
|
+
"string-argv": "~0.3.2",
|
|
48
|
+
"yaml": "~2.4.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@changesets/changelog-github": "0.5.0",
|