-
Notifications
You must be signed in to change notification settings - Fork 180
/
index.js
122 lines (112 loc) · 2.76 KB
/
index.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
'use strict';
const path = require('path');
const shared = require('@mongodb-js/eslint-config-devtools');
const common = require('@mongodb-js/eslint-config-devtools/common');
const extraTsRules = {
// Newly converted plugins use `any` quite a lot, we can't enable the rule,
// but we can warn so we can eventually address this
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: false },
],
};
const tsRules = {
...common.tsRules,
...extraTsRules,
};
const tsOverrides = {
...common.tsOverrides,
rules: { ...tsRules },
};
const tsxRules = {
...common.tsxRules,
...extraTsRules,
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: 'useTrackOnChange',
},
],
};
const tsxOverrides = {
...common.tsxOverrides,
rules: { ...tsxRules },
};
const commonTestOverrides = {
'@mongodb-js/compass/unique-mongodb-log-id': 'off',
'@typescript-eslint/no-restricted-imports': [
'error',
{
patterns: [
{
group: '@testing-library/*',
message: 'Use @mongodb-js/testing-library-compass instead',
allowTypeImports: false,
},
],
},
],
};
const testJsOverrides = {
...common.testOverrides,
files: ['**/*.spec.js', '**/*.spec.jsx', '**/*.test.js', '**/test/**/*.js'],
rules: {
...common.testRules,
...commonTestOverrides,
},
};
const testTsOverrides = {
files: [
'**/*.spec.ts',
'**/*.spec.tsx',
'**/*.test.tsx',
'**/*.test.ts',
'**/test/**/*.ts',
],
rules: {
...common.testRules,
...extraTsRules,
...commonTestOverrides,
},
};
module.exports = {
plugins: [...shared.plugins, '@mongodb-js/compass'],
rules: {
...shared.rules,
'@mongodb-js/compass/no-leafygreen-outside-compass-components': 'error',
'@mongodb-js/compass/unique-mongodb-log-id': [
'error',
{ root: path.resolve(__dirname, '..', '..') },
],
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.name="setImmediate"]',
message: 'Use browser-compatible `setTimeout(...)` instead',
},
{
selector:
'CallExpression[callee.object.name="process"][callee.property.name="nextTick"]',
message: 'Use browser-compatible `queueMicrotask(...)` instead',
},
],
},
env: {
...shared.env,
},
overrides: [
common.jsOverrides,
common.jsxOverrides,
tsOverrides,
tsxOverrides,
testJsOverrides,
testTsOverrides,
],
settings: {
...shared.settings,
},
};