Skip to content

Commit 591bb7c

Browse files
authored
chore: turn some javascript and typescript lint rules back into errors MONGOSH-1508 (#1631)
* bring back no-undef * remove rule that only required one override * bring back no-useless-escape * add comment * re-enable no-prototype-builtins * re-enable @typescript-eslint/consistent-type-imports * re-enable @typescript-eslint/no-unused-vars * re-enable @typescript-eslint/prefer-regexp-exec * ticket the remaining eslint warnings that should be errors * rather just disable no-useless-escape * remove async promise executor * reject rather * not a false positive * fix new lint errors after merge
1 parent aee03a2 commit 591bb7c

30 files changed

+76
-55
lines changed

configs/eslint-config-mongosh/index.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
const shared = require('@mongodb-js/eslint-config-devtools');
44
const common = require('@mongodb-js/eslint-config-devtools/common');
55

6-
// TODO(MONGOSH-1508) we need to turn these back into errors (and fix them) or ticket them
7-
const tempRules = {
6+
const extraJSRules = {
87
'jsx-a11y/no-autofocus': 1,
98
'jsx-a11y/click-events-have-key-events': 1,
109
'jsx-a11y/no-static-element-interactions': 1,
@@ -14,28 +13,30 @@ const tempRules = {
1413
'mocha/max-top-level-suites': 1,
1514
'mocha/no-sibling-hooks': 1,
1615

16+
// this would disallow our locale files' filenames like de_DE.ts
1717
'filename-rules/match': 1,
1818

19-
'no-useless-escape': 1,
20-
'no-undef': 1,
21-
'no-prototype-builtins': 1,
22-
'no-async-promise-executor': 1,
19+
// TODO(MONGOSH-1580): re-enable this rule
2320
'no-case-declarations': 1,
2421
};
2522

26-
// TODO(MONGOSH-1508) we need to turn these back into errors (and fix them) or ticket them
27-
const tempTypescriptRules = {
23+
const extraTypescriptRules = {
24+
// this rule causes many false positives, so we leave it to just warn
2825
'@typescript-eslint/no-unnecessary-type-assertion': 1,
26+
27+
// TODO(MONGOSH-1581): re-enable this rule
2928
'@typescript-eslint/restrict-plus-operands': 1,
29+
// TODO(MONGOSH-1582): re-enable this rule
3030
'@typescript-eslint/no-var-requires': 1,
31+
// TODO(MONGOSH-1583): re-enable this rule
3132
'@typescript-eslint/restrict-template-expressions': 1,
33+
// TODO(MONGOSH-1584): re-enable this rule
3234
'@typescript-eslint/no-empty-function': 1,
35+
// TODO(MONGOSH-1585): re-enable this rule
3336
'@typescript-eslint/no-misused-promises': 1,
34-
'@typescript-eslint/consistent-type-imports': 1,
37+
// TODO(MONGOSH-1586): re-enable this rule
3538
'@typescript-eslint/unbound-method': 1,
36-
'@typescript-eslint/no-implied-eval': 1,
37-
'@typescript-eslint/no-unused-vars': 1,
38-
'@typescript-eslint/prefer-regexp-exec': 1,
39+
// TODO(MONGOSH-1587): re-enable this rule
3940
'@typescript-eslint/ban-types': 1,
4041
};
4142

@@ -52,46 +53,46 @@ module.exports = {
5253
...common.jsOverrides,
5354
rules: {
5455
...common.jsRules,
55-
...tempRules,
56+
...extraJSRules,
5657
},
5758
},
5859
{
5960
...common.jsxOverrides,
6061
rules: {
6162
...common.jsxRules,
62-
...tempRules,
63+
...extraJSRules,
6364
},
6465
},
6566
{
6667
...common.tsOverrides,
6768
rules: {
6869
...common.tsRules,
69-
...tempRules,
70-
...tempTypescriptRules,
70+
...extraJSRules,
71+
...extraTypescriptRules,
7172
},
7273
},
7374
{
7475
...common.tsxOverrides,
7576
rules: {
7677
...common.tsxRules,
77-
...tempRules,
78-
...tempTypescriptRules,
78+
...extraJSRules,
79+
...extraTypescriptRules,
7980
},
8081
},
8182
{
8283
...common.testOverrides,
8384
rules: {
8485
...common.testRules,
85-
...tempRules,
86+
...extraJSRules,
8687
},
8788
},
8889
{
8990
...common.testOverrides,
9091
files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.test.tsx', '**/*.test.ts'],
9192
rules: {
9293
...common.testRules,
93-
...tempRules,
94-
...tempTypescriptRules,
94+
...extraJSRules,
95+
...extraTypescriptRules,
9596
},
9697
},
9798
],

packages/build/src/download-center/config.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
createAndPublishDownloadCenterConfig,
1111
createJsonFeedEntry,
1212
} from './config';
13-
import { Server as HTTPServer, createServer as createHTTPServer } from 'http';
13+
import { createServer as createHTTPServer } from 'http';
14+
import type { Server as HTTPServer } from 'http';
1415
import { once } from 'events';
1516
import path from 'path';
1617
import fetch from 'node-fetch';

packages/build/src/homebrew/generate-formula.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Mongosh < Formula
2929
end
3030
3131
test do
32-
assert_match "ECONNREFUSED 0.0.0.0:1", shell_output("#{bin}/mongosh \"mongodb://0.0.0.0:1\" 2>&1", 1)
33-
assert_match "#ok#", shell_output("#{bin}/mongosh --nodb --eval \"print('#ok#')\"")
32+
assert_match "ECONNREFUSED 0.0.0.0:1", shell_output("#{bin}/mongosh \\"mongodb://0.0.0.0:1\\" 2>&1", 1)
33+
assert_match "#ok#", shell_output("#{bin}/mongosh --nodb --eval \\"print('#ok#')\\"")
3434
end
3535
end`;
3636

@@ -75,8 +75,8 @@ class Mongosh < Formula
7575
end
7676
7777
test do
78-
assert_match "ECONNREFUSED 0.0.0.0:1", shell_output("#{bin}/mongosh \"mongodb://0.0.0.0:1\" 2>&1", 1)
79-
assert_match "#ok#", shell_output("#{bin}/mongosh --nodb --eval \"print('#ok#')\"")
78+
assert_match "ECONNREFUSED 0.0.0.0:1", shell_output("#{bin}/mongosh \\"mongodb://0.0.0.0:1\\" 2>&1", 1)
79+
assert_match "#ok#", shell_output("#{bin}/mongosh --nodb --eval \\"print('#ok#')\\"")
8080
end
8181
end`;
8282
expect(

packages/build/src/homebrew/generate-formula.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export async function generateUpdatedFormula(
1111
'master'
1212
);
1313

14-
const urlMatch = /url \"([^"]+)\"/g.exec(currentFormula.content);
15-
const shaMatch = /sha256 \"([^"]+)\"/g.exec(currentFormula.content);
14+
const urlMatch = /url "([^"]+)"/g.exec(currentFormula.content);
15+
const shaMatch = /sha256 "([^"]+)"/g.exec(currentFormula.content);
1616

1717
if (!urlMatch || !shaMatch) {
1818
throw new Error(
@@ -45,9 +45,9 @@ export async function generateUpdatedFormula(
4545
}
4646

4747
let newFormula = currentFormula.content;
48-
newFormula = newFormula.replace(/url \"([^"]+)\"/g, `url "${newUrl}"`);
48+
newFormula = newFormula.replace(/url "([^"]+)"/g, `url "${newUrl}"`);
4949
newFormula = newFormula.replace(
50-
/sha256 \"([^"]+)\"/g,
50+
/sha256 "([^"]+)"/g,
5151
`sha256 "${context.sha}"`
5252
);
5353
return newFormula;

packages/cli-repl/src/crypt-library-paths.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export async function getCryptLibraryPaths(
2424
): Promise<CryptLibraryPathResult> {
2525
const execPath = pretendProcessExecPathForTesting ?? process.execPath;
2626

27+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
2728
let getCryptSharedLibraryVersion: typeof import('mongodb-crypt-library-version');
2829
try {
2930
getCryptSharedLibraryVersion = require('mongodb-crypt-library-version');

packages/cli-repl/src/mongosh-repl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ class MongoshNodeRepl implements EvaluationListener {
485485
*
486486
* @param _initializationToken A value obtained by calling {@link MongoshNodeRepl.initialize}.
487487
*/
488+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
488489
async startRepl(_initializationToken: InitializationToken): Promise<void> {
489490
this.started = true;
490491
const { repl } = this.runtimeState();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* eslint-disable no-undef */
12
print('hello one');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* eslint-disable no-undef */
12
print('hello two');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/* eslint-disable no-undef */
12
insertTestCollection = db.getSiblingDB('test').getCollection('insertTest' + ((Math.random() * 100000) | 0));
23
print('Inserted:', insertTestCollection.insertOne({}).insertedId)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* eslint-disable no-undef */
12
print(`isInteractive=${isInteractive()}`)

0 commit comments

Comments
 (0)