lint-staged 14.0.0 → 15.0.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
@@ -1,4 +1,4 @@
1
- # 🚫💩 lint-staged ![GitHub Actions](https://github.com/okonet/lint-staged/workflows/CI/badge.svg) [![npm version](https://badge.fury.io/js/lint-staged.svg)](https://badge.fury.io/js/lint-staged) [![Codecov](https://codecov.io/gh/okonet/lint-staged/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/lint-staged)
1
+ # 🚫💩 lint-staged [![Test & Release](https://github.com/okonet/lint-staged/actions/workflows/push.yml/badge.svg)](https://github.com/okonet/lint-staged/actions/workflows/push.yml) [![Publish](https://github.com/okonet/lint-staged/actions/workflows/tag.yml/badge.svg)](https://github.com/okonet/lint-staged/actions/workflows/tag.yml) [![npm version](https://badge.fury.io/js/lint-staged.svg)](https://badge.fury.io/js/lint-staged) [![Codecov](https://codecov.io/gh/okonet/lint-staged/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/lint-staged)
2
2
 
3
3
  Run linters against staged git files and don't let :poop: slip into your code base!
4
4
 
@@ -906,4 +906,21 @@ export default {
906
906
 
907
907
  </details>
908
908
 
909
+ #### ESLint >= 8.51.0 && [Flat ESLint config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
910
+
911
+ <details>
912
+ <summary>Click to expand</summary>
913
+
914
+ ESLint v8.51.0 introduced [`--no-warn-ignored` CLI flag](https://eslint.org/docs/latest/use/command-line-interface#--no-warn-ignored). It suppresses the `warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override` warning, so manually ignoring files via `eslint.isPathIgnored` is no longer necessary.
915
+
916
+ ```json
917
+ {
918
+ "*.js": "eslint --max-warnings=0 --no-warn-ignored"
919
+ }
920
+ ```
921
+
922
+ **NOTE:** `--no-warn-ignored` flag is only available when [Flat ESLint config](https://eslint.org/docs/latest/use/configure/configuration-files-new) is used.
923
+
924
+ </details>
925
+
909
926
  </details>
@@ -8,21 +8,21 @@ import debug from 'debug'
8
8
 
9
9
  import lintStaged from '../lib/index.js'
10
10
  import { CONFIG_STDIN_ERROR } from '../lib/messages.js'
11
+ import { readStdin } from '../lib/readStdin.js'
11
12
 
12
13
  // Force colors for packages that depend on https://www.npmjs.com/package/supports-color
13
14
  if (supportsColor) {
14
15
  process.env.FORCE_COLOR = supportsColor.level.toString()
15
16
  }
16
17
 
18
+ const debugLog = debug('lint-staged:bin')
19
+
17
20
  // Do not terminate main Listr process on SIGINT
18
21
  process.on('SIGINT', () => {})
19
22
 
20
23
  const packageJson = JSON.parse(await fs.readFile(new URL('../package.json', import.meta.url)))
21
24
  const version = packageJson.version
22
25
 
23
- const debugLog = debug('lint-staged:bin')
24
- debugLog('Running `lint-staged@%s`', version)
25
-
26
26
  const cli = program.version(version)
27
27
 
28
28
  cli.option('--allow-empty', 'allow empty commits when tasks revert all staged changes', false)
@@ -89,6 +89,8 @@ if (cliOptions.debug) {
89
89
  debug.enable('lint-staged*')
90
90
  }
91
91
 
92
+ debugLog('Running `lint-staged@%s` on Node.js %s (%s)', version, process.version, process.platform)
93
+
92
94
  const options = {
93
95
  allowEmpty: !!cliOptions.allowEmpty,
94
96
  concurrent: JSON.parse(cliOptions.concurrent),
@@ -110,17 +112,13 @@ debugLog('Options parsed from command-line:', options)
110
112
  if (options.configPath === '-') {
111
113
  delete options.configPath
112
114
  try {
113
- options.config = await fs.readFile(process.stdin.fd, 'utf8').toString().trim()
114
- } catch {
115
+ debugLog('Reading config from stdin')
116
+ options.config = JSON.parse(await readStdin())
117
+ } catch (error) {
118
+ debugLog(CONFIG_STDIN_ERROR, error)
115
119
  console.error(CONFIG_STDIN_ERROR)
116
120
  process.exit(1)
117
121
  }
118
-
119
- try {
120
- options.config = JSON.parse(options.config)
121
- } catch {
122
- // Let config parsing complain if it's not JSON
123
- }
124
122
  }
125
123
 
126
124
  try {
package/lib/messages.js CHANGED
@@ -71,4 +71,4 @@ export const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored f
71
71
  > git stash apply --index stash@{0}
72
72
  `
73
73
 
74
- export const CONFIG_STDIN_ERROR = 'Error: Could not read config from stdin.'
74
+ export const CONFIG_STDIN_ERROR = chalk.redBright(`${error} Failed to read config from stdin.`)
@@ -0,0 +1,19 @@
1
+ import { createInterface } from 'node:readline'
2
+
3
+ /**
4
+ * Returns a promise resolving to the first line written to stdin after invoking.
5
+ * @warn will never resolve if called after writing to stdin
6
+ *
7
+ * @returns {Promise<string>}
8
+ */
9
+ export const readStdin = () => {
10
+ const readline = createInterface({ input: process.stdin })
11
+
12
+ return new Promise((resolve) => {
13
+ readline.prompt()
14
+ readline.on('line', (line) => {
15
+ readline.close()
16
+ resolve(line)
17
+ })
18
+ })
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "14.0.0",
3
+ "version": "15.0.0",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -14,7 +14,7 @@
14
14
  "url": "https://opencollective.com/lint-staged"
15
15
  },
16
16
  "engines": {
17
- "node": "^16.14.0 || >=18.0.0"
17
+ "node": ">=18.12.0"
18
18
  },
19
19
  "type": "module",
20
20
  "bin": "./bin/lint-staged.js",
@@ -30,36 +30,44 @@
30
30
  "scripts": {
31
31
  "lint": "eslint .",
32
32
  "test": "jest --coverage",
33
- "test:watch": "jest --watch"
33
+ "test:watch": "jest --watch",
34
+ "version": "npx changeset version",
35
+ "postversion": "npm i --package-lock-only && git commit -am \"chore(changeset): release\"",
36
+ "publish": "npx changeset tag"
34
37
  },
35
38
  "dependencies": {
36
39
  "chalk": "5.3.0",
37
- "commander": "11.0.0",
40
+ "commander": "11.1.0",
38
41
  "debug": "4.3.4",
39
- "execa": "7.2.0",
42
+ "execa": "8.0.1",
40
43
  "lilconfig": "2.1.0",
41
- "listr2": "6.6.1",
44
+ "listr2": "7.0.1",
42
45
  "micromatch": "4.0.5",
43
46
  "pidtree": "0.6.0",
44
47
  "string-argv": "0.3.2",
45
- "yaml": "2.3.1"
48
+ "yaml": "2.3.2"
46
49
  },
47
50
  "devDependencies": {
48
- "@babel/core": "7.22.10",
49
- "@babel/eslint-parser": "7.22.10",
50
- "@babel/preset-env": "7.22.10",
51
- "babel-jest": "29.6.2",
51
+ "@babel/core": "7.23.2",
52
+ "@babel/eslint-parser": "7.22.15",
53
+ "@babel/preset-env": "7.23.2",
54
+ "@changesets/changelog-github": "0.4.8",
55
+ "@changesets/cli": "2.26.2",
56
+ "@commitlint/cli": "17.7.2",
57
+ "@commitlint/config-conventional": "17.7.0",
58
+ "babel-jest": "29.7.0",
52
59
  "babel-plugin-transform-imports": "2.0.0",
53
60
  "consolemock": "1.1.0",
54
- "eslint": "8.46.0",
61
+ "eslint": "8.51.0",
55
62
  "eslint-config-prettier": "9.0.0",
56
- "eslint-plugin-import": "2.28.0",
63
+ "eslint-plugin-import": "2.28.1",
57
64
  "eslint-plugin-node": "11.1.0",
58
- "eslint-plugin-prettier": "5.0.0",
65
+ "eslint-plugin-prettier": "5.0.1",
59
66
  "husky": "8.0.3",
60
- "jest": "29.6.2",
67
+ "jest": "29.7.0",
61
68
  "jest-snapshot-serializer-ansi": "2.1.0",
62
- "prettier": "3.0.1"
69
+ "mock-stdin": "1.0.0",
70
+ "prettier": "3.0.3"
63
71
  },
64
72
  "keywords": [
65
73
  "lint",