forked from mozilla/perfcompare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
122 lines (119 loc) · 3.37 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
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
plugins: ['import', 'react'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:jest/recommended',
'prettier',
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
react: {
version: 'detect',
},
},
rules: {
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
overrides: [
{
// TypeScript linting
files: ['src/**/**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'airbnb-typescript',
'plugin:import/typescript',
'prettier',
],
rules: {
'react/prop-types': ['off'],
},
},
{
// Typescript test files
files: ['src/__tests__/**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: ['jest', 'jest-formatting'],
extends: [
'plugin:jest/recommended',
'plugin:import/typescript',
'plugin:testing-library/react',
'plugin:jest-dom/recommended',
'prettier',
],
rules: {
// TODO: update tests to not use store directly and remove these overrides
// https://github.com/mozilla/perfcompare/issues/115
'@typescript-eslint/no-unsafe-member-access': 'off',
// We can be less strict in tests about non-null assertions, to make it easier.
'@typescript-eslint/no-non-null-assertion': 'off',
// This disallows using direct Node properties (eg: firstChild), but we have
// legitimate uses:
'testing-library/no-node-access': 'off',
// Other useful rules in testing-library
'testing-library/prefer-explicit-assert': [
'error',
{ includeFindQueries: false },
],
// Individual jest-formatting rules so that we format only test and describe blocks
'jest-formatting/padding-around-describe-blocks': 2,
'jest-formatting/padding-around-test-blocks': 2,
},
},
{
// JavaScript linting
files: ['src/**/*.js', 'webpack/**/*.js', '*.js'],
parser: 'espree',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
},
],
// This property is specified both here in addition to the command line in
// package.json.
// The reason is that the property only warns but the command line option
// outputs errors, but the property is useful so that we have the information
// directly in editors.
reportUnusedDisableDirectives: true,
};