1
1
import type { FlatESLintConfigItem } from 'eslint-define-config'
2
2
import { GLOB_JSON , GLOB_JSON5 , GLOB_JSONC } from '../globs'
3
3
import { parserJsonc , pluginJsonc } from '../plugins'
4
+ import type { OptionsOverrides , OptionsStylistic } from '../types'
5
+
6
+ export function jsonc ( options : OptionsStylistic & OptionsOverrides = { } ) : FlatESLintConfigItem [ ] {
7
+ const {
8
+ stylistic = true ,
9
+ overrides = { } ,
10
+ } = options
4
11
5
- export function jsonc ( ) : FlatESLintConfigItem [ ] {
6
12
return [
7
13
{
8
14
plugins : {
@@ -15,11 +21,7 @@ export function jsonc(): FlatESLintConfigItem[] {
15
21
parser : parserJsonc ,
16
22
} ,
17
23
rules : {
18
- 'jsonc/array-bracket-spacing' : [ 'error' , 'never' ] ,
19
- 'jsonc/comma-dangle' : [ 'error' , 'never' ] ,
20
- 'jsonc/comma-style' : [ 'error' , 'last' ] ,
21
- 'jsonc/indent' : [ 'error' , 2 ] ,
22
- 'jsonc/key-spacing' : [ 'error' , { afterColon : true , beforeColon : false } ] ,
24
+
23
25
'jsonc/no-bigint-literals' : 'error' ,
24
26
'jsonc/no-binary-expression' : 'error' ,
25
27
'jsonc/no-binary-numeric-literals' : 'error' ,
@@ -43,14 +45,26 @@ export function jsonc(): FlatESLintConfigItem[] {
43
45
'jsonc/no-undefined-value' : 'error' ,
44
46
'jsonc/no-unicode-codepoint-escapes' : 'error' ,
45
47
'jsonc/no-useless-escape' : 'error' ,
46
- 'jsonc/object-curly-newline' : [ 'error' , { consistent : true , multiline : true } ] ,
47
- 'jsonc/object-curly-spacing' : [ 'error' , 'always' ] ,
48
- 'jsonc/object-property-newline' : [ 'error' , { allowMultiplePropertiesPerLine : true } ] ,
49
- 'jsonc/quote-props' : 'error' ,
50
- 'jsonc/quotes' : 'error' ,
51
48
'jsonc/space-unary-ops' : 'error' ,
52
49
'jsonc/valid-json-number' : 'error' ,
53
50
'jsonc/vue-custom-block/no-parsing-error' : 'error' ,
51
+
52
+ ...stylistic
53
+ ? {
54
+ 'jsonc/array-bracket-spacing' : [ 'error' , 'never' ] ,
55
+ 'jsonc/comma-dangle' : [ 'error' , 'never' ] ,
56
+ 'jsonc/comma-style' : [ 'error' , 'last' ] ,
57
+ 'jsonc/indent' : [ 'error' , 2 ] ,
58
+ 'jsonc/key-spacing' : [ 'error' , { afterColon : true , beforeColon : false } ] ,
59
+ 'jsonc/object-curly-newline' : [ 'error' , { consistent : true , multiline : true } ] ,
60
+ 'jsonc/object-curly-spacing' : [ 'error' , 'always' ] ,
61
+ 'jsonc/object-property-newline' : [ 'error' , { allowMultiplePropertiesPerLine : true } ] ,
62
+ 'jsonc/quote-props' : 'error' ,
63
+ 'jsonc/quotes' : 'error' ,
64
+ }
65
+ : { } ,
66
+
67
+ ...overrides ,
54
68
} ,
55
69
} ,
56
70
]
0 commit comments