Skip to content

Releases

v17.6.0

Choose a tag to compare

@github-actions github-actions released this 26 Sep 05:59
Immutable release. Only release title and notes can be modified.
48f9f4e

Minor Changes

  • #1850 938d3f4 - Task functions like { title, task } can now use a logger function log() to emit output while the task runs. By default, the output will only be visible if the task fails, unless the --verbose option was used. Additionally, when the task rejects, the error will be shown in the output.

    import { defineConfig } from 'lint-staged/config'
    
    export default defineConfig({
      '*': {
        title: 'Fail if PDF files are committed',
        task: async (filepaths, { log }) => {
          const pdfFiles = filepaths.filter((f) => f.toLowerCase().endsWith('.pdf'))
          if (pdfFiles.length > 0) {
            log('PDF files should not be committed: %s', pdfFiles)
            throw new Error('Failed')
          }
        },
      },
    })
  • #1854 30562bc - lint-staged now stages changes to all tracked files modified by tasks, including files that werenโ€™t originally staged or didnโ€™t match the configured globs. This can happen when your task has side-effects, or it's a function that ignores the staged files like () => "prettier --write .".

    If you have unstaged changes in a file and the task also edits that file, your unstaged changes will be staged too. Use --hide-unstaged to hide your changes while tasks run.

Patch Changes

  • #1860 4296532 - The assignment of staged files to lint-staged configuration files (when using multiple, for example in a monorepo) has been rewritten to be more efficient. As a reminder, each staged file is assigned to exactly one configuration (the closest one), even if that config doesn't match the file in its globs.

  • #1861 c45f28a - Fix running parallel tasks for a single glob, when tasks are created by a function. Nesting one level of arrays inside an array of tasks will result in the inner tasks running in parallel. This behavior should now be consistent when creating tasks using functions. In the following example eslint and prettier will run in parallel (for all files, when any JS files are staged):

    import { defineConfig } from 'lint-staged/config'
    
    export default defineConfig({
      '*.js': () => [['eslint --max-warnings=0 .', 'prettier --list-different .']],
    })
  • #1859 f0ea69d - Various performance improvements from skipping redundant internal Git calls.

  • #1856 69d7d17 - Partially staged changes are hidden in a uniquely-named patch file to avoid multiple invocations of lint-staged overwriting it. This makes it safer to run lint-staged in multiple worktrees at the same time.

v17.5.1

Choose a tag to compare

@github-actions github-actions released this 10 Sep 11:30
Immutable release. Only release title and notes can be modified.
f8b1ab1

Patch Changes

  • #1852 bfcca94 - Fix TypeScript issue TS1254 from defineConfig() by changing the signature from const to a function:

    A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

v17.5.0

Choose a tag to compare

@github-actions github-actions released this 05 Sep 07:03
Immutable release. Only release title and notes can be modified.
dcb59f6

Minor Changes

  • #1847 f9063b7 - Lint-staged now refuses to run when files were staged with --intent-to-add, because Git stash doesn't support them. Previously this was an unhandled error.

Patch Changes

  • #1848 d718ccc - Lint-staged now handles color support better in non-TTY streams, and honors the FORCE_COLOR environment variable.

  • #1845 7e5ece8 - Update tinyexec@1.3.1 so that local binaries from node_modules/.bin are resolved starting from the directory of each lint-staged configuration file (in monorepo setups). This behavior was broken in lint-staged@16.3.0 where they were only resolved from the current working directory and up.

  • #1845 eb8a4e3 - Do not try to restore untracked files when using --hide-all and there is no initial commit yet.

v17.4.1

Choose a tag to compare

@github-actions github-actions released this 27 Aug 10:48
Immutable release. Only release title and notes can be modified.
d0c1517

17.4.1

Patch Changes

  • #1840 efe5b63 - This is a version-bump-only release because the previous version 17.4.0 was not published to npmjs.com due to problems with GitHub Actions and Changesets.

17.4.0

Minor Changes

  • #1836 90ec282 - Added a new defineConfig helper for type-checking the lint-staged configuration:

    // lint-staged.config.ts
    
    import { defineConfig } from 'lint-staged/config'
    
    export default defineConfig({
      '*.js': ['prettier --check', 'eslint'],
    })
  • #1832 510a27c - Added a new flag --all to make lint-staged include all files tracked by Git, instead of only staged.

    By default lint-staged only runs tasks on files that include staged changes (hence the name). Use this flag to include all files tracked in Git version control (standard exclusions apply). Using this flag implies the --no-stash flag, disabling the automatic backup, and the --allow-empty flag so that lint-staged doesn't fail when there are no changes after running. This makes it easier to run npx lint-staged --all on a clean state, for example in CI.

Patch Changes

  • #1838 69bec99 - The behavior of the automatic backup stash has been improved when running lint-staged in multiple worktrees in parallel. You should still avoid running multiple instances of lint-staged in parallel in the same tree, because some of the Git operations are locking and might lead to data loss.

  • #1839 5e5bdd2 - Parsing of lint-staged CLI flags and Node.js API options has been rewritten to avoid inconsistent behavior between the two.

v17.3.0

Choose a tag to compare

@github-actions github-actions released this 31 Jul 08:41
Immutable release. Only release title and notes can be modified.
d153443

Minor Changes

  • #1825 16b3f74 - It is now possible to run multiple tasks in parallel for a single glob by configuring it with an array of tasks (which run sequentially), and then placing another array inside it (where the tasks will run in parallel). The following demonstrates the order tasks will start in:

    {
      "*.ts": ["first", "second", ["third", "third"], "fourth"]
    }

    As a concrete example, lint-staged's own configuration is:

    /** @type {import('./lib/index.js').Configuration} */
    export default {
      "*": [
        [
          "oxfmt --check --no-error-on-unmatched-pattern",
          "oxlint --no-error-on-unmatched-pattern",
        ],
      ],
      "*.ts": () => "tsc",
    };

    which means:

    1. for all staged files, run the two commands in parallel with staged filenames appended, for example:
      • oxfmt --check --no-error-on-unmatched-pattern lib/index.js
      • oxlint --no-error-on-unmatched-pattern lib/index.js
    2. additionally, if any *.ts files are staged, run tsc without appending any arguments
    3. The two sets of commands also run in parallel

Patch Changes

  • #1829 15f7e53 - During an in-progress merge, files that are unchanged from the branch being merged are now skipped. Technically, files are only included if there are staged changes against both HEAD and MERGE_HEAD.

v17.2.0

Choose a tag to compare

@github-actions github-actions released this 23 Jul 09:48
Immutable release. Only release title and notes can be modified.
fb540fb

Minor Changes

  • #1823 ee156cc - The chunking of tasks based on maximum command line argument length has been re-implemented to be more precise. Now the chunking happens based on the final generated command string, instead of just the list of staged files like previously. This benefits mainly Windows platforms and function commands like:

    /** @type {import('lint-staged').Configuration} */
    export default {
      "*.ts": () => "tsc", // Run "tsc" when any TS file is changed (for entire project)
    };

    Where the spawned command is literally "tsc" without any extra arguments. Previously, this was still chunked when a lot of files were staged. Now, it probably won't be chunked because the length of the command is just three letters.

    Also, native JavaScript/Node.js function tasks won't be chunked at all, when previously they were run multiple times when chunked:

    /** @type {import('lint-staged').Configuration} */
    export default {
      "*.js": {
        title: "Log staged JS files to console",
        task: async (files) => {
          console.log("Staged JS files:", files);
        },
      },
    };

v17.1.1

Choose a tag to compare

@github-actions github-actions released this 22 Jul 06:06
Immutable release. Only release title and notes can be modified.
dbc7831

Patch Changes

  • #1820 a626a9f - It's now possible to set --max-arg-length=Infinity to effectively disable chunking of tasks based on the number of staged files. The parsing and validation of the numeric CLI options --max-arg-length and --concurrency has been improved.

v17.1.0

Choose a tag to compare

@github-actions github-actions released this 18 Jul 13:47
Immutable release. Only release title and notes can be modified.
dd5a95f

Minor Changes

  • #1816 7568d4f - The console output of lint-staged has been simplified so that there's less interactive spinners and more explicit messages like "Startedโ€ฆ" -> "Done!". The primary purpose of this was to remove Listr2, a very large dependency.

    Before:

    Size of node_modules/ after installing: 1561.7 kB with 29 packages.

    Fancy interactive spinners, but output dynamically changes:

    โœ” Backed up original state in git stash (0b191303)
    โœ” Running tasks for staged files...
    โœ” Staging changes from tasks...
    โœ” Cleaning up temporary files...

    After:

    Size of node_modules/ after installing: 974.0 kB with 5 packages (37.6 % smaller, 82.7 % less transitive dependencies).

    Simpler but more explicit output:

    โ‹ฏ Backing up original stateโ€ฆ
    โœ” Done backing up original state (35b38ed1)!
    โ‹ฏ Running tasks for staged filesโ€ฆ
        *.js โ€” 1 file
          โ‹ฏ oxlint --fix
        *.{json,md} โ€” 1 file
          โ‹ฏ oxfmt --write
    
    โœ” oxfmt --write
    โœ” oxlint --fix
    
    โœ” Done running tasks for staged files!
    โ‹ฏ Staging changes from tasksโ€ฆ
    โœ” Done staging changes from tasks!
    โ‹ฏ Cleaning up temporary filesโ€ฆ
    โœ” Done cleaning up temporary files!

Patch Changes

  • #1816 c19079d - Try to restore hidden unstaged changes when using --no-revert.

  • #1818 efb23a2 - Console output colors are enabled/disabled more consistently.

  • #1818 26112a1 - Failed JS function tasks now properly kill other tasks, unless --continue-on-error is used. Previously their failure didn't affect other tasks.

v17.0.8

Choose a tag to compare

@github-actions github-actions released this 20 Jun 19:36
Immutable release. Only release title and notes can be modified.
5f3b8f2

Patch Changes

  • #1809 179b437 - Fix lint-staged discarding the ongoing merge conflict status (.git/MERGE_HEAD) when using the --hide-unstaged or --hide-all options.

  • #1811 3d0b2c0 - Fix issues with Git commands that are successful but also emit warnings to stderr, by ignoring the stderr output completely when the process exits with code 0. This was the behavior when using nano-spawn and execa, but when switching to tinyexec in 16.3.0 both stdout and stderr were used as interleaved output.

v17.0.7

Choose a tag to compare

@github-actions github-actions released this 31 May 10:48
Immutable release. Only release title and notes can be modified.
cd11fec

Patch Changes