-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy patheslint.config.js
165 lines (159 loc) · 4.93 KB
/
eslint.config.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
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
// @ts-check
const { fixupPluginRules } = require('@eslint/compat');
const { FlatCompat } = require('@eslint/eslintrc');
const eslintJs = require('@eslint/js');
const eslintTs = require('typescript-eslint');
const angular = require('angular-eslint');
// plugins
const jsdoc = require('eslint-plugin-jsdoc');
const prettier = require('eslint-plugin-prettier');
const unusedImports = require('eslint-plugin-unused-imports');
const header = require('eslint-plugin-header');
// @see https://github.com/Stuk/eslint-plugin-header/issues/57#issuecomment-2378485611
header.rules.header.meta.schema = false;
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: eslintJs.configs.recommended
});
/**
* @description Resolve a legacy plugin that does not support eslint@9
* @see https://github.com/import-js/eslint-plugin-import/issues/2948#issuecomment-2148832701
* @param {string} name the plugin name
* @param {string} alias the plugin alias
* @returns {import('eslint').ESLint.Plugin}
*/
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
}
return fixupPluginRules(plugin);
}
module.exports = eslintTs.config(
{
files: ['**/*.ts'],
plugins: {
jsdoc,
'unused-imports': unusedImports,
header: legacyPlugin('eslint-plugin-header', 'header'),
import: legacyPlugin('eslint-plugin-import', 'import'),
prettier
},
extends: [
eslintJs.configs.recommended,
...eslintTs.configs.recommended,
...eslintTs.configs.stylistic,
...angular.configs.tsRecommended
],
processor: angular.processInlineTemplates,
rules: {
'prettier/prettier': 'error',
'header/header': [2, './license-header.js'],
'unused-imports/no-unused-imports': 'error',
'import/no-duplicates': 'error',
'import/no-unused-modules': 'error',
'import/no-unassigned-import': 'error',
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
caseInsensitive: false
},
'newlines-between': 'always',
groups: ['external', 'builtin', 'internal', ['parent', 'sibling', 'index']],
pathGroups: [
{
pattern: '{@angular/**,rxjs,rxjs/operators}',
group: 'external',
position: 'before'
},
{
pattern: '@paimon/**',
group: 'internal',
position: 'before'
}
],
pathGroupsExcludedImportTypes: []
}
],
'no-empty-function': 'off',
'no-unused-expressions': 'error',
'no-use-before-define': 'off',
'no-bitwise': 'off',
'no-duplicate-imports': 'error',
'no-invalid-this': 'off',
'no-irregular-whitespace': 'error',
'no-magic-numbers': 'off',
'no-multiple-empty-lines': 'error',
'no-redeclare': 'off',
'no-underscore-dangle': 'off',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'off',
'prefer-object-spread': 'error',
'prefer-template': 'error',
yoda: 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple'
}
],
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'off',
{
accessibility: 'explicit'
}
],
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
ignoreProperties: true
}
],
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: true
}
],
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'paimon',
style: 'camelCase'
}
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'paimon',
style: 'kebab-case'
}
]
}
},
{
files: ['**/*.html'],
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
plugins: {
prettier
},
rules: {
'@angular-eslint/template/click-events-have-key-events': ['off'],
'@angular-eslint/template/interactive-supports-focus': ['off'],
'prettier/prettier': ['error', { parser: 'angular' }]
}
}
);