forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
158 lines (144 loc) · 5.04 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
152
153
154
155
156
157
158
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
module.exports = {
plugins: ['header'],
extends: ['react-app', 'prettier'],
rules: {
'import/order': [
'warn',
{
groups: [
['builtin', 'external'],
['internal', 'parent', 'sibling', 'index'],
'type',
],
pathGroups: [
{
pattern: '{.,..}/**/*.css',
group: 'type',
position: 'after',
},
],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
warnOnUnassignedImports: true,
},
],
'import/no-duplicates': ['error'],
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
},
],
'react/jsx-key': ['error', {}],
'header/header': [
2,
'line',
[
' Copyright (c) Mysten Labs, Inc.',
' SPDX-License-Identifier: Apache-2.0',
],
],
'react/boolean-prop-naming': 'off',
'react/jsx-boolean-value': ['error', 'never'],
// Always use function declarations for components
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
},
],
'react/prefer-stateless-function': 'error',
'react/jsx-pascal-case': [
'error',
{ allowAllCaps: true, allowNamespace: true },
],
// Always self-close when applicable
'react/self-closing-comp': [
'error',
{
component: true,
html: true,
},
],
'react/void-dom-elements-no-children': 'error',
// Use alternatives instead of danger
'react/no-danger': 'error',
'react/no-danger-with-children': 'error',
// Accessibility requirements
'react/button-has-type': 'error',
'react/no-invalid-html-attribute': 'error',
// Security requirements
'react/jsx-no-script-url': 'error',
'react/jsx-no-target-blank': 'error',
// Enforce consistent JSX spacing and syntax
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-space-before-closing': 'off',
// Avoid interpolation as much as possible
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],
// Always use shorthand fragments when applicable
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-no-useless-fragment': 'error',
'react/jsx-handler-names': [
'error',
{
eventHandlerPropPrefix: 'on',
},
],
// Avoid bad or problematic patterns
'react/jsx-uses-vars': 'error',
'react/no-access-state-in-setstate': 'error',
'react/no-arrow-function-lifecycle': 'error',
'react/no-children-prop': 'error',
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-namespace': 'error',
'react/no-redundant-should-component-update': 'error',
'react/no-render-return-value': 'error',
'react/no-string-refs': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
'react/no-unescaped-entities': 'error',
'react/no-unknown-property': 'error',
'react/no-unused-class-component-methods': 'error',
'react/no-will-update-set-state': 'error',
'react/require-optimization': 'off',
'react/style-prop-object': 'error',
'react/no-unstable-nested-components': 'error',
// We may eventually want to turn this on but it requires migration:
'react/no-array-index-key': 'off',
// Require usage of the custom Link component:
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-router-dom',
importNames: ['Link'],
message:
'Please use `LinkWithQuery` from "~/ui/utils/LinkWithQuery" instead.',
},
],
},
],
},
overrides: [
{
files: ['*.stories.*'],
rules: {
// Story files have render functions that this rule incorrectly warns on:
'react-hooks/rules-of-hooks': 'off',
},
},
],
};