-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
118 lines (113 loc) · 4.16 KB
/
eslint.config.mjs
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
import typescriptParser from '@typescript-eslint/parser';
import prettierPlugin from 'eslint-plugin-prettier';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import angularPlugin from '@angular-eslint/eslint-plugin';
import angularTemplate from '@angular-eslint/eslint-plugin-template';
import angularTemplateParser from '@angular-eslint/template-parser';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import sonarjs from 'eslint-plugin-sonarjs';
export default [
{
ignores: ['.cache/', '.git/', '.github/', 'node_modules/'],
},
{
files: ['**/*.ts'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: ['./tsconfig.json', './tsconfig.app.json', './tsconfig.spec.json'],
},
},
plugins: {
'@typescript-eslint': tsPlugin,
'@angular-eslint': angularPlugin,
prettier: prettierPlugin,
},
rules: {
// TypeScript: https://typescript-eslint.io/rules/
...tsPlugin.configs.recommended.rules,
...tsPlugin.configs.stylistic.rules,
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/triple-slash-reference': 'warn',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
// Angular: https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/README.md
...angularPlugin.configs.recommended.rules,
'@angular-eslint/component-selector': ['error', { type: 'element', prefix: 'app', style: 'kebab-case' }],
// EcmaScript: https://eslint.org/docs/latest/rules/
...js.configs.recommended.rules,
'prefer-template': 'error',
'no-undef': 'off',
// Prettier: https://github.com/prettier/eslint-config-prettier?tab=readme-ov-file#special-rules
...eslintConfigPrettier.rules,
'prettier/prettier': 'warn',
},
},
{
files: ['**/*.html'],
languageOptions: {
parser: angularTemplateParser,
},
plugins: {
'@angular-eslint': angularPlugin,
'@angular-eslint/template': angularTemplate,
prettier: prettierPlugin,
},
rules: {
// Angular template: https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/README.md
...angularTemplate.configs.recommended.rules,
...angularTemplate.configs.accessibility.rules,
'@angular-eslint/template/prefer-self-closing-tags': 'error',
'@angular-eslint/template/no-interpolation-in-attributes': ['error'],
'@angular-eslint/template/click-events-have-key-events': 'off',
'@angular-eslint/template/interactive-supports-focus': [
'error',
{
allowList: ['li'],
},
],
'@angular-eslint/contextual-decorator': 'warn',
'@angular-eslint/prefer-signals': 'error',
'@angular-eslint/template/attributes-order': [
'error',
{
alphabetical: false,
order: [
'TEMPLATE_REFERENCE',
'ATTRIBUTE_BINDING',
'STRUCTURAL_DIRECTIVE',
'INPUT_BINDING',
'TWO_WAY_BINDING',
'OUTPUT_BINDING',
],
},
],
// Prettier: https://github.com/prettier/eslint-config-prettier?tab=readme-ov-file#special-rules
...eslintConfigPrettier.rules,
'prettier/prettier': ['error', { parser: 'angular' }],
},
},
// Unicorn: https://github.com/sindresorhus/eslint-plugin-unicorn
eslintPluginUnicorn.configs.recommended,
{
rules: {
'unicorn/prevent-abbreviations': 'warn',
'unicorn/no-array-reduce': 'off',
'unicorn/prefer-ternary': 'warn',
'unicorn/no-null': 'off',
'unicorn/prefer-dom-node-text-content': 'warn',
},
},
eslintPluginPrettierRecommended,
// SonarJS: https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md
sonarjs.configs.recommended,
{
rules: {
'sonarjs/cognitive-complexity': 'error',
'sonarjs/no-duplicate-string': 'error',
},
},
];