forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
134 lines (131 loc) · 3.65 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
// @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.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: '@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.`,
},
],
},
],
'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.',
},
],
},
],
'react/jsx-no-target-blank': ['error', { allowReferrer: true }],
},
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