-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
83 lines (83 loc) · 2.68 KB
/
index.js
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
import eslint from '@eslint/js';
import globals from 'globals';
// @ts-expect-error no-types
import html from 'eslint-plugin-html';
import { configs as tslintConfigs } from 'typescript-eslint';
// @ts-expect-error no-types
import { flatConfigs } from 'eslint-plugin-import';
import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
export function getConfig(htmlConfig = false, tsConfig = './tsconfig.json') {
return [
htmlConfig
? {
files: ['**/*.html'],
plugins: {
html,
},
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'script',
},
globals: {
...globals.browser,
},
},
rules: {
indent: ['error', 4],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
},
}
: [],
{
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.tsx'],
extends: [eslint.configs.recommended, prettierRecommendedConfig],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
rules: {
'prettier/prettier': [
'error',
{
tabWidth: 4,
printWidth: 110,
singleQuote: true,
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
...tslintConfigs.recommended,
...tslintConfigs.stylistic,
flatConfigs.recommended,
flatConfigs.typescript,
],
rules: {
'import/order': ['error'],
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-unused-expressions': ['off'],
'@typescript-eslint/no-unused-vars': ['warn'],
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: tsConfig,
},
},
},
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
];
}