@commencis/eslint-config 2.5.0 → 3.0.1
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/CHANGELOG.md +12 -0
- package/README.md +46 -48
- package/dist/{flatConfig-Cm6wkwA_.d.ts → config.types-M1gOzpFJ.d.mts} +12 -6
- package/dist/configFactory-D_qKOxEp.mjs +574 -0
- package/dist/configs/javascript.d.mts +8 -0
- package/dist/configs/javascript.mjs +9 -0
- package/dist/configs/native.d.mts +8 -0
- package/dist/configs/native.mjs +12 -0
- package/dist/configs/next.d.mts +8 -0
- package/dist/configs/next.mjs +13 -0
- package/dist/configs/react.d.mts +8 -0
- package/dist/configs/react.mjs +12 -0
- package/dist/configs/typescript.d.mts +8 -0
- package/dist/configs/typescript.mjs +9 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.mjs +7 -0
- package/package.json +26 -38
- package/dist/configs/base.d.ts +0 -8
- package/dist/configs/base.js +0 -245
- package/dist/configs/next.d.ts +0 -6
- package/dist/configs/next.js +0 -301
- package/dist/configs/prettier.d.ts +0 -6
- package/dist/configs/prettier.js +0 -9
- package/dist/configs/react-native.d.ts +0 -6
- package/dist/configs/react-native.js +0 -300
- package/dist/configs/react.d.ts +0 -6
- package/dist/configs/react.js +0 -300
- package/dist/configs/typescript.d.ts +0 -6
- package/dist/configs/typescript.js +0 -135
- package/dist/configs/vue.d.ts +0 -6
- package/dist/configs/vue.js +0 -313
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -358
package/dist/index.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import tseslint3 from "typescript-eslint";
|
|
3
|
-
|
|
4
|
-
// src/configs/base.ts
|
|
5
|
-
import eslint from "@eslint/js";
|
|
6
|
-
import globals from "globals";
|
|
7
|
-
|
|
8
|
-
// src/plugins/importSortPlugin.ts
|
|
9
|
-
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
10
|
-
|
|
11
|
-
// src/rules/importSortRules.ts
|
|
12
|
-
function asTypeOnly(pattern) {
|
|
13
|
-
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
14
|
-
return `${base}\\u0000$`;
|
|
15
|
-
}
|
|
16
|
-
function withTypeFirst(group) {
|
|
17
|
-
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
18
|
-
}
|
|
19
|
-
function exact(p) {
|
|
20
|
-
return `^@/${p}$`;
|
|
21
|
-
}
|
|
22
|
-
function subpath(p) {
|
|
23
|
-
return `^@/${p}/.+$`;
|
|
24
|
-
}
|
|
25
|
-
function expandFolders(folders) {
|
|
26
|
-
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
27
|
-
}
|
|
28
|
-
var GROUPS = {
|
|
29
|
-
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
30
|
-
SIDE_EFFECTS: ["^\\u0000"],
|
|
31
|
-
// Main frameworks & libraries
|
|
32
|
-
FRAMEWORKS: [
|
|
33
|
-
"^(react(-native|-dom)?(/.*)?)$",
|
|
34
|
-
"^next",
|
|
35
|
-
"^vue",
|
|
36
|
-
"^nuxt",
|
|
37
|
-
"^@angular(/.*|$)",
|
|
38
|
-
"^expo",
|
|
39
|
-
"^node"
|
|
40
|
-
],
|
|
41
|
-
// External packages
|
|
42
|
-
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
43
|
-
// Internal common directories
|
|
44
|
-
INTERNAL_COMMON: expandFolders([
|
|
45
|
-
"config",
|
|
46
|
-
"types",
|
|
47
|
-
"interfaces",
|
|
48
|
-
"constants",
|
|
49
|
-
"helpers",
|
|
50
|
-
"utils",
|
|
51
|
-
"lib"
|
|
52
|
-
]),
|
|
53
|
-
// Component directories
|
|
54
|
-
COMPONENTS: expandFolders([
|
|
55
|
-
"providers",
|
|
56
|
-
"layouts",
|
|
57
|
-
"pages",
|
|
58
|
-
"modules",
|
|
59
|
-
"features",
|
|
60
|
-
"components"
|
|
61
|
-
]),
|
|
62
|
-
// Internal root alias (catch-all leftover @/ imports except styles and assets)
|
|
63
|
-
INTERNAL_ROOT: ["^@/(?!.*\\.(s?css|svg|png)$).+$"],
|
|
64
|
-
// Relative parent imports then same-dir relatives
|
|
65
|
-
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
66
|
-
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
67
|
-
// Assets
|
|
68
|
-
ASSETS: [
|
|
69
|
-
"(asset(s?)|public|static|images)(/.*|$)",
|
|
70
|
-
"^@/.+\\.(svg|png)$",
|
|
71
|
-
"^.+\\.svg$",
|
|
72
|
-
"^.+\\.png$"
|
|
73
|
-
],
|
|
74
|
-
// Styles
|
|
75
|
-
STYLES: [
|
|
76
|
-
// side-effect - virtual css imports
|
|
77
|
-
"^\\u0000.+\\.s?css$",
|
|
78
|
-
// root alias css imports
|
|
79
|
-
"^@/.+\\.s?css$",
|
|
80
|
-
// relative css imports
|
|
81
|
-
"^(\\.{1,2}/).+\\.s?css$"
|
|
82
|
-
]
|
|
83
|
-
};
|
|
84
|
-
var importSortRules = {
|
|
85
|
-
"simple-import-sort/imports": [
|
|
86
|
-
"error",
|
|
87
|
-
{
|
|
88
|
-
groups: [
|
|
89
|
-
GROUPS.SIDE_EFFECTS,
|
|
90
|
-
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
91
|
-
withTypeFirst(GROUPS.EXTERNAL),
|
|
92
|
-
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
93
|
-
withTypeFirst(GROUPS.COMPONENTS),
|
|
94
|
-
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
95
|
-
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
96
|
-
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
97
|
-
GROUPS.ASSETS,
|
|
98
|
-
GROUPS.STYLES
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
"simple-import-sort/exports": "error"
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// src/rules/nextPluginRules.ts
|
|
106
|
-
var nextPluginRules = {
|
|
107
|
-
// Breaks with ESLint 9, should be activated after the next plugin is updated
|
|
108
|
-
"@next/next/no-duplicate-head": "off"
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/rules/reactHooksRules.ts
|
|
112
|
-
var reactHooksRules = {
|
|
113
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
114
|
-
"react-hooks/rules-of-hooks": "error"
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// src/rules/reactRules.ts
|
|
118
|
-
var reactRules = {
|
|
119
|
-
// Disable JS specific rules
|
|
120
|
-
"react/jsx-filename-extension": "off",
|
|
121
|
-
"react/default-props-match-prop-types": "off",
|
|
122
|
-
"react/prop-types": "off",
|
|
123
|
-
// Breaks @typescript-eslint/parser
|
|
124
|
-
"react/jsx-indent": "off",
|
|
125
|
-
"react/no-typos": "off",
|
|
126
|
-
"react/jsx-closing-tag-location": "off",
|
|
127
|
-
"react/jsx-wrap-multilines": "off",
|
|
128
|
-
// No longer necessary
|
|
129
|
-
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#eslint
|
|
130
|
-
"react/jsx-uses-react": "off",
|
|
131
|
-
"react/react-in-jsx-scope": "off",
|
|
132
|
-
// We are not planning to utilize rules below
|
|
133
|
-
"react/jsx-props-no-spreading": "off"
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/rules/typescriptRules.ts
|
|
137
|
-
var typescriptRules = {
|
|
138
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
139
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
140
|
-
"@typescript-eslint/array-type": "off",
|
|
141
|
-
"@typescript-eslint/explicit-function-return-type": "error",
|
|
142
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
143
|
-
"error",
|
|
144
|
-
{
|
|
145
|
-
prefer: "type-imports",
|
|
146
|
-
fixStyle: "separate-type-imports"
|
|
147
|
-
}
|
|
148
|
-
],
|
|
149
|
-
"@typescript-eslint/no-unused-vars": [
|
|
150
|
-
"error",
|
|
151
|
-
{
|
|
152
|
-
argsIgnorePattern: "^_",
|
|
153
|
-
caughtErrorsIgnorePattern: "^_",
|
|
154
|
-
destructuredArrayIgnorePattern: "^_",
|
|
155
|
-
varsIgnorePattern: "^_"
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// src/plugins/importSortPlugin.ts
|
|
161
|
-
var importSortPluginConfig = {
|
|
162
|
-
name: "commencis/plugin:simple-import-sort",
|
|
163
|
-
plugins: {
|
|
164
|
-
"simple-import-sort": simpleImportSortPlugin
|
|
165
|
-
},
|
|
166
|
-
rules: {
|
|
167
|
-
...importSortRules
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/plugins/jsxA11yPlugin.ts
|
|
172
|
-
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
173
|
-
|
|
174
|
-
// src/constants/index.ts
|
|
175
|
-
var JSX_TSX_FILE_PATTERNS = ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"];
|
|
176
|
-
|
|
177
|
-
// src/plugins/jsxA11yPlugin.ts
|
|
178
|
-
var jsxA11yPluginConfig = {
|
|
179
|
-
name: "commencis/plugin:jsx-a11y",
|
|
180
|
-
files: JSX_TSX_FILE_PATTERNS,
|
|
181
|
-
plugins: {
|
|
182
|
-
"jsx-a11y": jsxA11yPlugin
|
|
183
|
-
},
|
|
184
|
-
languageOptions: { ...jsxA11yPlugin.flatConfigs.recommended.languageOptions },
|
|
185
|
-
rules: {
|
|
186
|
-
...jsxA11yPlugin.flatConfigs.recommended.rules
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// src/plugins/nextPlugin.ts
|
|
191
|
-
import nextPlugin from "@next/eslint-plugin-next";
|
|
192
|
-
var nextPluginConfig = {
|
|
193
|
-
name: "commencis/plugin:next",
|
|
194
|
-
files: JSX_TSX_FILE_PATTERNS,
|
|
195
|
-
plugins: {
|
|
196
|
-
"@next/next": nextPlugin
|
|
197
|
-
},
|
|
198
|
-
rules: {
|
|
199
|
-
...nextPlugin.configs.recommended.rules,
|
|
200
|
-
...nextPlugin.configs["core-web-vitals"].rules,
|
|
201
|
-
...nextPluginRules
|
|
202
|
-
},
|
|
203
|
-
ignores: [".next/*"]
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// src/plugins/reactHooksPlugin.ts
|
|
207
|
-
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
208
|
-
var reactHooksPluginConfig = {
|
|
209
|
-
name: "commencis/plugin:react-hooks",
|
|
210
|
-
files: JSX_TSX_FILE_PATTERNS,
|
|
211
|
-
plugins: {
|
|
212
|
-
"react-hooks": reactHooksPlugin
|
|
213
|
-
},
|
|
214
|
-
rules: { ...reactHooksRules }
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
// src/plugins/reactPlugin.ts
|
|
218
|
-
import reactPlugin from "eslint-plugin-react";
|
|
219
|
-
var { recommended: recommendedConfig, "jsx-runtime": jsxRuntimeConfig } = reactPlugin.configs.flat;
|
|
220
|
-
var reactPluginConfig = {
|
|
221
|
-
name: "commencis/plugin:react",
|
|
222
|
-
files: JSX_TSX_FILE_PATTERNS,
|
|
223
|
-
languageOptions: {
|
|
224
|
-
...recommendedConfig.languageOptions
|
|
225
|
-
},
|
|
226
|
-
plugins: {
|
|
227
|
-
react: reactPlugin
|
|
228
|
-
},
|
|
229
|
-
rules: {
|
|
230
|
-
...recommendedConfig.rules,
|
|
231
|
-
...jsxRuntimeConfig.rules,
|
|
232
|
-
...reactRules
|
|
233
|
-
},
|
|
234
|
-
settings: {
|
|
235
|
-
react: {
|
|
236
|
-
version: "detect"
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// src/plugins/vuePlugin.ts
|
|
242
|
-
import vuePlugin from "eslint-plugin-vue";
|
|
243
|
-
var vuePluginConfig = [
|
|
244
|
-
...vuePlugin.configs["flat/recommended"],
|
|
245
|
-
{
|
|
246
|
-
name: "commencis/plugin:vue"
|
|
247
|
-
}
|
|
248
|
-
];
|
|
249
|
-
|
|
250
|
-
// src/configs/base.ts
|
|
251
|
-
var base_default = [
|
|
252
|
-
eslint.configs.recommended,
|
|
253
|
-
importSortPluginConfig,
|
|
254
|
-
{
|
|
255
|
-
name: "commencis/base",
|
|
256
|
-
languageOptions: {
|
|
257
|
-
ecmaVersion: 2022,
|
|
258
|
-
globals: {
|
|
259
|
-
...globals.browser,
|
|
260
|
-
...globals.es2021,
|
|
261
|
-
...globals.node,
|
|
262
|
-
...globals.serviceworker
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
rules: {
|
|
266
|
-
"no-console": "warn"
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
];
|
|
270
|
-
|
|
271
|
-
// src/configs/prettier.ts
|
|
272
|
-
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
273
|
-
var prettier_default = [
|
|
274
|
-
eslintPluginPrettierRecommended,
|
|
275
|
-
{ name: "commencis/prettier" }
|
|
276
|
-
];
|
|
277
|
-
|
|
278
|
-
// src/configs/typescript.ts
|
|
279
|
-
import tseslint from "typescript-eslint";
|
|
280
|
-
var typescript_default = [
|
|
281
|
-
...tseslint.configs.strict,
|
|
282
|
-
...tseslint.configs.stylistic,
|
|
283
|
-
{
|
|
284
|
-
name: "commencis/typescript",
|
|
285
|
-
rules: {
|
|
286
|
-
...typescriptRules
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
];
|
|
290
|
-
|
|
291
|
-
// src/configs/next.ts
|
|
292
|
-
var next_default = [
|
|
293
|
-
...base_default,
|
|
294
|
-
...typescript_default,
|
|
295
|
-
reactPluginConfig,
|
|
296
|
-
reactHooksPluginConfig,
|
|
297
|
-
jsxA11yPluginConfig,
|
|
298
|
-
nextPluginConfig,
|
|
299
|
-
...prettier_default,
|
|
300
|
-
{ name: "commencis/next" }
|
|
301
|
-
];
|
|
302
|
-
|
|
303
|
-
// src/configs/react.ts
|
|
304
|
-
var react_default = [
|
|
305
|
-
...base_default,
|
|
306
|
-
...typescript_default,
|
|
307
|
-
reactPluginConfig,
|
|
308
|
-
reactHooksPluginConfig,
|
|
309
|
-
jsxA11yPluginConfig,
|
|
310
|
-
...prettier_default,
|
|
311
|
-
{ name: "commencis/react" }
|
|
312
|
-
];
|
|
313
|
-
|
|
314
|
-
// src/configs/react-native.ts
|
|
315
|
-
var react_native_default = [
|
|
316
|
-
...base_default,
|
|
317
|
-
...typescript_default,
|
|
318
|
-
reactPluginConfig,
|
|
319
|
-
reactHooksPluginConfig,
|
|
320
|
-
jsxA11yPluginConfig,
|
|
321
|
-
...prettier_default,
|
|
322
|
-
{ name: "commencis/react-native" }
|
|
323
|
-
];
|
|
324
|
-
|
|
325
|
-
// src/configs/vue.ts
|
|
326
|
-
import tseslint2 from "typescript-eslint";
|
|
327
|
-
var vue_default = [
|
|
328
|
-
...base_default,
|
|
329
|
-
...typescript_default,
|
|
330
|
-
...vuePluginConfig,
|
|
331
|
-
...prettier_default,
|
|
332
|
-
{
|
|
333
|
-
plugins: {
|
|
334
|
-
"typescript-eslint": tseslint2.plugin
|
|
335
|
-
},
|
|
336
|
-
languageOptions: {
|
|
337
|
-
parserOptions: {
|
|
338
|
-
parser: tseslint2.parser,
|
|
339
|
-
extraFileExtensions: [".vue"],
|
|
340
|
-
sourceType: "module"
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
{ name: "commencis/vue" }
|
|
345
|
-
];
|
|
346
|
-
|
|
347
|
-
// src/index.ts
|
|
348
|
-
var defineConfig = tseslint3.config;
|
|
349
|
-
export {
|
|
350
|
-
base_default as commencisBaseConfig,
|
|
351
|
-
next_default as commencisNextConfig,
|
|
352
|
-
prettier_default as commencisPrettierConfig,
|
|
353
|
-
react_default as commencisReactConfig,
|
|
354
|
-
react_native_default as commencisReactNativeConfig,
|
|
355
|
-
typescript_default as commencisTypescriptConfig,
|
|
356
|
-
vue_default as commencisVueConfig,
|
|
357
|
-
defineConfig
|
|
358
|
-
};
|