lint-staged 13.2.0 → 13.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/lib/loadConfig.js +15 -2
- package/package.json +1 -1
package/lib/loadConfig.js
CHANGED
|
@@ -9,12 +9,14 @@ import { resolveConfig } from './resolveConfig.js'
|
|
|
9
9
|
|
|
10
10
|
const debugLog = debug('lint-staged:loadConfig')
|
|
11
11
|
|
|
12
|
+
const PACKAGE_JSON = 'package.json'
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* The list of files `lint-staged` will read configuration
|
|
14
16
|
* from, in the declared order.
|
|
15
17
|
*/
|
|
16
18
|
export const searchPlaces = [
|
|
17
|
-
|
|
19
|
+
PACKAGE_JSON,
|
|
18
20
|
'.lintstagedrc',
|
|
19
21
|
'.lintstagedrc.json',
|
|
20
22
|
'.lintstagedrc.yaml',
|
|
@@ -27,7 +29,18 @@ export const searchPlaces = [
|
|
|
27
29
|
'lint-staged.config.cjs',
|
|
28
30
|
]
|
|
29
31
|
|
|
30
|
-
const jsonParse = (path, content) =>
|
|
32
|
+
const jsonParse = (path, content) => {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(content)
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (path.endsWith(PACKAGE_JSON)) {
|
|
37
|
+
debugLog('Ignoring invalid package file `%s` with content:\n%s', path, content)
|
|
38
|
+
return undefined
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw error
|
|
42
|
+
}
|
|
43
|
+
}
|
|
31
44
|
|
|
32
45
|
const yamlParse = (path, content) => YAML.parse(content)
|
|
33
46
|
|