+48
-5
lines changedFilter options
+48
-5
lines changed Original file line number Diff line number Diff line change
@@ -242,6 +242,29 @@ When you want to override rules, or disable them inline, you need to update to t
242
242
type foo = { bar: 2 }
243
243
```
244
244
245
+
### Optional Rules
246
+
247
+
This config also provides some optional plugins/rules for extended usages.
248
+
249
+
#### `sort-keys`
250
+
251
+
This plugin [`eslint-plugin-sort-keys`](https://github.com/namnm/eslint-plugin-sort-keys) allows you to keep object keys sorted with auto-fix.
252
+
253
+
It's installed but no rules are enabled by default.
254
+
255
+
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).
256
+
257
+
```js
258
+
/* eslint sort-keys/sort-keys-fix: "error" */
259
+
const objectWantedToSort = {
260
+
a: 2,
261
+
b: 1,
262
+
c: 3,
263
+
}
264
+
/* eslint sort-keys/sort-keys-fix: "off" */
265
+
```
266
+
267
+
245
268
### Rules Overrides
246
269
247
270
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:
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
1
1
// @ts-check
2
-
import sortKeys from 'eslint-plugin-sort-keys'
3
2
import styleMigrate from '@stylistic/eslint-plugin-migrate'
4
3
import antfu from './dist/index.js'
5
4
@@ -14,9 +13,6 @@ export default antfu(
14
13
},
15
14
{
16
15
files: ['src/**/*.ts'],
17
-
plugins: {
18
-
'sort-keys': sortKeys,
19
-
},
20
16
rules: {
21
17
'sort-keys/sort-keys-fix': 'error',
22
18
},
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
50
50
"eslint-plugin-markdown": "^3.0.1",
51
51
"eslint-plugin-n": "^16.2.0",
52
52
"eslint-plugin-no-only-tests": "^3.1.0",
53
+
"eslint-plugin-sort-keys": "^2.3.5",
53
54
"eslint-plugin-unicorn": "^48.0.1",
54
55
"eslint-plugin-unused-imports": "^3.0.0",
55
56
"eslint-plugin-vitest": "^0.3.2",
@@ -71,7 +72,6 @@
71
72
"bumpp": "^9.2.0",
72
73
"eslint": "^8.51.0",
73
74
"eslint-flat-config-viewer": "^0.1.0",
74
-
"eslint-plugin-sort-keys": "^2.3.5",
75
75
"esno": "^0.17.0",
76
76
"fast-glob": "^3.3.1",
77
77
"fs-extra": "^11.1.1",
Original file line number Diff line number Diff line change
@@ -13,3 +13,4 @@ export * from './unicorn'
13
13
export * from './vue'
14
14
export * from './yaml'
15
15
export * from './test'
16
+
export * from './sort-keys'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1
+
import type { ConfigItem } from '../types'
2
+
import { pluginSortKeys } from '../plugins'
3
+
4
+
/**
5
+
* Optional sort-keys plugin
6
+
*
7
+
* @see https://github.com/namnm/eslint-plugin-sort-keys
8
+
*/
9
+
export function sortKeys(): ConfigItem[] {
10
+
return [
11
+
{
12
+
name: 'antfu:sort-keys',
13
+
plugins: {
14
+
'sort-keys': pluginSortKeys,
15
+
},
16
+
},
17
+
]
18
+
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import {
12
12
jsonc,
13
13
markdown,
14
14
node,
15
+
sortKeys,
15
16
sortPackageJson,
16
17
sortTsconfig,
17
18
stylistic,
@@ -90,6 +91,9 @@ export function antfu(options: OptionsConfig & ConfigItem = {}, ...userConfigs:
90
91
stylistic: stylisticOptions,
91
92
}),
92
93
unicorn(),
94
+
95
+
// Optional plugins (not enabled by default)
96
+
sortKeys(),
93
97
)
94
98
95
99
if (enableVue)
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ export { default as pluginVue } from 'eslint-plugin-vue'
16
16
export * as pluginYaml from 'eslint-plugin-yml'
17
17
export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests'
18
18
export { default as pluginVitest } from 'eslint-plugin-vitest'
19
+
export { default as pluginSortKeys } from 'eslint-plugin-sort-keys'
19
20
20
21
export * as parserTs from '@typescript-eslint/parser'
21
22
export { default as parserVue } from 'vue-eslint-parser'
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4