-
Notifications
You must be signed in to change notification settings - Fork 389
/
.eslintrc.js
141 lines (123 loc) · 5.24 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
module.exports = {
root: true,
reportUnusedDisableDirectives: true,
overrides: [
// Docusaurus, Storybook
{
files: [
'apps/*-docs/**/*',
'apps/*-storybook/**/*',
'examples/docusaurus/**/*',
'examples/storybook/**/*',
],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
],
parserOptions: {
EXPERIMENTAL_useProjectService: true,
},
plugins: ['react-perf', 'relay', '@typescript-eslint', 'import'],
extends: [
'airbnb-typescript/base',
'airbnb/rules/react',
'airbnb/rules/react-a11y',
'plugin:relay/strict',
],
rules: {
'import/extensions': ['error', 'never'],
'react/destructuring-assignment': 'off',
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx', '.mdx'] }],
// We utilize prop spreading
'react/jsx-props-no-spreading': 'off',
// We utilize class properties
'react/state-in-constructor': 'off',
// Dont use prop types since were using TypeScript
'react/default-props-match-prop-types': 'off',
'react/forbid-foreign-prop-types': 'off',
'react/forbid-prop-types': 'off',
'react/no-unused-prop-types': 'off',
'react/prefer-read-only-props': 'off',
'react/prop-types': 'off',
'react/require-default-props': 'off',
'react/sort-prop-types': 'off',
// Performance: Avoid unnecessary renders
'react-perf/jsx-no-new-array-as-prop': 'warn',
'react-perf/jsx-no-new-function-as-prop': 'warn',
'react-perf/jsx-no-new-object-as-prop': ['warn', { nativeAllowList: ['style'] }],
// We prefer function declarations
'react/function-component-definition': [
'error',
{ namedComponents: 'function-declaration', unnamedComponents: 'function-expression' },
],
// We prefer on/handle named events
'react/jsx-handler-names': 'error',
// We require named functions for inferred `displayName`
// This is required for memo() and forwardRef() usage
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'react/jsx-one-expression-per-line': 'off',
// We dont use flow
'relay/generated-flow-types': 'off',
// Shorthand types
'@typescript-eslint/array-type': ['error', { default: 'array' }],
'@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/method-signature-style': ['error', 'property'],
'@typescript-eslint/no-inferrable-types': 'error',
// Forbid types
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
// Readability
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: false }],
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-use-before-define': 'off',
// Correctness
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'@typescript-eslint/restrict-plus-operands': ['error', { skipCompoundAssignments: false }],
'@typescript-eslint/unified-signatures': 'error',
// Assertions
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/prefer-as-const': 'error',
// Comments
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/triple-slash-reference': [
'error',
{ path: 'never', types: 'never', lib: 'never' },
],
// Async
'no-void': 'off',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/promise-function-async': 'error',
// APIs
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
// Hard to migrate
// Errors for all try/catch blocks and any types from third-parties
'@typescript-eslint/no-unsafe-member-access': 'off',
},
};