lint-staged 11.1.2 → 11.2.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
@@ -369,7 +369,7 @@ All examples assume you've already set up lint-staged in the `package.json` file
369
369
  In `.husky/pre-commit`
370
370
 
371
371
  ```shell
372
- #!/bin/sh
372
+ #!/usr/bin/env sh
373
373
  . "$(dirname "$0")/_/husky.sh"
374
374
 
375
375
  npx lint-staged
@@ -671,8 +671,6 @@ Example repo: [sudo-suhas/lint-staged-django-react-demo](https://github.com/sudo
671
671
 
672
672
  ESLint throws out `warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override` warnings that breaks the linting process ( if you used `--max-warnings=0` which is recommended ).
673
673
 
674
- </details>
675
-
676
674
  #### ESLint < 7
677
675
 
678
676
  <details>
@@ -702,21 +700,19 @@ module.exports = {
702
700
 
703
701
  In versions of ESLint > 7, [isPathIgnored](https://eslint.org/docs/developer-guide/nodejs-api#-eslintispathignoredfilepath) is an async function and now returns a promise. The code below can be used to reinstate the above functionality.
704
702
 
705
- This particular code uses a tiny package, [node-filter-async](https://www.npmjs.com/package/node-filter-async), to filter the files array with an async function. If you prefer to not have an extra dependency, it is quite simple to write a similar function.
706
-
707
703
  Since [10.5.3](https://github.com/okonet/lint-staged/releases), any errors due to a bad ESLint config will come through to the console.
708
704
 
709
705
  ```js
710
706
  const { ESLint } = require('eslint')
711
- const filterAsync = require('node-filter-async').default
712
-
713
- const eslintCli = new ESLint()
714
707
 
715
708
  const removeIgnoredFiles = async (files) => {
716
- const filteredFiles = await filterAsync(files, async (file) => {
717
- const isIgnored = await eslintCli.isPathIgnored(file)
718
- return !isIgnored
719
- })
709
+ const eslint = new ESLint()
710
+ const isIgnored = await Promise.all(
711
+ files.map((file) => {
712
+ return eslint.isPathIgnored(file)
713
+ })
714
+ )
715
+ const filteredFiles = files.filter((_, i) => !isIgnored[i])
720
716
  return filteredFiles.join(' ')
721
717
  }
722
718
 
@@ -729,3 +725,5 @@ module.exports = {
729
725
  ```
730
726
 
731
727
  </details>
728
+
729
+ </details>
@@ -5,9 +5,9 @@
5
5
  const fs = require('fs')
6
6
 
7
7
  // Force colors for packages that depend on https://www.npmjs.com/package/supports-color
8
- const { supportsColor } = require('chalk')
9
- if (supportsColor && supportsColor.level) {
10
- process.env.FORCE_COLOR = supportsColor.level.toString()
8
+ const supportsColor = require('supports-color')
9
+ if (supportsColor.stdout) {
10
+ process.env.FORCE_COLOR = supportsColor.stdout.level.toString()
11
11
  }
12
12
 
13
13
  // Do not terminate main Listr process on SIGINT
package/lib/figures.js ADDED
@@ -0,0 +1,10 @@
1
+ const { blue, redBright, yellow } = require('colorette')
2
+ const { figures } = require('listr2')
3
+
4
+ const { arrowRight, cross, warning } = figures
5
+
6
+ module.exports = {
7
+ info: blue(arrowRight),
8
+ error: redBright(cross),
9
+ warning: yellow(warning),
10
+ }
package/lib/messages.js CHANGED
@@ -1,26 +1,28 @@
1
1
  'use strict'
2
2
 
3
- const chalk = require('chalk')
4
- const { error, info, warning } = require('log-symbols')
3
+ const { redBright, bold, yellow } = require('colorette')
5
4
  const format = require('stringify-object')
6
5
 
6
+ const { error, info, warning } = require('./figures')
7
+
7
8
  const configurationError = (opt, helpMsg, value) =>
8
- `${chalk.redBright(`${error} Validation Error:`)}
9
+ `${redBright(`${error} Validation Error:`)}
9
10
 
10
- Invalid value for '${chalk.bold(opt)}': ${chalk.bold(
11
+ Invalid value for '${bold(opt)}': ${bold(
11
12
  format(value, { inlineCharacterLimit: Number.POSITIVE_INFINITY })
12
13
  )}
13
14
 
14
15
  ${helpMsg}`
15
16
 
16
- const NOT_GIT_REPO = chalk.redBright(`${error} Current directory is not a git directory!`)
17
+ const NOT_GIT_REPO = redBright(`${error} Current directory is not a git directory!`)
17
18
 
18
- const FAILED_GET_STAGED_FILES = chalk.redBright(`${error} Failed to get staged files!`)
19
+ const FAILED_GET_STAGED_FILES = redBright(`${error} Failed to get staged files!`)
19
20
 
20
- const incorrectBraces = (before, after) => `${warning} ${chalk.yellow(
21
- `Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\``
22
- )}
21
+ const incorrectBraces = (before, after) =>
22
+ yellow(
23
+ `${warning} Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\`
23
24
  `
25
+ )
24
26
 
25
27
  const NO_STAGED_FILES = `${info} No staged files found.`
26
28
 
@@ -28,30 +30,30 @@ const NO_TASKS = `${info} No staged files match any configured task.`
28
30
 
29
31
  const skippingBackup = (hasInitialCommit) => {
30
32
  const reason = hasInitialCommit ? '`--no-stash` was used' : 'there’s no initial commit yet'
31
- return `${warning} ${chalk.yellow(`Skipping backup because ${reason}.\n`)}`
33
+ return yellow(`${warning} Skipping backup because ${reason}.\n`)
32
34
  }
33
35
 
34
- const DEPRECATED_GIT_ADD = `${warning} ${chalk.yellow(
35
- `Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.`
36
- )}
36
+ const DEPRECATED_GIT_ADD = yellow(
37
+ `${warning} Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.
37
38
  `
39
+ )
38
40
 
39
41
  const TASK_ERROR = 'Skipped because of errors from tasks.'
40
42
 
41
43
  const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
42
44
 
43
- const GIT_ERROR = `\n ${error} ${chalk.red(`lint-staged failed due to a git error.`)}`
45
+ const GIT_ERROR = `\n ${redBright(`${error} lint-staged failed due to a git error.`)}`
44
46
 
45
- const invalidOption = (name, value, message) => `${chalk.redBright(`${error} Validation Error:`)}
47
+ const invalidOption = (name, value, message) => `${redBright(`${error} Validation Error:`)}
46
48
 
47
- Invalid value for option '${chalk.bold(name)}': ${chalk.bold(value)}
49
+ Invalid value for option '${bold(name)}': ${bold(value)}
48
50
 
49
51
  ${message}
50
52
 
51
53
  See https://github.com/okonet/lint-staged#command-line-flags`
52
54
 
53
55
  const PREVENTED_EMPTY_COMMIT = `
54
- ${warning} ${chalk.yellow(`lint-staged prevented an empty git commit.
56
+ ${yellow(`${warning} lint-staged prevented an empty git commit.
55
57
  Use the --allow-empty option to continue, or check your task configuration`)}
56
58
  `
57
59
 
@@ -1,11 +1,11 @@
1
1
  'use strict'
2
2
 
3
- const { redBright, dim } = require('chalk')
3
+ const { redBright, dim } = require('colorette')
4
4
  const execa = require('execa')
5
5
  const debug = require('debug')('lint-staged:task')
6
6
  const { parseArgsStringToArgv } = require('string-argv')
7
- const { error, info } = require('log-symbols')
8
7
 
8
+ const { error, info } = require('./figures')
9
9
  const { getInitialState } = require('./state')
10
10
  const { TaskError } = require('./symbols')
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "11.1.2",
3
+ "version": "11.2.0",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -27,38 +27,38 @@
27
27
  "test:watch": "jest --watch"
28
28
  },
29
29
  "dependencies": {
30
- "chalk": "^4.1.1",
31
- "cli-truncate": "^2.1.0",
32
- "commander": "^7.2.0",
33
- "cosmiconfig": "^7.0.0",
34
- "debug": "^4.3.1",
30
+ "cli-truncate": "2.1.0",
31
+ "colorette": "^1.4.0",
32
+ "commander": "^8.2.0",
33
+ "cosmiconfig": "^7.0.1",
34
+ "debug": "^4.3.2",
35
35
  "enquirer": "^2.3.6",
36
- "execa": "^5.0.0",
37
- "listr2": "^3.8.2",
38
- "log-symbols": "^4.1.0",
36
+ "execa": "^5.1.1",
37
+ "listr2": "^3.12.2",
39
38
  "micromatch": "^4.0.4",
40
39
  "normalize-path": "^3.0.0",
41
40
  "please-upgrade-node": "^3.2.0",
42
41
  "string-argv": "0.3.1",
43
- "stringify-object": "^3.3.0"
42
+ "stringify-object": "3.3.0",
43
+ "supports-color": "8.1.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@babel/core": "^7.14.0",
47
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
48
- "@babel/preset-env": "^7.14.1",
49
- "babel-eslint": "10.1.0",
50
- "babel-jest": "^26.6.3",
46
+ "@babel/core": "^7.15.5",
47
+ "@babel/eslint-parser": "^7.15.7",
48
+ "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
49
+ "@babel/preset-env": "^7.15.6",
50
+ "babel-jest": "^27.2.4",
51
51
  "consolemock": "^1.1.0",
52
- "eslint": "^7.25.0",
52
+ "eslint": "^7.32.0",
53
53
  "eslint-config-prettier": "^8.3.0",
54
- "eslint-plugin-import": "^2.22.1",
54
+ "eslint-plugin-import": "^2.24.2",
55
55
  "eslint-plugin-node": "^11.1.0",
56
- "eslint-plugin-prettier": "^3.4.0",
56
+ "eslint-plugin-prettier": "^4.0.0",
57
57
  "fs-extra": "^10.0.0",
58
- "husky": "^6.0.0",
59
- "jest": "^26.6.3",
58
+ "husky": "^7.0.2",
59
+ "jest": "^27.2.4",
60
60
  "jest-snapshot-serializer-ansi": "^1.0.0",
61
- "prettier": "^2.2.1"
61
+ "prettier": "^2.4.1"
62
62
  },
63
63
  "config": {
64
64
  "commitizen": {