1- import type { FlatESLintConfigItem } from '../types'
1+ import type { FlatESLintConfigItem , StylisticConfig } from '../types'
22import { pluginAntfu , pluginStylistic } from '../plugins'
33
4- export function stylistic ( ) : FlatESLintConfigItem [ ] {
4+ export function stylistic ( options : StylisticConfig = { } ) : FlatESLintConfigItem [ ] {
5+ const {
6+ indent = 2 ,
7+ quotes = 'single' ,
8+ } = options
9+
510 return [
611 {
712 name : 'coderwyd:stylistic' ,
@@ -26,7 +31,7 @@ export function stylistic(): FlatESLintConfigItem[] {
2631 'style/computed-property-spacing' : [ 'error' , 'never' , { enforceForClassMembers : true } ] ,
2732 'style/dot-location' : [ 'error' , 'property' ] ,
2833 'style/eol-last' : 'error' ,
29- 'style/indent' : [ 'error' , 2 , {
34+ 'style/indent' : [ 'error' , indent , {
3035 ArrayExpression : 1 ,
3136 CallExpression : { arguments : 1 } ,
3237 FunctionDeclaration : { body : 1 , parameters : 1 } ,
@@ -85,15 +90,15 @@ export function stylistic(): FlatESLintConfigItem[] {
8590 'style/no-mixed-spaces-and-tabs' : 'error' ,
8691 'style/no-multi-spaces' : 'error' ,
8792 'style/no-multiple-empty-lines' : [ 'error' , { max : 1 , maxBOF : 0 , maxEOF : 0 } ] ,
88- 'style/no-tabs' : 'error' ,
93+ 'style/no-tabs' : indent === 'tab' ? 'off' : 'error' ,
8994 'style/no-trailing-spaces' : 'error' ,
9095 'style/no-whitespace-before-property' : 'error' ,
9196 'style/object-curly-spacing' : [ 'error' , 'always' ] ,
9297 'style/object-property-newline' : [ 'error' , { allowMultiplePropertiesPerLine : true } ] ,
9398 'style/operator-linebreak' : [ 'error' , 'before' ] ,
9499 'style/padded-blocks' : [ 'error' , { blocks : 'never' , classes : 'never' , switches : 'never' } ] ,
95100 'style/quote-props' : [ 'error' , 'consistent-as-needed' ] ,
96- 'style/quotes' : [ 'error' , 'single' , { allowTemplateLiterals : true , avoidEscape : true } ] ,
101+ 'style/quotes' : [ 'error' , quotes , { allowTemplateLiterals : true , avoidEscape : true } ] ,
97102 'style/rest-spread-spacing' : [ 'error' , 'never' ] ,
98103 'style/semi' : [ 'error' , 'never' ] ,
99104 'style/semi-spacing' : [ 'error' , { after : true , before : false } ] ,
0 commit comments