@siberiacancode/eslint 2.0.7 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -3
- package/index.js +41 -39
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module '@siberiacancode/eslint' {
|
|
2
2
|
declare type Eslint = (
|
|
3
3
|
options?: import('@antfu/eslint-config').OptionsConfig & {
|
|
4
|
-
'jsx-a11y'?: boolean
|
|
4
|
+
'jsx-a11y'?: boolean;
|
|
5
5
|
} & import('@antfu/eslint-config').TypedFlatConfigItem,
|
|
6
6
|
...userConfigs: import('@antfu/eslint-config').Awaitable<
|
|
7
7
|
| import('@antfu/eslint-config').TypedFlatConfigItem
|
|
@@ -12,7 +12,7 @@ declare module '@siberiacancode/eslint' {
|
|
|
12
12
|
) => import('@antfu/eslint-config').FlatConfigComposer<
|
|
13
13
|
import('@antfu/eslint-config').TypedFlatConfigItem,
|
|
14
14
|
import('@antfu/eslint-config').ConfigNames
|
|
15
|
-
|
|
15
|
+
>;
|
|
16
16
|
|
|
17
|
-
export const eslint: Eslint
|
|
17
|
+
export const eslint: Eslint;
|
|
18
18
|
}
|
package/index.js
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import antfu from '@antfu/eslint-config'
|
|
2
|
-
import pluginJsxA11y from 'eslint-plugin-jsx-a11y'
|
|
3
|
-
import pluginReact from 'eslint-plugin-react'
|
|
4
|
-
import pluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
1
|
+
import antfu from '@antfu/eslint-config';
|
|
2
|
+
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
|
|
3
|
+
import pluginReact from 'eslint-plugin-react';
|
|
4
|
+
import pluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
5
5
|
|
|
6
6
|
/** @type {import('@siberiacancode/eslint').Eslint} */
|
|
7
|
-
export const eslint = (options
|
|
7
|
+
export const eslint = (options, ...configs) => {
|
|
8
|
+
const stylistic = options.stylistic ?? false;
|
|
9
|
+
|
|
8
10
|
if (options['jsx-a11y']) {
|
|
9
11
|
configs.unshift({
|
|
10
12
|
plugins: {
|
|
11
|
-
'siberiacancode-jsx-a11y': pluginJsxA11y
|
|
13
|
+
'siberiacancode-jsx-a11y': pluginJsxA11y
|
|
12
14
|
},
|
|
13
15
|
name: 'siberiacancode/jsx-a11y',
|
|
14
16
|
rules: {
|
|
15
17
|
...Object.entries(pluginJsxA11y.flatConfigs.recommended.rules).reduce(
|
|
16
18
|
(acc, [key, value]) => {
|
|
17
|
-
acc[key.replace('jsx-a11y', 'siberiacancode-jsx-a11y')] = value
|
|
18
|
-
return acc
|
|
19
|
+
acc[key.replace('jsx-a11y', 'siberiacancode-jsx-a11y')] = value;
|
|
20
|
+
return acc;
|
|
19
21
|
},
|
|
20
|
-
{}
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
22
|
+
{}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
});
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
if (options.react) {
|
|
27
29
|
configs.unshift({
|
|
28
30
|
name: 'siberiacancode/react',
|
|
29
31
|
plugins: {
|
|
30
|
-
'siberiacancode-react': pluginReact
|
|
32
|
+
'siberiacancode-react': pluginReact
|
|
31
33
|
},
|
|
32
34
|
settings: {
|
|
33
35
|
react: {
|
|
34
|
-
version: 'detect'
|
|
35
|
-
}
|
|
36
|
+
version: 'detect'
|
|
37
|
+
}
|
|
36
38
|
},
|
|
37
39
|
rules: {
|
|
38
40
|
...Object.entries(pluginReact.configs.recommended.rules).reduce((acc, [key, value]) => {
|
|
39
|
-
acc[key.replace('react', 'siberiacancode-react')] = value
|
|
40
|
-
return acc
|
|
41
|
+
acc[key.replace('react', 'siberiacancode-react')] = value;
|
|
42
|
+
return acc;
|
|
41
43
|
}, {}),
|
|
42
44
|
'siberiacancode-react/react-in-jsx-scope': 'off',
|
|
43
45
|
'siberiacancode-react/function-component-definition': [
|
|
44
46
|
'error',
|
|
45
47
|
{
|
|
46
48
|
namedComponents: ['arrow-function'],
|
|
47
|
-
unnamedComponents: 'arrow-function'
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
})
|
|
49
|
+
unnamedComponents: 'arrow-function'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
});
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
if (
|
|
56
|
+
if (stylistic) {
|
|
55
57
|
configs.unshift({
|
|
56
58
|
name: 'siberiacancode/formatter',
|
|
57
59
|
rules: {
|
|
@@ -67,7 +69,7 @@ export const eslint = (options = { stylistics: false }, ...configs) => {
|
|
|
67
69
|
'error',
|
|
68
70
|
100,
|
|
69
71
|
2,
|
|
70
|
-
{ ignoreComments: true, ignoreStrings: true, ignoreTemplateLiterals: true }
|
|
72
|
+
{ ignoreComments: true, ignoreStrings: true, ignoreTemplateLiterals: true }
|
|
71
73
|
],
|
|
72
74
|
'style/quotes': ['error', 'single', { allowTemplateLiterals: true }],
|
|
73
75
|
'style/jsx-quotes': ['error', 'prefer-single'],
|
|
@@ -76,13 +78,13 @@ export const eslint = (options = { stylistics: false }, ...configs) => {
|
|
|
76
78
|
'style/indent': ['error', 2, { SwitchCase: 1 }],
|
|
77
79
|
'style/no-tabs': 'error',
|
|
78
80
|
'style/linebreak-style': ['error', 'unix'],
|
|
79
|
-
'style/arrow-parens': ['error', 'always']
|
|
80
|
-
}
|
|
81
|
-
})
|
|
81
|
+
'style/arrow-parens': ['error', 'always']
|
|
82
|
+
}
|
|
83
|
+
});
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
return antfu(
|
|
85
|
-
options,
|
|
87
|
+
{ ...options, stylistic },
|
|
86
88
|
{
|
|
87
89
|
name: 'siberiacancode/rewrite',
|
|
88
90
|
rules: {
|
|
@@ -94,13 +96,13 @@ export const eslint = (options = { stylistics: false }, ...configs) => {
|
|
|
94
96
|
|
|
95
97
|
'test/prefer-lowercase-title': 'off',
|
|
96
98
|
|
|
97
|
-
'no-console': 'warn'
|
|
98
|
-
}
|
|
99
|
+
'no-console': 'warn'
|
|
100
|
+
}
|
|
99
101
|
},
|
|
100
102
|
{
|
|
101
103
|
name: 'siberiacancode/imports',
|
|
102
104
|
plugins: {
|
|
103
|
-
'plugin-simple-import-sort': pluginSimpleImportSort
|
|
105
|
+
'plugin-simple-import-sort': pluginSimpleImportSort
|
|
104
106
|
},
|
|
105
107
|
rules: {
|
|
106
108
|
'sort-imports': 'off',
|
|
@@ -117,12 +119,12 @@ export const eslint = (options = { stylistics: false }, ...configs) => {
|
|
|
117
119
|
['^\\u0000'],
|
|
118
120
|
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
|
|
119
121
|
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
|
|
120
|
-
['^.+\\.s?css$']
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
}
|
|
122
|
+
['^.+\\.s?css$']
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
125
127
|
},
|
|
126
|
-
...configs
|
|
127
|
-
)
|
|
128
|
-
}
|
|
128
|
+
...configs
|
|
129
|
+
);
|
|
130
|
+
};
|