Skip to content

Commit

Permalink
docs: sync changelog and README regarding TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Jan 16, 2025
1 parent 6de7529 commit 41c9fee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .changeset/brown-pumpkins-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ export default {
}
```

It's also possible to use the `.ts` file extension for the configuration if your Node.js version supports it. The `--experimental-strip-type` 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.
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.

```shell
export NODE_OPTIONS="--experimental-strip-types"

npx lint-staged --config lint-staged.config.ts
```
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,6 @@ Configuration should be an object where each value is a command to run and its k

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.

### TypeScript

_Lint-staged_ provides TypeScript types for the main configuration format, usable in JS-based config files. Lint-staged doesn't currently support loading configuration from actual TS files, but it's possible to [use the JSDoc syntax together with TypeScript](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types):

```js
/**
* @filename: lint-staged.config.js
* @type {import('lint-staged').Configuration}
*/
export default {
'*': 'prettier --write',
}
```

#### `package.json` example:

```json
Expand All @@ -222,6 +208,28 @@ So, considering you did `git add file1.ext file2.ext`, lint-staged will run the

`your-cmd file1.ext file2.ext`

### TypeScript

_Lint-staged_ provides TypeScript types for the main configuration format, usable in JS-based config files. Lint-staged doesn't currently support loading configuration from actual TS files, but it's possible to [use the JSDoc syntax together with TypeScript](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types):

```js
/**
* @filename: lint-staged.config.js
* @type {import('lint-staged').Configuration}
*/
export default {
'*': '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 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.

```shell
export NODE_OPTIONS="--experimental-strip-types"

npx lint-staged --config lint-staged.config.ts
```

### Task concurrency

By default _lint-staged_ will run configured tasks concurrently. This means that for every glob, all the commands will be started at the same time. With the following config, both `eslint` and `prettier` will run at the same time:
Expand Down

0 comments on commit 41c9fee

Please sign in to comment.