-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.ts
171 lines (162 loc) · 4.92 KB
/
eslint.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import stylistic from '@stylistic/eslint-plugin';
import pluginVitest from '@vitest/eslint-plugin';
import {
defineConfigWithVueTs,
vueTsConfigs,
} from '@vue/eslint-config-typescript';
// @ts-expect-error https://github.com/cypress-io/eslint-plugin-cypress/issues/232
import pluginCypress from 'eslint-plugin-cypress/flat';
// @ts-expect-error https://github.com/import-js/eslint-plugin-import/pull/3097
import importPlugin from 'eslint-plugin-import';
import pluginVue from 'eslint-plugin-vue';
import tseslint, {
type ConfigWithExtends,
} from 'typescript-eslint';
const importPluginConfigs: ConfigWithExtends[] = [
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
{
name : 'shark-ui/import',
files : ['**/*.{ts,vue}'],
settings: {
'import/resolver': {
'typescript' : true,
'node' : true,
'eslint-import-resolver-custom-alias': {
alias: {
'@': './src',
},
extensions: ['.ts', '.vue'],
},
},
},
rules: {
'import/order': [
'error',
{
'groups': [
'builtin',
'external',
'parent',
'sibling',
'index',
],
'pathGroups': [
{
pattern : '@/library/vue/**', // Allows Vue utilities to bubble to the very top of the <script setup> tag
group : 'builtin',
position: 'before',
},
{
pattern : '@/library/**', // Treats our "internal dependencies" as somewhere between an external dependencies and internal business logic"
group : 'external',
position: 'after',
},
{
pattern : '@/**', // Alias for "src/**"
group : 'internal',
position: 'after',
},
],
'newlines-between': 'always-and-inside-groups',
'alphabetize' : {
order: 'asc',
},
},
],
},
},
];
const configWithVueTS = defineConfigWithVueTs(
...importPluginConfigs,
{
name : 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
},
{
name : 'app/files-to-ignore',
ignores: [
'**/dist/**',
'**/dist-ssr/**',
'**/coverage/**',
],
},
{
rules: {
'eqeqeq' : 'error', // Avoids `==` and `!=`, which perform type coercions that follow the rather obscure Abstract Equality Comparison Algorithm: https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
'no-implicit-coercion' : 'error', // Using constructors, factories, and parsers for coercion rather than operators leads to less confusing behavior
'@typescript-eslint/explicit-member-accessibility': 'error', // Easier to see dead code in situations where a member is marked `private`
},
},
stylistic.configs.customize({
commaDangle: 'always-multiline',
quotes : 'single',
semi : true,
}),
{
name : 'shark-ui/extra-stylistic',
plugins: {
'@stylistic': stylistic,
},
rules: {
'@stylistic/key-spacing': [
'error',
{
align : 'colon', // Makes object literals more tabular, helping identify inconsistencies and repetition
ignoredNodes: [
'ClassBody',
'TSTypeLiteral',
'TSInterfaceBody',
], // Avoids conflicts with "@stylistic/no-multi-spaces" and "@stylistic/type-annotation-spacing"
},
],
'@stylistic/nonblock-statement-body-position': [
'error',
'beside', // allows for single-line statements, useful for simple guards and "conditional sentences"
],
'@stylistic/object-curly-newline': [
'error',
{
multiline : true,
minProperties: 1,
},
],
'@stylistic/object-property-newline': [
'error',
{
allowAllPropertiesOnSameLine: false,
},
],
},
},
pluginVue.configs['flat/recommended'],
vueTsConfigs.strictTypeChecked,
vueTsConfigs.stylisticTypeChecked,
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*'],
},
{
...pluginCypress.configs.recommended as ConfigWithExtends,
files: [
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
'cypress/support/**/*.{js,ts,jsx,tsx}',
],
},
);
export default tseslint.config([
...configWithVueTS,
{
name : 'shark-ui/safety-override',
files: [
'*/**/*.ts',
],
rules: {
'@typescript-eslint/no-unsafe-argument' : 'error',
'@typescript-eslint/no-unsafe-assignment' : 'error',
'@typescript-eslint/no-unsafe-call' : 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return' : 'error',
},
},
]);