lint-staged 15.0.2 → 15.1.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 CHANGED
@@ -72,6 +72,10 @@ See [Releases](https://github.com/okonet/lint-staged/releases).
72
72
 
73
73
  ### Migration
74
74
 
75
+ #### v15
76
+
77
+ - Since `v15.0.0` _lint-staged_ no longer supports Node.js 16. Please upgrade your Node.js version to at least `18.12.0`.
78
+
75
79
  #### v14
76
80
 
77
81
  - Since `v14.0.0` _lint-staged_ no longer supports Node.js 14. Please upgrade your Node.js version to at least `16.14.0`.
@@ -79,6 +83,7 @@ See [Releases](https://github.com/okonet/lint-staged/releases).
79
83
  #### v13
80
84
 
81
85
  - Since `v13.0.0` _lint-staged_ no longer supports Node.js 12. Please upgrade your Node.js version to at least `14.13.1`, or `16.0.0` onward.
86
+ - Version `v13.3.0` was incorrectly released including code of version `v14.0.0`. This means the breaking changes of `v14` are also included in `v13.3.0`, the last `v13` version released
82
87
 
83
88
  #### v12
84
89
 
@@ -145,7 +150,7 @@ Options:
145
150
 
146
151
  _Lint-staged_ can be configured in many ways:
147
152
 
148
- - `lint-staged` object in your `package.json`
153
+ - `lint-staged` object in your `package.json`, or [`package.yaml`](https://github.com/pnpm/pnpm/pull/1799)
149
154
  - `.lintstagedrc` file in JSON or YML format, or you can be explicit with the file extension:
150
155
  - `.lintstagedrc.json`
151
156
  - `.lintstagedrc.yaml`
package/lib/loadConfig.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /** @typedef {import('./index').Logger} Logger */
2
2
 
3
+ import path from 'node:path'
4
+
3
5
  import debug from 'debug'
4
6
  import { lilconfig } from 'lilconfig'
5
7
  import YAML from 'yaml'
@@ -9,14 +11,19 @@ import { resolveConfig } from './resolveConfig.js'
9
11
 
10
12
  const debugLog = debug('lint-staged:loadConfig')
11
13
 
12
- const PACKAGE_JSON = 'package.json'
14
+ const CONFIG_NAME = 'lint-staged'
15
+
16
+ const PACKAGE_JSON_FILE = 'package.json'
17
+
18
+ const PACKAGE_YAML_FILES = ['package.yaml', 'package.yml']
13
19
 
14
20
  /**
15
21
  * The list of files `lint-staged` will read configuration
16
22
  * from, in the declared order.
17
23
  */
18
24
  export const searchPlaces = [
19
- PACKAGE_JSON,
25
+ PACKAGE_JSON_FILE,
26
+ ...PACKAGE_YAML_FILES,
20
27
  '.lintstagedrc',
21
28
  '.lintstagedrc.json',
22
29
  '.lintstagedrc.yaml',
@@ -29,12 +36,12 @@ export const searchPlaces = [
29
36
  'lint-staged.config.cjs',
30
37
  ]
31
38
 
32
- const jsonParse = (path, content) => {
39
+ const jsonParse = (filePath, content) => {
33
40
  try {
34
41
  return JSON.parse(content)
35
42
  } catch (error) {
36
- if (path.endsWith(PACKAGE_JSON)) {
37
- debugLog('Ignoring invalid package file `%s` with content:\n%s', path, content)
43
+ if (path.basename(filePath) === PACKAGE_JSON_FILE) {
44
+ debugLog('Ignoring invalid package file `%s` with content:\n%s', filePath, content)
38
45
  return undefined
39
46
  }
40
47
 
@@ -42,7 +49,20 @@ const jsonParse = (path, content) => {
42
49
  }
43
50
  }
44
51
 
45
- const yamlParse = (path, content) => YAML.parse(content)
52
+ const yamlParse = (filePath, content) => {
53
+ const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filePath))
54
+ try {
55
+ const yaml = YAML.parse(content)
56
+ return isPackageFile ? yaml[CONFIG_NAME] : yaml
57
+ } catch (error) {
58
+ if (isPackageFile) {
59
+ debugLog('Ignoring invalid package file `%s` with content:\n%s', filePath, content)
60
+ return undefined
61
+ }
62
+
63
+ throw error
64
+ }
65
+ }
46
66
 
47
67
  /**
48
68
  * `lilconfig` doesn't support yaml files by default,
@@ -60,7 +80,7 @@ const loaders = {
60
80
  noExt: yamlParse,
61
81
  }
62
82
 
63
- const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
83
+ const explorer = lilconfig(CONFIG_NAME, { searchPlaces, loaders })
64
84
 
65
85
  /**
66
86
  * @param {object} options
package/lib/runAll.js CHANGED
@@ -108,7 +108,7 @@ export const runAll = async (
108
108
  // Lint-staged will create a backup stash only when there's an initial commit,
109
109
  // and when using the default list of staged files by default
110
110
  ctx.shouldBackup = hasInitialCommit && stash
111
- if (!ctx.shouldBackup) {
111
+ if (!ctx.shouldBackup && !quiet) {
112
112
  logger.warn(skippingBackup(hasInitialCommit, diff))
113
113
  }
114
114
 
@@ -242,7 +242,7 @@ export const runAll = async (
242
242
  }
243
243
  }
244
244
 
245
- if (hasDeprecatedGitAdd) {
245
+ if (hasDeprecatedGitAdd && !quiet) {
246
246
  logger.warn(DEPRECATED_GIT_ADD)
247
247
  }
248
248
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "15.0.2",
3
+ "version": "15.1.0",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -45,22 +45,22 @@
45
45
  "micromatch": "4.0.5",
46
46
  "pidtree": "0.6.0",
47
47
  "string-argv": "0.3.2",
48
- "yaml": "2.3.3"
48
+ "yaml": "2.3.4"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "7.23.2",
52
- "@babel/eslint-parser": "7.22.15",
53
- "@babel/preset-env": "7.23.2",
51
+ "@babel/core": "7.23.3",
52
+ "@babel/eslint-parser": "7.23.3",
53
+ "@babel/preset-env": "7.23.3",
54
54
  "@changesets/changelog-github": "0.4.8",
55
55
  "@changesets/cli": "2.26.2",
56
- "@commitlint/cli": "17.8.0",
57
- "@commitlint/config-conventional": "17.8.0",
56
+ "@commitlint/cli": "18.4.0",
57
+ "@commitlint/config-conventional": "18.4.0",
58
58
  "babel-jest": "29.7.0",
59
59
  "babel-plugin-transform-imports": "2.0.0",
60
60
  "consolemock": "1.1.0",
61
- "eslint": "8.51.0",
61
+ "eslint": "8.53.0",
62
62
  "eslint-config-prettier": "9.0.0",
63
- "eslint-plugin-import": "2.28.1",
63
+ "eslint-plugin-import": "2.29.0",
64
64
  "eslint-plugin-node": "11.1.0",
65
65
  "eslint-plugin-prettier": "5.0.1",
66
66
  "husky": "8.0.3",