-
-
Notifications
You must be signed in to change notification settings - Fork 125
/
.eslintrc.js
151 lines (145 loc) · 4.55 KB
/
.eslintrc.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
const path = require('path');
module.exports = {
parser: '@typescript-eslint/parser',
env: {
browser: true,
es6: true,
amd: true,
worker: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:jsx-a11y/recommended',
'plugin:cypress/recommended',
'plugin:eslint-comments/recommended',
'plugin:prettier/recommended',
'preact',
],
parserOptions: {
requireConfigFile: false,
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
'preact-i18n',
'import',
'babel',
'html',
'optimize-regex',
'json',
'jsx-a11y',
],
rules: {
'no-unused-vars': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
// Re-enable the `no-console` rule which gets disabled by the Node env.
'no-console': 'error',
'no-lonely-if': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-empty-function': 'off',
// TODO: Re-enable this once we've completely migrated to TypeScript.
'@typescript-eslint/no-var-requires': 'off',
'react/no-did-update-set-state': 'warn',
'react/self-closing-comp': 'warn',
'react/jsx-no-bind': [
'error',
{
allowArrowFunctions: true,
allowBind: false,
ignoreRefs: true,
},
],
'react/react-in-jsx-scope': 'off',
'react/jsx-key': 'off',
'react/no-unknown-property': ['error', { ignore: ['for'] }],
// TODO: Enable this once we're done migrating to functional components.
'react/prefer-stateless-function': 'off',
'optimize-regex/optimize-regex': 'warn',
'prefer-template': 'off',
'jest/expect-expect': 'off',
'jest/valid-expect-in-promise': 'off',
'jest/valid-expect': 'off',
'jest/valid-title': 'off',
'react/prop-types': 'off',
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
// https://github.com/typescript-eslint/typescript-eslint/blob/a85254817ae4914333e7236a5b0f9b6844ce8791/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
'no-undef': 'off',
},
},
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
BASE_URL: 'readonly',
LOCALE: 'readonly',
SUPPORTED_LANGUAGES: 'readonly',
SUPPORTED_COUNTRIES: 'readonly',
// defined in `src/general.js`
I18N_DEFINITION: 'readonly',
I18N_DEFINITION_REQUESTS: 'readonly',
PARAMETERS: 'readonly',
// defined in `webpack.common.js`
CODE_VERSION: 'readonly',
},
settings: {
react: {
pragma: 'h',
version: 'latest',
},
'preact-i18n': {
languageFiles: [
{
name: 'en',
path: 'src/i18n/en.json',
},
{
name: 'de',
path: 'src/i18n/de.json',
},
{
name: 'fr',
path: 'src/i18n/fr.json',
},
{
name: 'pt',
path: 'src/i18n/pt.json',
},
{
name: 'es',
path: 'src/i18n/es.json',
},
{
name: 'hr',
path: 'src/i18n/hr.json',
},
{
name: 'nl',
path: 'src/i18n/nl.json',
},
{
name: 'cs',
path: 'src/i18n/cs.json',
},
],
},
// The Preact config includes Jest rules but we don't have Jest installed. This stops them from complaining.
jest: { version: 'n/a' },
'import/resolver': { webpack: { config: path.resolve(__dirname, 'webpack.common.js') } },
},
};