lint-staged 13.1.0 → 13.1.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.
package/README.md CHANGED
@@ -42,7 +42,7 @@ This project contains a script that will run arbitrary shell tasks with a list o
42
42
  - [Running Jest Tests Before Each Git Commit - Ben McCormick, 2017](https://benmccormick.org/2017/02/26/running-jest-tests-before-each-git-commit/)
43
43
  - [AgentConf presentation - Andrey Okonetchnikov, 2018](https://www.youtube.com/watch?v=-mhY7e-EsC4)
44
44
  - [SurviveJS interview - Juho Vepsäläinen and Andrey Okonetchnikov, 2018](https://survivejs.com/blog/lint-staged-interview/)
45
- - [Prettier your CSharp with `dotnet-format` and `lint-staged`](https://blog.johnnyreilly.com/2020/12/prettier-your-csharp-with-dotnet-format-and-lint-staged.html)
45
+ - [Prettier your CSharp with `dotnet-format` and `lint-staged`](https://johnnyreilly.com/2020/12/22/prettier-your-csharp-with-dotnet-format-and-lint-staged)
46
46
 
47
47
  > If you've written one, please submit a PR with the link to it!
48
48
 
@@ -127,10 +127,10 @@ Options:
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
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.
130
- - **`--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).
130
+ - **`--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
131
  - **`--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
132
  - **`--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.
133
- - **`--no-stash`**: By default a backup stash will be created before running the tasks, and all task modifications will be reverted in case of an error. This option will disable creating the stash, and instead leave all modifications in the index when aborting the commit.
133
+ - **`--no-stash`**: By default a backup stash will be created before running the tasks, and all task modifications will be reverted in case of an error. This option will disable creating the stash, and instead leave all modifications in the index when aborting the commit. Can be re-enabled with `--stash`
134
134
  - **`--quiet`**: Supress all CLI output, except from tasks.
135
135
  - **`--relative`**: Pass filepaths relative to `process.cwd()` (where `lint-staged` runs) to tasks. Default is `false`.
136
136
  - **`--shell`**: By default linter commands will be parsed for speed and security. This has the side-effect that regular shell scripts might not work as expected. You can skip parsing of commands with this option. To use a specific shell, use a path like `--shell "/bin/bash"`.
@@ -274,7 +274,7 @@ going to execute `eslint` and if it exits with `0` code, it will execute `pretti
274
274
 
275
275
  ## Using JS configuration files
276
276
 
277
- Writing the configuration file in JavaScript is the most powerful way to configure lint-staged (`lint-staged.config.js`, [similar](https://github.com/okonet/lint-staged/README.md#configuration), or passed via `--config`). From the configuration file, you can export either a single function or an object.
277
+ Writing the configuration file in JavaScript is the most powerful way to configure lint-staged (`lint-staged.config.js`, [similar](https://github.com/okonet/lint-staged#configuration), or passed via `--config`). From the configuration file, you can export either a single function or an object.
278
278
 
279
279
  If the `exports` value is a function, it will receive an array of all staged filenames. You can then build your own matchers for the files and return a command string or an array of command strings. These strings are considered complete and should include the filename arguments, if wanted.
280
280
 
@@ -358,7 +358,7 @@ export default {
358
358
  <details>
359
359
  <summary>Click to expand</summary>
360
360
 
361
- It's better to use the [function-based configuration (seen above)](https://github.com/okonet/lint-staged/README.md#example-export-a-function-to-build-your-own-matchers), if your use case is this.
361
+ It's better to use the [function-based configuration (seen above)](https://github.com/okonet/lint-staged#example-export-a-function-to-build-your-own-matchers), if your use case is this.
362
362
 
363
363
  ```js
364
364
  // lint-staged.config.js
@@ -611,6 +611,29 @@ See more on [this blog post](https://medium.com/@tomchentw/imagemin-lint-staged-
611
611
 
612
612
  </details>
613
613
 
614
+ ### Integrate with Next.js
615
+
616
+ <details>
617
+ <summary>Click to expand</summary>
618
+
619
+ ```js
620
+ // .lintstagedrc.js
621
+ // See https://nextjs.org/docs/basic-features/eslint#lint-staged for details
622
+
623
+ const path = require('path')
624
+
625
+ const buildEslintCommand = (filenames) =>
626
+ `next lint --fix --file ${filenames
627
+ .map((f) => path.relative(process.cwd(), f))
628
+ .join(' --file ')}`
629
+
630
+ module.exports = {
631
+ '*.{js,jsx,ts,tsx}': [buildEslintCommand],
632
+ }
633
+ ```
634
+
635
+ </details>
636
+
614
637
  ## Frequently Asked Questions
615
638
 
616
639
  ### The output of commit hook looks weird (no colors, duplicate lines, …)
package/lib/index.js CHANGED
@@ -75,7 +75,8 @@ const lintStaged = async (
75
75
  quiet = false,
76
76
  relative = false,
77
77
  shell = false,
78
- stash = true,
78
+ // Stashing should be disabled by default when the `diff` option is used
79
+ stash = diff === undefined,
79
80
  verbose = false,
80
81
  } = {},
81
82
  logger = console
package/lib/runAll.js CHANGED
@@ -77,7 +77,8 @@ export const runAll = async (
77
77
  quiet = false,
78
78
  relative = false,
79
79
  shell = false,
80
- stash = true,
80
+ // Stashing should be disabled by default when the `diff` option is used
81
+ stash = diff === undefined,
81
82
  verbose = false,
82
83
  },
83
84
  logger = console
@@ -104,9 +105,9 @@ export const runAll = async (
104
105
  .then(() => true)
105
106
  .catch(() => false)
106
107
 
107
- // Lint-staged should create a backup stash only when there's an initial commit,
108
- // and when using the default list of staged files
109
- ctx.shouldBackup = hasInitialCommit && stash && diff === undefined
108
+ // Lint-staged will create a backup stash only when there's an initial commit,
109
+ // and when using the default list of staged files by default
110
+ ctx.shouldBackup = hasInitialCommit && stash
110
111
  if (!ctx.shouldBackup) {
111
112
  logger.warn(skippingBackup(hasInitialCommit, diff))
112
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "13.1.0",
3
+ "version": "13.1.2",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",