forked from wireapp/wire-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
183 lines (176 loc) · 5.5 KB
/
Copy patheslint.config.ts
File metadata and controls
183 lines (176 loc) · 5.5 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* Wire
* Flat ESLint configuration (ESLint 9+)
*/
import path from 'path';
import {FlatCompat} from '@eslint/eslintrc';
// @ts-ignore - No types available for @emotion/eslint-plugin with ESLint 9
import emotionPlugin from '@emotion/eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import tsParser from '@typescript-eslint/parser';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
// @ts-ignore - No types available for @tony.ganchev/eslint-plugin-header
import headerPlugin from '@tony.ganchev/eslint-plugin-header';
import globals from 'globals';
import type {Linter} from 'eslint';
const year = new Date().getFullYear();
const compat = new FlatCompat({
baseDirectory: __dirname,
resolvePluginsRelativeTo: __dirname,
});
const ignores = [
'.git/',
'docs/',
'bin/',
'**/node_modules/',
'apps/webapp/assets/',
'resource/',
'apps/webapp/resource/',
'apps/webapp/test/',
'**/__mocks__/**',
'**/setupTests.*',
'**/*.config.*',
'apps/webapp/*.config.*',
'apps/webapp/src/sw.js',
'apps/server/bin/',
'apps/server/dist/',
'apps/server/node_modules/',
'apps/webapp/src/ext/',
'apps/webapp/src/script/localization/**/webapp*.js',
'apps/webapp/src/worker/',
'apps/webapp/src/script/components/Icon.tsx',
'**/*.test.*',
'**/*.spec.*',
'*.js',
'apps/webapp/src/types/i18n.d.ts',
'apps/webapp/playwright-report/',
];
const base = compat.extends('@wireapp/eslint-config');
const config: Linter.Config[] = [
{ignores},
...base,
{
// Adjust legacy bits from extended config
rules: {
'no-unsanitized/DOM': 'off', // deprecated config variant; rely on recommended defaults instead
'valid-jsdoc': 'off', // rule removed in ESLint 9
'header/header': 'off', // disable existing header rule to use our own
},
},
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
// Enable type-aware linting for TypeScript sources
project: './apps/webapp/tsconfig.eslint.json',
tsconfigRootDir: __dirname,
EXPERIMENTAL_useProjectService: {
allowDefaultProjectForFiles: ['*.ts', '*.tsx'],
},
},
globals: {
...globals.browser,
...globals.node,
React: 'readonly',
JSX: 'readonly',
amplify: 'readonly',
},
},
// @ts-ignore - Plugin type compatibility issues with ESLint 9 flat config
plugins: {
'@emotion': emotionPlugin,
import: importPlugin,
'react-hooks': reactHooksPlugin,
'header-tony': headerPlugin,
},
rules: {
'@emotion/pkg-renaming': 'error',
'@emotion/no-vanilla': 'error',
'@emotion/import-from-emotion': 'error',
'@emotion/styled-import': 'error',
'header-tony/header': [
'error',
'block',
[
'',
' * Wire',
{
pattern: ' \\* Copyright \\(C\\) \\d{4} Wire Swiss GmbH',
template: ` * Copyright (C) ${year} Wire Swiss GmbH`,
},
' *',
' * This program is free software: you can redistribute it and/or modify',
' * it under the terms of the GNU General Public License as published by',
' * the Free Software Foundation, either version 3 of the License, or',
' * (at your option) any later version.',
' *',
' * This program is distributed in the hope that it will be useful,',
' * but WITHOUT ANY WARRANTY; without even the implied warranty of',
' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the',
' * GNU General Public License for more details.',
' *',
' * You should have received a copy of the GNU General Public License',
' * along with this program. If not, see http://www.gnu.org/licenses/.',
' *',
' ',
],
2,
],
'id-length': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^(_?err(or)?|error)$',
varsIgnorePattern: '^(_?err(or)?|error)$',
},
],
'@typescript-eslint/typedef': 'off',
'no-dupe-class-members': 'off',
'no-unsanitized/property': 'off',
'prefer-promise-reject-errors': 'off',
'jest/no-jasmine-globals': 'off',
'jsx-a11y/media-has-caption': 'off',
'no-empty': 'error',
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: path.join(__dirname, 'apps/webapp/tsconfig.eslint.json'),
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
},
{
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
languageOptions: {
parser: require('espree'),
parserOptions: {
project: null,
tsconfigRootDir: __dirname,
},
},
rules: {
// Disable TS-only rules on JS mocks/shims
'@typescript-eslint/require-array-sort-compare': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['**/*.test.tsx', '**/*.test.ts', '**/*.spec.tsx', '**/*.spec.ts', '**/test/**/*', '**/mocks/**/*'],
rules: {
'no-magic-numbers': 'off',
'id-length': 'off',
},
},
];
export default config;