This PR contains the following updates:
Release Notes
lint-staged/lint-staged (lint-staged)
Compare Source
Patch Changes
- #1693
33d4502 Thanks@Adrian-Baran-GY! - Fix problems with--continue-on-error option, where tasks might have still been killed (SIGINT) when one of them failed.
Compare Source
Patch Changes
- #1687
9e02d9d Thanks@iiroj! - Fix unhandled promise rejection when spawning tasks (instead of the tasks themselves failing). Previously when a task failed to spawn,lint-staged also failed and the backup stash might not have been automatically restored.
Compare Source
Patch Changes
Compare Source
Patch Changes
- #1669
27cd541 Thanks@iiroj! - When using--fail-on-changes, automatically hidden (partially) unstaged changes are no longer counted to makelint-staged fail.
Compare Source
Patch Changes
#1667699f95d Thanks@iiroj! - The backup stash will not be dropped when using--fail-on-changes and there are errors. When reverting to original state is disabled (via--no-revert or--fail-on-changes), hidden (partially) unstaged changes are still restored automatically so that it's easier to resolve the situation manually.
Additionally, the example for using the backup stash manually now uses the correct backup hash, if available:
% npx lint-staged --fail-on-changes✔ Backed up original statein git stash (c18d55a3)✔ Running tasksfor staged files...✖ Tasks modified files and --fail-on-changes was used!↓ Cleaning up temporary files...✖ lint-staged failed because`--fail-on-changes` was used.Any lost modifications can be restored from a git stash:> git stash list --format="%h %s" c18d55a3 On main: lint-staged automatic backup> git apply --index c18d55a3
Compare Source
Patch Changes
#16648277b3b Thanks@iiroj! - The built-in TypeScript types have been updated to more closely match the implementation. Notably, the list of staged files supplied to task functions isreadonly string[] and can't be mutated. Thanks@outslept!
export default {--- "*": (files: string[]) => void console.log('staged files', files)+++ "*": (files: readonly string[]) => void console.log('staged files', files)}#165470b9af3 Thanks@iiroj! - This version has been published from GitHub Actions usingTrusted Publishing for npm packages.
#16594996817 Thanks@iiroj! - Fix searching configuration files when the working directory is a subdirectory of a git repository, and there arepackage.json files in the working directory. This situation might happen when runninglint-staged for a single package in a monorepo.
#16547021f0a Thanks@iiroj! - Return the caret semver range (^) to direct dependencies so that future patch and minor versions are allowed. This enables projects to better maintain and deduplicate their own transitive dependencies while not requiring direct updates tolint-staged. This was changed in16.2.0 after the vulnerability issues withchalk anddebug, which were also removed in the same version.
Given the recent vulnerabilities in thenpm ecosystem, it's best to be very careful when updating dependencies.
Compare Source
Minor Changes
#161599eb742 Thanks@iiroj! - Added a new option--fail-on-changes to makelint-staged exit with code 1 when tasks modify any files, making theprecommit hook fail. This is similar to thegit diff --exit-code option. Using this flag also implies the--no-revert flag which means any changes made by tasks will be left in the working tree after failing, so that they can be manually staged and the commit tried again.
#1611cd05fd3 Thanks@rlorenzo! - Added a new option--continue-on-error so thatlint-staged will run all tasks to completion even if some of them fail. By default,lint-staded will exit early on the first failure.
#163782fcc07 Thanks@iiroj! - Internallint-staged errors are now thrown and visible in the console output. Previously they were caught with the process exit code set to 1, but not logged. This happens when, for example, there's a syntax error in thelint-staged configuration file.
#1647a5ecc06 Thanks@iiroj! - Removedebug as a dependency due to recent malware issue; read more atdebug-js/debug#1005. Because of this, theDEBUG environment variable is no longer supported — use the--debug to enable debugging
#16368db2717 Thanks@iiroj! - Added a new option--hide-unstaged so thatlint-staged will hide all unstaged changes to tracked files before running tasks. The changes will be applied back after running the tasks. Note that the combination of flags--hide-unstaged --no-hide-partially-staged isn't meaningful and behaves the same as just--hide-unstaged.
Thanks to@ItsNickBarry for the idea and initial implementation in#1552.
#16487900b3b Thanks@iiroj! - Removelilconfig to reduce reliance on third-party dependencies. It was used to find possible config files outside of those tracked in Git, including from the parent directories. This behavior has been moved directly intolint-staged and should work about the same.
Patch Changes
#16337f9e485 Thanks@dependabot! - Bumpslistr2 from 9.0.3 to 9.0.4.
#162699d5a9b Thanks@iiroj! - Due to recent phishing attacks, for examplechalk@5.6.1 was released with malware. To avoidlint-staged's users being at risk thedirect dependencies are pinned to exact versions, instead of allowing future patch versions with thecaret (^) range.
#1588035bbf2 Thanks@outslept! - Increase performance by listing staged files and searching for configuration concurrently.
#1645deba3ad Thanks@iiroj! - Removechalk as a dependency due to recent malware issue; read more atchalk/chalk#656.
If you are having trouble with ANSI color codes when usinglint-staged, you can try setting eitherFORCE_COLOR=true orNO_COLOR=true env variables.
Compare Source
Patch Changes
- #1610
e93578e Thanks@iiroj! - Try to improve terminating of subprocess of tasks by usingSIGKILL, and only callingpidtree when the the main task process has a known pid.
Compare Source
Patch Changes
Compare Source
Patch Changes
- #1604
90b37b0 Thanks@iiroj! - Add anothertypes field topackage.json to make even more sure NPM detects thatlint-staged includes built-in TypeScript type definitions.
Compare Source
Patch Changes
- #1602
7ea700b Thanks@dword-design! - Add thetypes field topackage.json to make sure NPM detectslint-staged includes built-in TypeScript type definitions.
Compare Source
Patch Changes
#1570a7c0c88 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.
Compare Source
Patch Changes
#15653686977 Thanks@iiroj! -Lint-staged now explicitly warns about potential data loss when using--no-stash.
#157102299a9 Thanks@iiroj! - Function tasks (introduced in v16.0.0) only receive the staged files matching the configured glob, instead of all staged files.
#1563bc61c74 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 bylint-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.
Compare Source
Minor Changes
#1536e729daa 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.
#1550b27fa3f Thanks@iiroj! -Lint-staged now ignores symlinks and leaves them out from the list of staged files.
Patch Changes
Compare Source
Major Changes
#1546158d15c Thanks@iiroj! - Processes are spawned usingnano-spawn instead ofexeca. 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"}#1546158d15c Thanks@iiroj! - The--shell flag has been removed andlint-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"$@​":
Compare Source
Patch Changes
Compare Source
Patch Changes
Compare Source
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 Prettierprefers 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
Compare Source
Patch Changes
- #1512
cbfed1d Thanks@tarik02! - Adjust TypeScript types for the default export so that it can be used as a value without error TS2693.
Compare Source
Patch Changes
- #1509
8827ebf Thanks@iiroj! - Changelint-staged's dependencies to usecaret (^) ranges instead oftilde (~). This makes it easier for package managers to perform dependency management when minor-level updates are also permitted instead of just patch-level.
Compare Source
Patch Changes
Compare Source
Minor Changes
#1500a8ec1dd Thanks@iiroj! -Lint-staged now provides TypeScript types for the configuration and main Node.js API. You can use the JSDoc syntax in your JS configuration files:
/** * @​filename: lint-staged.config.js * @​type {import('lint-staged').Configuration} */exportdefault{'*':'prettier --write',}It's also possible to use the.ts file extension for the configuration if your Node.js version supports it. The--experimental-strip-types flag was introduced inNode.js v22.6.0 and unflagged inv23.6.0, enabling Node.js to execute TypeScript files without additional configuration.
export NODE_OPTIONS="--experimental-strip-types"npx lint-staged --config lint-staged.config.ts
Patch Changes
Compare Source
Minor Changes
#1495e69da9e Thanks@iiroj! - Added more info to the debug logs so that "environment" info doesn't need to be added separately to GitHub issues.
#1493fa0fe98 Thanks@iiroj! - Added more help messages around the automaticgit stash thatlint-staged creates as a backup (by default). The console output also displays the short githash of the stash so that it's easier to recover lost files in case some fatal errors are encountered, or the process is killed before completing.
For example:
% npx lint-staged✔ Backed up original state in git stash (20addf8)✔ Running tasks for staged files...✔ Applying modifications from tasks...✔ Cleaning up temporary files...
where the backup can be seen withgit show 20addf8, orgit stash list:
% git stash liststash@{0}: lint-staged automatic backup (20addf8)
Compare Source
Patch Changes
#1484bcfe309 Thanks@wormsik! - Escape paths containing spaces when using the "shell" option.
#14877dd8caa Thanks@iiroj! - Do not treat submodule root paths as "staged files". This causedlint-staged to fail to a Git error when only updating the revision of a submodule.
Compare Source
Patch Changes
Compare Source
Patch Changes
- #1463
b69ce2d Thanks@iiroj! - Set the maximum number of event listeners to the number of tasks. This should silence the console warningMaxListenersExceededWarning: Possible EventEmitter memory leak detected.
Configuration
📅Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated byMend Renovate. View therepository job log.
Uh oh!
There was an error while loading.Please reload this page.
This PR contains the following updates:
15.2.8->16.2.6Release Notes
lint-staged/lint-staged (lint-staged)
v16.2.6Compare Source
Patch Changes
33d4502Thanks@Adrian-Baran-GY! - Fix problems with--continue-on-erroroption, where tasks might have still been killed (SIGINT) when one of them failed.v16.2.5Compare Source
Patch Changes
9e02d9dThanks@iiroj! - Fix unhandled promise rejection when spawning tasks (instead of the tasks themselves failing). Previously when a task failed to spawn,lint-staged also failed and the backup stash might not have been automatically restored.v16.2.4Compare Source
Patch Changes
#1682
0176038Thanks@iiroj! - Update dependencies, includingnano-spawn@2.0.0with bug fixes.#1671
581a54eThanks@iiroj! - Speed up execution by only importing theyamldepedency if using YAML configuration files.v16.2.3Compare Source
Patch Changes
27cd541Thanks@iiroj! - When using--fail-on-changes, automatically hidden (partially) unstaged changes are no longer counted to makelint-staged fail.v16.2.2Compare Source
Patch Changes
#1667
699f95dThanks@iiroj! - The backup stash will not be dropped when using--fail-on-changesand there are errors. When reverting to original state is disabled (via--no-revertor--fail-on-changes), hidden (partially) unstaged changes are still restored automatically so that it's easier to resolve the situation manually.Additionally, the example for using the backup stash manually now uses the correct backup hash, if available:
v16.2.1Compare Source
Patch Changes
#1664
8277b3bThanks@iiroj! - The built-in TypeScript types have been updated to more closely match the implementation. Notably, the list of staged files supplied to task functions isreadonly string[]and can't be mutated. Thanks@outslept!export default {--- "*": (files: string[]) => void console.log('staged files', files)+++ "*": (files: readonly string[]) => void console.log('staged files', files)}#1654
70b9af3Thanks@iiroj! - This version has been published from GitHub Actions usingTrusted Publishing for npm packages.#1659
4996817Thanks@iiroj! - Fix searching configuration files when the working directory is a subdirectory of a git repository, and there arepackage.jsonfiles in the working directory. This situation might happen when runninglint-staged for a single package in a monorepo.#1654
7021f0aThanks@iiroj! - Return the caret semver range (^) to direct dependencies so that future patch and minor versions are allowed. This enables projects to better maintain and deduplicate their own transitive dependencies while not requiring direct updates tolint-staged. This was changed in16.2.0 after the vulnerability issues withchalkanddebug, which were also removed in the same version.Given the recent vulnerabilities in thenpm ecosystem, it's best to be very careful when updating dependencies.
v16.2.0Compare Source
Minor Changes
#1615
99eb742Thanks@iiroj! - Added a new option--fail-on-changesto makelint-staged exit with code 1 when tasks modify any files, making theprecommithook fail. This is similar to thegit diff --exit-codeoption. Using this flag also implies the--no-revertflag which means any changes made by tasks will be left in the working tree after failing, so that they can be manually staged and the commit tried again.#1611
cd05fd3Thanks@rlorenzo! - Added a new option--continue-on-errorso thatlint-staged will run all tasks to completion even if some of them fail. By default,lint-staded will exit early on the first failure.#1637
82fcc07Thanks@iiroj! - Internallint-staged errors are now thrown and visible in the console output. Previously they were caught with the process exit code set to 1, but not logged. This happens when, for example, there's a syntax error in thelint-staged configuration file.#1647
a5ecc06Thanks@iiroj! - Removedebug as a dependency due to recent malware issue; read more atdebug-js/debug#1005. Because of this, theDEBUGenvironment variable is no longer supported — use the--debugto enable debugging#1636
8db2717Thanks@iiroj! - Added a new option--hide-unstagedso thatlint-staged will hide all unstaged changes to tracked files before running tasks. The changes will be applied back after running the tasks. Note that the combination of flags--hide-unstaged --no-hide-partially-stagedisn't meaningful and behaves the same as just--hide-unstaged.Thanks to@ItsNickBarry for the idea and initial implementation in#1552.
#1648
7900b3bThanks@iiroj! - Removelilconfig to reduce reliance on third-party dependencies. It was used to find possible config files outside of those tracked in Git, including from the parent directories. This behavior has been moved directly intolint-staged and should work about the same.Patch Changes
#1633
7f9e485Thanks@dependabot! - Bumpslistr2 from 9.0.3 to 9.0.4.#1626
99d5a9bThanks@iiroj! - Due to recent phishing attacks, for examplechalk@5.6.1 was released with malware. To avoidlint-staged's users being at risk thedirect dependencies are pinned to exact versions, instead of allowing future patch versions with thecaret (^) range.#1588
035bbf2Thanks@outslept! - Increase performance by listing staged files and searching for configuration concurrently.#1645
deba3adThanks@iiroj! - Removechalk as a dependency due to recent malware issue; read more atchalk/chalk#656.If you are having trouble with ANSI color codes when usinglint-staged, you can try setting either
FORCE_COLOR=trueorNO_COLOR=trueenv variables.v16.1.6Compare Source
Patch Changes
e93578eThanks@iiroj! - Try to improve terminating of subprocess of tasks by usingSIGKILL, and only callingpidtreewhen the the main task process has a known pid.v16.1.5Compare Source
Patch Changes
4e3ce22Thanks@srsatt! - Detect the git repo's top-level directory correctly when in a worktree.v16.1.4Compare Source
Patch Changes
90b37b0Thanks@iiroj! - Add anothertypesfield topackage.jsonto make even more sure NPM detects thatlint-staged includes built-in TypeScript type definitions.v16.1.3Compare Source
Patch Changes
7ea700bThanks@dword-design! - Add thetypesfield topackage.jsonto make sure NPM detectslint-staged includes built-in TypeScript type definitions.v16.1.2Compare Source
Patch Changes
#1570
a7c0c88Thanks@ItsNickBarry! - When using--diff-filterwith theDoption 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 addlikefatal: pathspec 'deleted-file' did not match any files.38f942eThanks@iiroj! - Removed an extraneous log entry that printedshouldHidePArtiallyStagedFilesto console output.v16.1.1Compare Source
Patch Changes
#1565
3686977Thanks@iiroj! -Lint-staged now explicitly warns about potential data loss when using--no-stash.#1571
02299a9Thanks@iiroj! - Function tasks (introduced in v16.0.0) only receive the staged files matching the configured glob, instead of all staged files.#1563
bc61c74Thanks@iiroj! - This version fixes incorrect behavior where unstaged changes were committed when using the--no-stashoption. This happened because--no-stashimplied--no-hide-partially-staged, meaning unstaged changes to files which also had other staged changes were added to the commit bylint-staged; this is no longer the case.The previous (incorrect) behavior can still be achieved by using both options
--no-stash --no-hide-partially-stagedat the same time.v16.1.0Compare Source
Minor Changes
#1536
e729daaThanks@iiroj! - A new flag--no-reverthas 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
b27fa3fThanks@iiroj! -Lint-staged now ignores symlinks and leaves them out from the list of staged files.Patch Changes
c37dc38Thanks@iiroj! - The minimum required Node.js version is lowered to20.17followingnano-spawn@1.0.2.v16.0.0Compare Source
Major Changes
#1546
158d15cThanks@iiroj! - Processes are spawned usingnano-spawn instead ofexeca. 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
158d15cThanks@iiroj! - The--shellflag has been removed andlint-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"$@​":v15.5.2Compare Source
Patch Changes
5561321Thanks@YimingIsCOLD! - Correctly handle colon (:) characters in staged filenames.v15.5.1Compare Source
Patch Changes
#1533
5d53534Thanks@iiroj! - Improve listing of staged files so thatlint-staged doesn't crash when encountering an uninitialized submodule. This should result in less errors like:v15.5.0Compare Source
Minor Changes
630af5fThanks@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 Prettierprefers double quotes.
Previously
file.jswith only double quotes"changed to'git commit -am "I don't like double quotes"prettier --write file.js, converting all the'back to"'are stagedNow
file.jswith only double-quotes"changed to'git commit -am "I don't like double quotes"prettier --write file.js, converting all the'back to"v15.4.3Compare Source
Patch Changes
cbfed1dThanks@tarik02! - Adjust TypeScript types for the default export so that it can be used as a value without error TS2693.v15.4.2Compare Source
Patch Changes
8827ebfThanks@iiroj! - Changelint-staged's dependencies to usecaret (^) ranges instead oftilde (~). This makes it easier for package managers to perform dependency management when minor-level updates are also permitted instead of just patch-level.v15.4.1Compare Source
Patch Changes
#1504
1c7a45eThanks@iiroj! - Default TypeScript config filenames match JS equivalents.#1504
9cc18c9Thanks@iiroj! - Add missing conditional exports syntax for TypeScript types.v15.4.0Compare Source
Minor Changes
#1500
a8ec1ddThanks@iiroj! -Lint-staged now provides TypeScript types for the configuration and main Node.js API. You can use the JSDoc syntax in your JS configuration files:It's also possible to use the
.tsfile extension for the configuration if your Node.js version supports it. The--experimental-strip-typesflag was introduced inNode.js v22.6.0 and unflagged inv23.6.0, enabling Node.js to execute TypeScript files without additional configuration.Patch Changes
9b79364Thanks@iiroj! - Handle possible failures when logging user shell for debug info.v15.3.0Compare Source
Minor Changes
#1495
e69da9eThanks@iiroj! - Added more info to the debug logs so that "environment" info doesn't need to be added separately to GitHub issues.#1493
fa0fe98Thanks@iiroj! - Added more help messages around the automaticgit stashthatlint-staged creates as a backup (by default). The console output also displays the short githash of the stash so that it's easier to recover lost files in case some fatal errors are encountered, or the process is killed before completing.For example:
where the backup can be seen with
git show 20addf8, orgit stash list:v15.2.11Compare Source
Patch Changes
#1484
bcfe309Thanks@wormsik! - Escape paths containing spaces when using the "shell" option.#1487
7dd8caaThanks@iiroj! - Do not treat submodule root paths as "staged files". This causedlint-staged to fail to a Git error when only updating the revision of a submodule.v15.2.10Compare Source
Patch Changes
e3f283bThanks@iiroj! - Update minor dependencies, includingmicromatch@~4.0.8.v15.2.9Compare Source
Patch Changes
b69ce2dThanks@iiroj! - Set the maximum number of event listeners to the number of tasks. This should silence the console warningMaxListenersExceededWarning: Possible EventEmitter memory leak detected.Configuration
📅Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated byMend Renovate. View therepository job log.