Skip to content

Commit 7c69e90

Browse files
committed
chore(eslint-config): allow polyfilled nodejs built-ins; temporarily disable new failing rules
1 parent 6e38e9e commit 7c69e90

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

configs/eslint-config-compass/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ const extraTsRules = {
1515
'error',
1616
{ fixMixedExportsWithInlineTypeSpecifier: false },
1717
],
18+
19+
// TODO: turn those back on
20+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'@typescript-eslint/no-base-to-string': 'off',
23+
'@typescript-eslint/no-require-imports': 'off',
24+
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
25+
'@typescript-eslint/unbound-method': 'off',
26+
'@typescript-eslint/no-redundant-type-constituents': 'off',
27+
'@typescript-eslint/no-duplicate-type-constituents': 'off',
28+
'@typescript-eslint/only-throw-error': 'off',
29+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
30+
'@typescript-eslint/no-misused-promises': 'off',
1831
};
1932

2033
const tsRules = {
@@ -57,6 +70,12 @@ const commonTestOverrides = {
5770
],
5871
},
5972
],
73+
// Due do chai triggering these rules erroneously in a lot of cases
74+
'no-unused-expressions': 'off',
75+
'@typescript-eslint/no-unused-expressions': 'off',
76+
77+
// TODO: turn these back on
78+
'mocha/consistent-spacing-between-blocks': 'off',
6079
};
6180

6281
const testJsOverrides = {

configs/eslint-config-compass/plugin.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ function restrictedProviderImport(servicePkg) {
1010
};
1111
}
1212

13+
// node built-ins with meaningful polyfills in web environment
14+
const allowedNodeJSBuiltinModules = ['stream', 'events', 'crypto'];
15+
1316
module.exports = {
1417
...baseConfig,
1518
rules: {
@@ -25,14 +28,25 @@ module.exports = {
2528
restrictedProviderImport('@mongodb-js/my-queries-storage'),
2629
restrictedProviderImport('@mongodb-js/atlas-service'),
2730
restrictedProviderImport('compass-preferences-model'),
28-
...require('module').builtinModules.map((name) => {
29-
return {
30-
name,
31-
message:
32-
'Using Node.js built-in modules in plugins is not allowed.',
33-
allowTypeImports: true,
34-
};
35-
}),
31+
...require('module')
32+
.builtinModules.filter((module) => {
33+
return (
34+
!module.startsWith('_') &&
35+
!allowedNodeJSBuiltinModules.includes(module)
36+
);
37+
})
38+
.flatMap((name) => {
39+
const config = {
40+
message:
41+
'Using Node.js built-in modules in plugins is not allowed.',
42+
allowTypeImports: true,
43+
};
44+
45+
return [
46+
{ name, ...config },
47+
{ name: `node:${name}`, ...config },
48+
];
49+
}),
3650
...['electron', '@electron/remote'].map((name) => {
3751
return {
3852
name,

0 commit comments

Comments
 (0)