Releases: lint-staged/lint-staged
v16.1.2
Patch Changes
-
#1570
a7c0c88
Thanks @ItsNickBarry! - When using--diff-filter
with theD
option to include deleted staged files, lint-staged no longer tries to stage the deleted files, unless they're no longer deleted. Previously this caused an error fromgit add
likefatal: pathspec 'deleted-file' did not match any files
. -
38f942e
Thanks @iiroj! - Removed an extraneous log entry that printedshouldHidePArtiallyStagedFiles
to console output.
v16.1.1
Patch Changes
-
#1565
3686977
Thanks @iiroj! - Lint-staged now explicitly warns about potential data loss when using--no-stash
. -
#1571
02299a9
Thanks @iiroj! - Function tasks (introduced in v16.0.0) only receive the staged files matching the configured glob, instead of all staged files. -
#1563
bc61c74
Thanks @iiroj! - This version fixes incorrect behavior where unstaged changes were committed when using the--no-stash
option. This happened because--no-stash
implied--no-hide-partially-staged
, meaning unstaged changes to files which also had other staged changes were added to the commit by lint-staged; this is no longer the case.The previous (incorrect) behavior can still be achieved by using both options
--no-stash --no-hide-partially-staged
at the same time.
v16.1.0
Minor Changes
-
#1536
e729daa
Thanks @iiroj! - A new flag--no-revert
has been introduced for when task modifications should be applied to the index before aborting the commit in case of errors. By default, lint-staged will clear all task modifications and revert to the original state. -
#1550
b27fa3f
Thanks @iiroj! - Lint-staged now ignores symlinks and leaves them out from the list of staged files.
Patch Changes
- #1558
c37dc38
Thanks @iiroj! - The minimum required Node.js version is lowered to20.17
following [email protected].
v16.0.0
Major Changes
-
#1546
158d15c
Thanks @iiroj! - Processes are spawned using nano-spawn instead of execa. If you are using Node.js scripts as tasks, you might need to explicitly run them withnode
, especially when using Windows:{ "*.js": "node my-js-linter.js" }
-
#1546
158d15c
Thanks @iiroj! - The--shell
flag has been removed and lint-staged no longer supports evaluating commands directly via a shell. To migrate existing commands, you can create a shell script and invoke it instead. Lint-staged will pass matched staged files as a list of arguments, accessible via"$@"
:# my-script.sh #!/bin/bash echo "Staged files: $@"
and
{ "*.js": "my-script.sh" }
If you were using the shell option to avoid passing filenames to tasks, for example
bash -c 'tsc --noEmit'
, use the function syntax instead:export default { '*.ts': () => 'tsc --noEmit' }
-
#1546
158d15c
Thanks @iiroj! - Validation for deprecated advanced configuration has been removed. The advanced configuration was removed in lint-staged version 9 and until now validation has failed if advanced configuration options were detected. Going forward the entire configuration will be treated with the same logic and if these advanced options are still present, they might be treated as valid globs for staged files instead. -
#1546
158d15c
Thanks @iiroj! - The lowest supported Node.js version is20.18
. Please upgrade your Node.js version.
Minor Changes
-
#1401
27110ef
Thanks @RohitLuthra19! - Added support for directly running functions on staged files. To configure a function task, use an object with a title and the task itself:export default { '*.js': { title: 'My task', task: async (files) => { console.log('Staged JS files:', files) }, }, }
Lint-staged will run your function task with the staged files matching the configured glob as its argument, and show the custom title in its console output.
v15.5.2
Patch Changes
- #1544
5561321
Thanks @YimingIsCOLD! - Correctly handle colon (:
) characters in staged filenames.
v15.5.1
v15.5.0
Minor Changes
-
#1526
630af5f
Thanks @iiroj! - Lint-staged no longer resets to the original state when preventing an empty git commit. This happens when your configured tasks reset all the staged changes, typically when trying to commit formatting changes which conflict with your linter setup like ESLint or Prettier.Example with Prettier
By default Prettier prefers double quotes.
Previously
- Stage
file.js
with only double quotes"
changed to'
- Run
git commit -am "I don't like double quotes"
- Lint-staged runs
prettier --write file.js
, converting all the'
back to"
- Because there are now no changes, lint-staged fails, cancels the commit, and resets back to the original state
- Commit was not done, original state is restored and single quotes
'
are staged
Now
- Stage
file.js
with only double-quotes"
changed to'
- Run
git commit -am "I don't like double quotes"
- Lint-staged runs
prettier --write file.js
, converting all the'
back to"
- Because there are now no changes, lint-staged fails and cancels the commit
- Commit was not done, and there are no staged changes
- Stage