forked from grafana/pyroscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
151 lines (138 loc) · 4.43 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 = {
plugins: ['@typescript-eslint', 'css-modules'],
extends: [
'airbnb-typescript-prettier',
'plugin:cypress/recommended',
'plugin:import/typescript',
'plugin:css-modules/recommended',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
rules: {
'@typescript-eslint/no-shadow': 'warn',
// https://stackoverflow.com/questions/63818415/react-was-used-before-it-was-defined/64024916#64024916
'@typescript-eslint/no-use-before-define': ['off'],
// react functional components are usually written using PascalCase
'@typescript-eslint/naming-convention': [
'warn',
{ selector: 'function', format: ['PascalCase', 'camelCase'] },
],
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'no-param-reassign': ['warn'],
'no-case-declarations': ['warn'],
'no-restricted-globals': ['warn'],
'react/button-has-type': ['warn'],
'react/prop-types': ['off'],
'jsx-a11y/heading-has-content': ['warn'],
'jsx-a11y/control-has-associated-label': ['warn'],
'no-undef': ['warn'],
'jsx-a11y/mouse-events-have-key-events': ['warn'],
'jsx-a11y/click-events-have-key-events': ['warn'],
'jsx-a11y/no-static-element-interactions': ['warn'],
'jsx-a11y/label-has-associated-control': [
'error',
{
required: {
some: ['nesting', 'id'],
},
},
],
'react/jsx-filename-extension': [1, { extensions: ['.tsx', '.ts'] }],
'import/extensions': [
'error',
'always',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'spaced-comment': [2, 'always', { exceptions: ['*'] }],
'react/require-default-props': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.spec.jsx',
'**/*.spec.ts',
'**/*.spec.tsx',
'**/*.stories.tsx',
],
packageDir: [
// TODO compute this dynamically
path.resolve(__dirname, 'packages/pyroscope-flamegraph'),
process.cwd(),
],
},
],
// otherwise it conflincts with ts411
'dot-notation': 'off',
// disable relative imports to force people to use '@webapp'
'import/no-relative-packages': 'error',
// https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/
'import/prefer-default-export': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
},
],
// any is bad, if really necessary one can use ShamefulAny
'@typescript-eslint/no-explicit-any': 'error',
// ATM there's too many errors to deal with right now
// TODO: deal with each issue individually
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
// https://github.com/typescript-eslint/typescript-eslint/issues/1184
'@typescript-eslint/no-floating-promises': ['warn', { ignoreVoid: true }],
// makes it easier to check what are local variables computated dynamically and what are static props
'react/destructuring-assignment': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
},
env: {
browser: true,
jquery: true,
},
settings: {
'import/internal-regex': '^@pyroscope',
'import/resolver': {
'eslint-import-resolver-lerna': {
packages: path.resolve(__dirname, 'packages'),
},
typescript: {
project: 'tsconfig.json',
},
},
},
overrides: [
// Tests are completely different
// And we shouldn't be so strict
{
files: ['**/?(*.)+(spec|test).+(ts|tsx|js)'],
plugins: ['jest'],
env: {
node: true,
'jest/globals': true,
},
},
],
ignorePatterns: ['dist', 'public'],
globals: {
// see ./lib/alias.d.ts
ShamefulAny: true,
JSX: true,
},
parserOptions: {
project: ['./tsconfig.json'],
},
};