lint-staged 13.2.0 → 13.2.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.
Files changed (2) hide show
  1. package/lib/loadConfig.js +15 -2
  2. package/package.json +2 -2
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
- 'package.json',
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) => JSON.parse(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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "13.2.0",
3
+ "version": "13.2.2",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -45,7 +45,7 @@
45
45
  "object-inspect": "^1.12.3",
46
46
  "pidtree": "^0.6.0",
47
47
  "string-argv": "^0.3.1",
48
- "yaml": "^2.2.1"
48
+ "yaml": "^2.2.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@babel/core": "^7.21.0",