Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08cf8f5

Browse filesBrowse files
committed
docs: update README.md and bump nano-spawn as major change
1 parent 276dcc8 commit 08cf8f5
Copy full SHA for 08cf8f5

File tree

Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed

‎.changeset/easy-frogs-speak.md

Copy file name to clipboardExpand all lines: .changeset/easy-frogs-speak.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'lint-staged': minor
2+
'lint-staged': major
33
---
44

55
Processes are spawned using [nano-spawn](https://github.com/sindresorhus/nano-spawn) instead of [execa](https://github.com/sindresorhus/execa). If you are using Node.js scripts as tasks, you might need to explicitly run them with `node`, especially when using Windows:

‎README.md

Copy file name to clipboardExpand all lines: README.md
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ _Lint-staged_ can be configured in many ways:
152152
whether your project's _package.json_ contains the `"type": "module"` option or not.
153153
- Pass a configuration file using the `--config` or `-c` flag
154154

155-
Configuration should be an object where each value is a command to run and its key is a glob pattern to use for this command. This package uses [micromatch](https://github.com/micromatch/micromatch) for glob patterns. JavaScript files can also export advanced configuration as a function. See [Using JS configuration files](#using-js-configuration-files) for more info.
155+
Configuration should be an object where each value is a **command** to run and its key is a glob pattern to use for this command. This package uses [micromatch](https://github.com/micromatch/micromatch) for glob patterns. JavaScript files can also export advanced configuration as a function. See [Using JS configuration files](#using-js-configuration-files) for more info.
156156

157157
You can also place multiple configuration files in different directories inside a project. For a given staged file, the closest configuration file will always be used. See ["How to use `lint-staged` in a multi-package monorepo?"](#how-to-use-lint-staged-in-a-multi-package-monorepo) for more info and an example.
158158

@@ -335,12 +335,19 @@ export default {
335335

336336
This will result in _lint-staged_ first running `eslint .` (matching _all_ files), and if it passes, `prettier --write file-1.js file-2.js`, when you have staged files `file-1.js`, `file-2.js` and `README.md`.
337337

338-
### Function signature
338+
### JavaScript Functions
339339

340-
The function can also be async:
340+
You can also configure _lint-staged_ to run a JavaScript/Node.js script directly, passing the list of staged files as an argument:
341341

342-
```ts
343-
(filenames: string[]) => string | string[] | Promise<string | string[]>
342+
```js
343+
export default {
344+
'*.js': {
345+
title: 'Log staged JS files to console',
346+
task: async (files) => {
347+
console.log('Staged JS files:', files)
348+
},
349+
},
350+
}
344351
```
345352

346353
### Example: Export a function to build your own matchers

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.