lint-staged 13.1.4 → 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/README.md CHANGED
@@ -126,7 +126,8 @@ Options:
126
126
  - **`--cwd [path]`**: By default tasks run in the current working directory. Use the `--cwd some/directory` to override this. The path can be absolute or relative to the current working directory.
127
127
  - **`--debug`**: Run in debug mode. When set, it does the following:
128
128
  - uses [debug](https://github.com/visionmedia/debug) internally to log additional 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*`.
129
- - uses [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`; this causes serial, uncoloured output to the terminal, instead of the default (beautified, dynamic) output.
129
+ - uses [`verbose` renderer](https://listr2.kilic.dev/renderers/verbose-renderer/) for `listr2`; this causes serial, uncoloured output to the terminal, instead of the default (beautified, dynamic) output.
130
+ (the [`verbose` renderer](https://listr2.kilic.dev/renderers/verbose-renderer/) can also be activated by setting the `TERM=dumb` or `NODE_ENV=test` environment variables)
130
131
  - **`--diff`**: By default linters are filtered against all files staged in git, generated from `git diff --staged`. This option allows you to override the `--staged` flag with arbitrary revisions. For example to get a list of changed files between two branches, use `--diff="branch1...branch2"`. You can also read more from about [git diff](https://git-scm.com/docs/git-diff) and [gitrevisions](https://git-scm.com/docs/gitrevisions). This option also implies `--no-stash`.
131
132
  - **`--diff-filter`**: By default only files that are _added_, _copied_, _modified_, or _renamed_ are included. Use this flag to override the default `ACMR` value with something else: _added_ (`A`), _copied_ (`C`), _deleted_ (`D`), _modified_ (`M`), _renamed_ (`R`), _type changed_ (`T`), _unmerged_ (`U`), _unknown_ (`X`), or _pairing broken_ (`B`). See also the `git diff` docs for [--diff-filter](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203).
132
133
  - **`--max-arg-length`**: long commands (a lot of files) are automatically split into multiple chunks when it detects the current shell cannot handle them. Use this flag to override the maximum length of the generated command string.
@@ -4,16 +4,16 @@ import fs from 'node:fs'
4
4
  import path from 'node:path'
5
5
  import { fileURLToPath } from 'node:url'
6
6
 
7
+ import { supportsColor } from 'chalk'
7
8
  import { Option, program } from 'commander'
8
9
  import debug from 'debug'
9
- import supportsColor from 'supports-color'
10
10
 
11
11
  import lintStaged from '../lib/index.js'
12
12
  import { CONFIG_STDIN_ERROR } from '../lib/messages.js'
13
13
 
14
14
  // Force colors for packages that depend on https://www.npmjs.com/package/supports-color
15
- if (supportsColor.stdout) {
16
- process.env.FORCE_COLOR = supportsColor.stdout.level.toString()
15
+ if (supportsColor) {
16
+ process.env.FORCE_COLOR = supportsColor.level.toString()
17
17
  }
18
18
 
19
19
  // Do not terminate main Listr process on SIGINT
@@ -104,16 +104,7 @@ export class GitWorkflow {
104
104
  throw new Error('lint-staged automatic backup is missing!')
105
105
  }
106
106
 
107
- /**
108
- * https://github.com/okonet/lint-staged/issues/1121
109
- * Detect MSYS in login shell mode and escape braces
110
- * to prevent interpolation
111
- */
112
- if (!!process.env.MSYSTEM && !!process.env.LOGINSHELL) {
113
- return `refs/stash@\\{${index}\\}`
114
- }
115
-
116
- return `refs/stash@{${index}}`
107
+ return String(index)
117
108
  }
118
109
 
119
110
  /**
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.1.4",
3
+ "version": "13.2.1",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -45,24 +45,23 @@
45
45
  "object-inspect": "^1.12.3",
46
46
  "pidtree": "^0.6.0",
47
47
  "string-argv": "^0.3.1",
48
- "supports-color": "9.3.1",
49
48
  "yaml": "^2.2.1"
50
49
  },
51
50
  "devDependencies": {
52
51
  "@babel/core": "^7.21.0",
53
52
  "@babel/eslint-parser": "^7.19.1",
54
53
  "@babel/preset-env": "^7.20.2",
55
- "babel-jest": "^29.4.3",
54
+ "babel-jest": "^29.5.0",
56
55
  "babel-plugin-transform-imports": "2.0.0",
57
56
  "consolemock": "^1.1.0",
58
57
  "eslint": "^8.35.0",
59
- "eslint-config-prettier": "^8.6.0",
58
+ "eslint-config-prettier": "^8.7.0",
60
59
  "eslint-plugin-import": "^2.27.5",
61
60
  "eslint-plugin-node": "^11.1.0",
62
61
  "eslint-plugin-prettier": "^4.2.1",
63
62
  "fs-extra": "^11.1.0",
64
63
  "husky": "^8.0.3",
65
- "jest": "^29.4.3",
64
+ "jest": "^29.5.0",
66
65
  "jest-snapshot-serializer-ansi": "^1.0.0",
67
66
  "prettier": "^2.8.4"
68
67
  },