-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy path.eslintrc.js
130 lines (127 loc) · 3.59 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
/*eslint-env node */
const rules = {
'prettier/prettier': 'error',
'prefer-spread': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-unused-expressions': 'off',
'no-prototype-builtins': 'off',
'no-empty': 'off',
'no-console': 'error',
'no-only-tests/no-only-tests': 'error',
}
const extend = [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:compat/recommended',
'plugin:posthog-js/all',
]
module.exports = {
env: {
browser: true,
es6: true,
'jest/globals': true,
},
globals: {
given: 'readonly',
global: 'readonly',
Buffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'prettier',
'@typescript-eslint',
'eslint-plugin-react',
'eslint-plugin-react-hooks',
'jest',
'no-only-tests',
],
extends: extend,
rules,
settings: {
react: {
version: '17.0',
},
'import/resolver': {
node: {
paths: ['eslint-rules'], // Add the directory containing your custom rules
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Ensure ESLint resolves both JS and TS files
},
},
},
overrides: [
{
files: 'src/**/*',
rules: {
...rules,
'no-restricted-globals': ['error', 'document', 'window'],
},
},
{
files: 'src/__tests__/**/*',
// the same set of config as in the root
// but excluding the 'plugin:compat/recommended' rule
// we don't mind using the latest features in our tests
extends: extend.filter((s) => s !== 'plugin:compat/recommended'),
rules: {
...rules,
'no-console': 'off',
'no-restricted-globals': 'off',
},
},
{
files: 'react/src/**/',
extends: [...extend, 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
},
{
files: 'eslint-rules/**/*',
extends: ['eslint:recommended', 'prettier'],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'posthog-js/no-direct-null-check': 'off',
'posthog-js/no-direct-boolean-check': 'off',
},
env: {
node: true,
},
},
{
files: 'cypress/**/*',
globals: {
cy: true,
Cypress: true,
},
},
{
files: 'testcafe/**/*',
globals: {
__dirname: true,
},
},
{
files: ['playwright/**/*.ts'],
rules: {
'posthog-js/no-direct-array-check': 'off',
'posthog-js/no-direct-undefined-check': 'off',
'posthog-js/no-direct-null-check': 'off',
'compat/compat': 'off',
},
},
{
files: ['react/**/*.ts'],
rules: {
'posthog-js/no-direct-null-check': 'off',
},
},
],
root: true,
}