Skip to content

Commit

Permalink
docs: organize
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 16, 2023
1 parent ddc94e9 commit 2efb730
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export default antfu(

Going more advanced, you can also import fine-grained configs and compose them as you wish:

<details>
<summary>Advanced Example</summary>

We don't recommend using this style in general usages, as there are shared options between configs and might need extra care to make them consistent.

```js
// eslint.config.js
import {
Expand All @@ -201,13 +206,13 @@ import {

export default [
...ignores(),
...javascript(),
...javascript(/* Options */),
...comments(),
...node(),
...jsdoc(),
...imports(),
...unicorn(),
...typescript(),
...typescript(/* Options */),
...stylistic(),
...vue(),
...jsonc(),
Expand All @@ -216,6 +221,8 @@ export default [
]
```

</details>

Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/configs) and [factory](https://github.com/antfu/eslint-config/blob/main/src/factory.ts) for more details.

> Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) for the inspiration and reference.
Expand All @@ -242,29 +249,6 @@ When you want to override rules, or disable them inline, you need to update to t
type foo = { bar: 2 }
```

### Optional Rules

This config also provides some optional plugins/rules for extended usages.

#### `sort-keys`

This plugin [`eslint-plugin-sort-keys`](https://github.com/namnm/eslint-plugin-sort-keys) allows you to keep object keys sorted with auto-fix.

It's installed but no rules are enabled by default.

It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).

```js
/* eslint sort-keys/sort-keys-fix: "error" */
const objectWantedToSort = {
a: 2,
b: 1,
c: 3,
}
/* eslint sort-keys/sort-keys-fix: "off" */
```


### Rules Overrides

Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file extension:
Expand Down Expand Up @@ -311,6 +295,28 @@ export default antfu({
})
```

### Optional Rules

This config also provides some optional plugins/rules for extended usages.

#### `sort-keys`

This plugin [`eslint-plugin-sort-keys`](https://github.com/namnm/eslint-plugin-sort-keys) allows you to keep object keys sorted with auto-fix.

It's installed but no rules are enabled by default.

It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).

```js
/* eslint sort-keys/sort-keys-fix: "error" */
const objectWantedToSort = {
a: 2,
b: 1,
c: 3,
}
/* eslint sort-keys/sort-keys-fix: "off" */
```

### Type Aware Rules

You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
Expand Down

0 comments on commit 2efb730

Please sign in to comment.