This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreact.js
99 lines (84 loc) · 2.74 KB
/
react.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
module.exports = {
extends: [
'airbnb',
'airbnb-typescript',
'plugin:react/jsx-runtime',
'plugin:jsx-a11y/recommended',
'./lib/shared',
],
env: { browser: true },
plugins: ['react-hooks', 'testing-library'],
settings: {
'import/resolver': {
webpack: {
config: './webpack.config.js',
// choose any app here so that global `shared` and `test` resolve
// normally, each app will have its own .eslintrc
env: { APP: 'admin' },
},
},
},
rules: {
// set up naming convention rules
'@typescript-eslint/naming-convention': [
'error',
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
// allow known variable exclusions
{ selector: 'variable', filter: { regex: '^(__typename)$', match: true }, format: null },
// Allow camelCase functions (23.2), and PascalCase functions (23.8)
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
// disable function-component-definition rule enabled by airbnb
'react/function-component-definition': 'off',
// tab indentation
'react/jsx-indent': ['error', 'tab'],
'react/jsx-indent-props': ['error', 'tab'],
// permit spreading of props
'react/jsx-props-no-spreading': 'off',
// React triggers no-unused-vars rules
'react/jsx-uses-react': 'off',
// typescript is better at prop-types than `prop-types`
'react/prop-types': 'off',
// disable react-in-jsx-scope (must use @babel/preset-react option { runtime: 'automatic' })
// see: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html and https://babeljs.io/docs/en/babel-preset-react/#runtime
'react/react-in-jsx-scope': 'off',
// check effect dependencies
'react-hooks/exhaustive-deps': 'warn',
// check rules of react hooks
'react-hooks/rules-of-hooks': 'error',
},
overrides: [
{
files: ['*.tsx'],
rules: {
// no proptypes in typescript components
'react/require-default-props': 'off',
},
},
{
files: ['**/*.gql.ts'],
rules: {
// in graphql type files, allow underscores
'@typescript-eslint/naming-convention': ['error', { selector: 'default', format: null }],
camelcase: 'off',
},
},
{
// apply testing library rules only to test files
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
extends: ['plugin:testing-library/react'],
},
],
};