-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateConfig.mjs
More file actions
112 lines (108 loc) · 2.69 KB
/
createConfig.mjs
File metadata and controls
112 lines (108 loc) · 2.69 KB
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
import eslint from '@eslint/js'
import pluginJest from 'eslint-plugin-jest'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import globals from 'globals'
import tseslint from 'typescript-eslint'
const createConfig = __dirname => {
console.info({ __dirname })
const ts = tseslint
.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.stylisticTypeChecked
)
.map(config => ({
...config,
files: ['**/*.{mts,cts,tsx,ts}'],
}))
const baseEslintConfig = [
{
name: 'Ignores',
ignores: ['public/**', 'node_modules/**', 'dist/**'],
},
{
files: ['**/*.{mts,cts,tsx,ts}'],
languageOptions: {
parserOptions: {
project: true,
projectService: true,
tsconfigRootDir: __dirname,
},
},
},
...ts,
{
settings: {
react: {
version: 'detect',
},
},
},
eslintPluginUnicorn.configs.recommended,
{
rules: {
'no-undef': 'error',
'react/react-in-jsx-scope': 'off',
'unicorn/prevent-abbreviations': 'off',
},
},
{
files: ['**/*.{jsx,tsx}'],
rules: {
'no-console': 'warn',
'unicorn/filename-case': [
'error',
{
case: 'pascalCase',
},
],
},
},
{
files: ['**/*.{js,mjs,mts,cts,cjs,ts,}'],
rules: {
'unicorn/filename-case': 'off',
},
},
{
files: ['**/*.{js,mjs,mts,cts,cjs,ts,jsx,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
globals: { ...globals.browser, ...globals.node },
},
},
{
...pluginJest.configs['flat/recommended'],
files: ['__tests__/**/*.{js,ts,jsx,tsx}'],
plugins: { jest: pluginJest },
languageOptions: {
...pluginJest.configs['flat/recommended'].languageOptions,
parserOptions: {
...pluginJest.configs['flat/recommended'].languageOptions
?.parserOptions,
tsconfigRootDir: __dirname + `\\__tests__`,
},
},
rules: {
...pluginJest.configs['flat/recommended'].rules,
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
},
{
...pluginJest.configs['flat/recommended'],
files: ['test-d/**/*.test-d.{ts,tsx}'],
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname + `\\test-d`,
},
},
},
]
return baseEslintConfig
}
export default createConfig
export { createConfig }