forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
164 lines (161 loc) · 4.92 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
159
160
161
162
163
164
// @ts-check
const config = {
extends: '@sourcegraph/eslint-config',
env: {
browser: true,
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
project: __dirname + '/tsconfig.eslint.json',
},
settings: {
react: {
version: 'detect',
},
linkComponents: [
{
name: 'LinkOrSpan',
linkAttribute: 'to',
},
{
name: 'Link',
linkAttribute: 'to',
},
],
},
plugins: ['@sourcegraph/sourcegraph', 'monorepo', '@sourcegraph/wildcard'],
rules: {
// Rules that are specific to this repo
// All other rules should go into https://github.com/sourcegraph/eslint-config
'monorepo/no-relative-import': 'error',
'@sourcegraph/sourcegraph/check-help-links': 'error',
'no-restricted-imports': [
'error',
{
paths: [
'highlight.js',
'marked',
'rxjs/ajax',
{
name: 'rxjs',
importNames: ['animationFrameScheduler'],
message: 'Code using animationFrameScheduler breaks in Firefox when using Sentry.',
},
{
name: 'react-router-dom',
importNames: ['Link'],
message: 'Use the <Link /> component from @sourcegraph/wildcard instead.',
},
{
name: 'reactstrap',
importNames: ['Form'],
message: 'Use the <Form /> component from @sourcegraph/branded package instead',
},
{
name: '@sourcegraph/wildcard',
importNames: ['Tooltip'],
message:
'Please ensure there is only a single `<Tooltip />` component present in the React tree. To display a specific tooltip, you can add the `data-tooltip` attribute to the relevant element.',
},
{
name: 'zustand',
importNames: ['default'],
message:
'Our Zustand stores should be created in a single place. Create this store in client/web/src/stores',
},
],
patterns: [
{
group: ['**/enterprise/*'],
message: `The OSS product may not pull in any code from the enterprise codebase, to stay a 100% open-source program.
See https://handbook.sourcegraph.com/community/faq#is-all-of-sourcegraph-open-source for more information.`,
},
{
group: [
'@sourcegraph/*/src/*',
'!@sourcegraph/branded/src/*',
'!@sourcegraph/shared/src/*',
'!@sourcegraph/web/src/SourcegraphWebApp.scss',
],
message:
'Imports from package internals are banned. Add relevant export to the entry point of the package to import it from the outside world.',
},
],
},
],
'react/forbid-elements': [
'error',
{
forbid: [
{
element: 'form',
message:
'Use the Form component in src/components/Form.tsx instead of the native HTML form element to get proper form validation feedback',
},
{
element: 'select',
message: 'Use the <Select /> component from @sourcegraph/wildcard instead.',
},
{
element: 'textarea',
message: 'Use the <TextArea /> component from @sourcegraph/wildcard instead.',
},
{
element: 'a',
message: 'Use the <Link /> component from @sourcegraph/wildcard instead.',
},
],
},
],
'@sourcegraph/wildcard/forbid-class-name': [
'error',
{
forbid: [
{
className: 'badge',
message: 'Use the <Badge /> component from @sourcegraph/wildcard instead.',
},
{
className: 'icon-inline',
message: 'Use the <Icon /> component from @sourcegraph/wildcard instead.',
},
],
},
],
'react/jsx-no-target-blank': ['error', { allowReferrer: true }],
'no-restricted-syntax': [
'warn',
{
selector: 'CallExpression[callee.name="useLocalStorage"]',
message:
'Consider using useTemporarySetting instead of useLocalStorage so settings are synced when users log in elsewhere. More info at https://docs.sourcegraph.com/dev/background-information/web/temporary_settings',
},
],
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#eslint
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
},
overrides: [
{
files: ['*.d.ts'],
rules: {
'no-restricted-imports': 'off',
},
},
{
files: '*.story.tsx',
rules: {
'react/forbid-dom-props': 'off',
'import/no-default-export': 'off',
},
},
],
}
module.exports = config