|
1 | 1 | # lint-staged |
2 | 2 |
|
| 3 | +## 17.2.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- [#1823](https://github.com/lint-staged/lint-staged/pull/1823) [`ee156cc`](https://github.com/lint-staged/lint-staged/commit/ee156cc7039494f1db11f389b1233c78f588238c) - 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: |
| 8 | + |
| 9 | + ```js |
| 10 | + /** @type {import('lint-staged').Configuration} */ |
| 11 | + export default { |
| 12 | + "*.ts": () => "tsc", // Run "tsc" when any TS file is changed (for entire project) |
| 13 | + }; |
| 14 | + ``` |
| 15 | + |
| 16 | + 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. |
| 17 | + |
| 18 | + Also, native JavaScript/Node.js function tasks won't be chunked at all, when previously they were run multiple times when chunked: |
| 19 | + |
| 20 | + ```js |
| 21 | + /** @type {import('lint-staged').Configuration} */ |
| 22 | + export default { |
| 23 | + "*.js": { |
| 24 | + title: "Log staged JS files to console", |
| 25 | + task: async (files) => { |
| 26 | + console.log("Staged JS files:", files); |
| 27 | + }, |
| 28 | + }, |
| 29 | + }; |
| 30 | + ``` |
| 31 | + |
3 | 32 | ## 17.1.1 |
4 | 33 |
|
5 | 34 | ### Patch Changes |
|
395 | 424 | If you were using the shell option to avoid passing filenames to tasks, for example `bash -c 'tsc --noEmit'`, use the function syntax instead: |
396 | 425 |
|
397 | 426 | ```js |
398 | | - export default { '*.ts': () => 'tsc --noEmit' } |
| 427 | + export default { "*.ts": () => "tsc --noEmit" }; |
399 | 428 | ``` |
400 | 429 |
|
401 | 430 | - [#1546](https://github.com/lint-staged/lint-staged/pull/1546) [`158d15c`](https://github.com/lint-staged/lint-staged/commit/158d15c9aea0a3a87790ec3766442763cf387dba) Thanks [@iiroj](https://github.com/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. |
|
408 | 437 |
|
409 | 438 | ```js |
410 | 439 | export default { |
411 | | - '*.js': { |
412 | | - title: 'My task', |
| 440 | + "*.js": { |
| 441 | + title: "My task", |
413 | 442 | task: async (files) => { |
414 | | - console.log('Staged JS files:', files) |
| 443 | + console.log("Staged JS files:", files); |
415 | 444 | }, |
416 | 445 | }, |
417 | | - } |
| 446 | + }; |
418 | 447 | ``` |
419 | 448 |
|
420 | 449 | _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. |
|
446 | 475 | By default Prettier [prefers double quotes](https://prettier.io/docs/rationale#strings). |
447 | 476 |
|
448 | 477 | #### Previously |
| 478 | + |
449 | 479 | 1. Stage `file.js` with only double quotes `"` changed to `'` |
450 | 480 | 1. Run `git commit -am "I don't like double quotes"` |
451 | 481 | 1. _Lint-staged_ runs `prettier --write file.js`, converting all the `'` back to `"` |
452 | 482 | 1. Because there are now no changes, _lint-staged_ fails, cancels the commit, and resets back to the original state |
453 | 483 | 1. Commit was not done, original state is restored and single quotes `'` are staged |
454 | 484 |
|
455 | 485 | #### Now |
| 486 | + |
456 | 487 | 1. Stage `file.js` with only double-quotes `"` changed to `'` |
457 | 488 | 1. Run `git commit -am "I don't like double quotes"` |
458 | 489 | 1. _Lint-staged_ runs `prettier --write file.js`, converting all the `'` back to `"` |
|
491 | 522 | * @type {import('lint-staged').Configuration} |
492 | 523 | */ |
493 | 524 | export default { |
494 | | - '*': 'prettier --write', |
495 | | - } |
| 525 | + "*": "prettier --write", |
| 526 | + }; |
496 | 527 | ``` |
497 | 528 |
|
498 | 529 | 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 in [Node.js v22.6.0](https://github.com/nodejs/node/releases/tag/v22.6.0) and unflagged in [v23.6.0](https://github.com/nodejs/node/releases/tag/v23.6.0), enabling Node.js to execute TypeScript files without additional configuration. |
@@ -984,7 +1015,7 @@ To update your Node.js integration, please use: |
984 | 1015 |
|
985 | 1016 | ```js |
986 | 1017 | // const lintStaged = require('lint-staged') |
987 | | -import lintStaged from 'lint-staged' |
| 1018 | +import lintStaged from "lint-staged"; |
988 | 1019 | ``` |
989 | 1020 |
|
990 | 1021 | ## [v11.3.0-beta.2](https://github.com/lint-staged/lint-staged/releases/tag/v11.3.0-beta.2) - 30 Oct 2021 |
|
0 commit comments