forked from sbb-design-systems/lyne-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
149 lines (144 loc) · 3.82 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
// @ts-check
import 'tsx';
import { FlatCompat } from '@eslint/eslintrc';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginYml from 'eslint-plugin-yml';
import eslint from '@eslint/js';
const eslintPluginLyne = await import('./tools/eslint/index.ts');
const compat = new FlatCompat({
baseDirectory: import.meta.resolve('.'),
});
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
{
settings: {
'import-x/resolver': {
typescript: true,
},
},
},
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
},
{
ignores: [
'**/*.chromatic.stories.*',
'dist/**/*',
'coverage/**/*',
'tools/generate-component/boilerplate/**/*',
'**/__snapshots__/**/*',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...eslintPluginYml.configs['flat/standard'],
...eslintPluginYml.configs['flat/prettier'],
...compat.extends(
'plugin:lit/recommended',
'plugin:import-x/recommended',
'plugin:import-x/typescript',
),
eslintPluginLyne.default.configs.recommended,
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
format: ['PascalCase'],
selector: 'interface',
},
{
format: ['camelCase'],
selector: 'default',
},
{
format: ['camelCase', 'UPPER_CASE'],
selector: 'variable',
},
{
format: ['camelCase'],
leadingUnderscore: 'allow',
selector: 'parameter',
},
{
format: ['camelCase'],
leadingUnderscore: 'require',
modifiers: ['private'],
selector: 'memberLike',
},
{
format: ['PascalCase'],
selector: 'typeLike',
},
{
format: null,
selector: 'objectLiteralProperty',
},
],
// TODO: Remove this after fixing issues
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': 'error',
// TODO: Evaluate this rule
'@typescript-eslint/semi': 'error',
'import-x/first': 'error',
'import-x/no-absolute-path': 'error',
'import-x/no-cycle': 'error',
'import-x/no-self-import': 'error',
'import-x/no-unresolved': [
'error',
{
ignore: [
'\\.md\\?raw$',
'\\.svg\\?raw$',
'\\.scss\\?lit\\&inline',
// Broken. Maybe due to commonjs?
'@storybook/addon-actions/decorator',
],
},
],
'import-x/no-useless-path-segments': 'error',
'import-x/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
'newlines-between': 'always',
},
],
// TODO Discuss this with the team
'lit/no-invalid-html': 'off',
camelcase: 'off',
},
},
{
files: ['**/*.stories.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
{
files: ['**/*.js'],
rules: {
'import-x/namespace': 'off',
'import-x/default': 'off',
'import-x/no-named-as-default': 'off',
'import-x/no-named-as-default-member': 'off',
},
},
eslintConfigPrettier,
];