Skip to content

Commit

Permalink
chore(lint): remove require imports (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Mar 23, 2023
1 parent 833a24f commit 50a3234
Show file tree
Hide file tree
Showing 69 changed files with 117 additions and 111 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ module.exports = {
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-unused-vars': 2,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/ban-types': 0,
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate-keyfile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /usr/bin/env ts-node

import ora = require('ora');
import fs = require('fs');
import path = require('path');
import ora from 'ora';
import fs from 'fs';
import path from 'path';
import { resolve } from 'path';
import { config } from 'dotenv';
import { promisify } from 'util';
Expand Down
3 changes: 2 additions & 1 deletion src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import {
import { StorageController, StorageVariables } from './storage';
import { StatusView } from './views';
import TelemetryService from './telemetry/telemetryService';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJSON = require('../package.json');

const log = createLogger('connection controller');
const packageJSON = require('../package.json');

const MAX_CONNECTION_NAME_LENGTH = 512;

Expand Down
2 changes: 1 addition & 1 deletion src/editors/memoryFileSystemProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable new-cap */
import * as path from 'path';
import path from 'path';
import * as vscode from 'vscode';

export class File implements vscode.FileStat {
Expand Down
2 changes: 1 addition & 1 deletion src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'util';
import util from 'util';
import * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';
Expand Down
4 changes: 2 additions & 2 deletions src/editors/playgroundController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as vscode from 'vscode';
import path from 'path';
import { OutputChannel, ProgressLocation, TextEditor } from 'vscode';
import vm from 'vm';
import * as os from 'os';
import os from 'os';
import transpiler from 'bson-transpilers';

import ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import PlaygroundSelectedCodeActionProvider from './playgroundSelectedCodeActionProvider';
Expand Down Expand Up @@ -42,7 +43,6 @@ import TelemetryService from '../telemetry/telemetryService';
import { isPlayground } from '../utils/playground';

const log = createLogger('playground controller');
const transpiler = require('bson-transpilers');

interface ToCompile {
filter?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/collectionTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'util';
import util from 'util';
import * as vscode from 'vscode';
import path from 'path';
import type { DataService } from 'mongodb-data-service';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/databaseTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'util';
import util from 'util';
import * as vscode from 'vscode';
import path from 'path';

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/documentListTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import numeral from 'numeral';
import path from 'path';

import { createLogger } from '../logging';
import DocumentTreeItem from './documentTreeItem';
Expand All @@ -8,7 +9,6 @@ import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type { DataService } from 'mongodb-data-service';

const path = require('path');
const log = createLogger('documents tree item');

// We fetch 1 more than this in order to see if there are more to fetch.
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/helpTree.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as vscode from 'vscode';
import { openLink } from '../utils/linkHelper';
const path = require('path');
import path from 'path';

import { getImagesPath } from '../extensionConstants';
import { TelemetryService } from '../telemetry';
import { openLink } from '../utils/linkHelper';

const HELP_LINK_CONTEXT_VALUE = 'HELP_LINK';

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/indexListTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'util';
import util from 'util';
import * as vscode from 'vscode';
import { DataService } from 'mongodb-data-service';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/indexTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
const path = require('path');
import path from 'path';

import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/playgroundsTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import path = require('path');
import path from 'path';
import { getImagesPath } from '../extensionConstants';

export const PLAYGROUND_ITEM = 'playgroundsTreeItem';
Expand Down
2 changes: 1 addition & 1 deletion src/logging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger as ILogger } from 'ts-log';
import * as vscode from 'vscode';
import * as util from 'util';
import util from 'util';

class Logger implements ILogger {
static channel: vscode.OutputChannel =
Expand Down
1 change: 1 addition & 0 deletions src/telemetry/connectionTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ConnectionTypes } from '../connectionController';
import { createLogger } from '../logging';

const log = createLogger('connection telemetry helper');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require('../../package.json');

export type NewConnectionTelemetryEventProperties = {
Expand Down
3 changes: 2 additions & 1 deletion src/telemetry/telemetryService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'path';
import path from 'path';
import * as vscode from 'vscode';
import { config } from 'dotenv';
import { DataService } from 'mongodb-data-service';
Expand All @@ -14,6 +14,7 @@ import type { ShellEvaluateResult } from '../types/playgroundType';
import { StorageController } from '../storage';

const log = createLogger('telemetry');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require('../../package.json');

type PlaygroundTelemetryEventProperties = {
Expand Down
3 changes: 1 addition & 2 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path = require('path');

import path from 'path';
import { runTests } from '@vscode/test-electron';

// More information on vscode specific tests: https://github.com/microsoft/vscode-test
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/connectionController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sinon from 'sinon';
import type { SinonStub } from 'sinon';
import * as util from 'util';
import util from 'util';
import * as vscode from 'vscode';
import { afterEach, beforeEach } from 'mocha';
import assert from 'assert';
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/dbTestHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { connect, DataService } from 'mongodb-data-service';
import util from 'util';
import type { Document } from 'bson';
import * as util from 'util';

export const TEST_USER_USERNAME = 'testUser';
export const TEST_USER_PASSWORD = 'password';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'assert';
import { afterEach } from 'mocha';
import { ObjectId } from 'bson';
import sinon from 'sinon';
import * as util from 'util';
import util from 'util';

import ConnectionController from '../../../connectionController';
import { DocumentSource } from '../../../documentSource';
Expand Down
3 changes: 2 additions & 1 deletion src/test/suite/editors/playgroundController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sinon from 'sinon';
import type { SinonSpy, SinonStub } from 'sinon';
import { v4 as uuidv4 } from 'uuid';
import path from 'path';
import chaiAsPromised from 'chai-as-promised';

import ActiveDBCodeLensProvider from '../../../editors/activeConnectionCodeLensProvider';
import PlaygroundSelectedCodeActionProvider from '../../../editors/playgroundSelectedCodeActionProvider';
Expand All @@ -25,7 +26,7 @@ import { ExtensionContextStub, LanguageServerControllerStub } from '../stubs';

const expect = chai.expect;

chai.use(require('chai-as-promised'));
chai.use(chaiAsPromised);

suite('Playground Controller Test Suite', function () {
this.timeout(5000);
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/collectionTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CollectionTypes } from '../../../explorer/documentListTreeItem';
import { ext } from '../../../extensionConstants';
import { ExtensionContextStub, DataServiceStub } from '../stubs';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('CollectionTreeItem Test Suite', () => {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/connectionTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DataServiceStub } from '../stubs';
import formatError from '../../../utils/formatError';
import { mdbTestExtension } from '../stubbableMdbExtension';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('ConnectionTreeItem Test Suite', () => {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/databaseTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TEST_DATABASE_URI,
} from '../dbTestHelper';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('DatabaseTreeItem Test Suite', () => {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/documentListTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { before } from 'mocha';
import assert from 'assert';
import type { DataService } from 'mongodb-data-service';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

import DocumentListTreeItem, {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/fieldTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import SchemaTreeItem from '../../../explorer/schemaTreeItem';
import { ExtensionContextStub } from '../stubs';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('FieldTreeItem Test Suite', function () {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/explorer/indexListTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DataService } from 'mongodb-data-service';
import formatError from '../../../utils/formatError';
import IndexListTreeItem from '../../../explorer/indexListTreeItem';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('IndexListTreeItem Test Suite', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/explorer/playgroundsExplorer.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'assert';
import * as vscode from 'vscode';
import { before, afterEach } from 'mocha';
import * as path from 'path';
import path from 'path';
import { mdbTestExtension } from '../stubbableMdbExtension';
import PlaygroundsTree from './../../../explorer/playgroundsTree';

Expand Down
3 changes: 2 additions & 1 deletion src/test/suite/explorer/schemaTreeItem.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import * as sinon from 'sinon';
import sinon from 'sinon';
import { after, afterEach, before } from 'mocha';
import assert from 'assert';
import { inspect } from 'util';
Expand All @@ -21,6 +21,7 @@ import SchemaTreeItem, {
} from '../../../explorer/schemaTreeItem';
import { ExtensionContextStub } from '../stubs';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../../package.json');

suite('SchemaTreeItem Test Suite', function () {
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import assert from 'assert';
import * as vscode from 'vscode';
import EXTENSION_COMMANDS from '../../commands';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { contributes } = require('../../../package.json');

suite('Extension Test Suite', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Mocha from 'mocha';
import glob from 'glob';
import path = require('path');
import path from 'path';
import MDBExtensionController from '../../mdbExtensionController';
import { ext } from '../../extensionConstants';
import KeytarStub from './keytarStub';
Expand Down Expand Up @@ -33,7 +33,7 @@ export async function run(): Promise<void> {
await mdbTestExtension.testExtensionController.activate();

return new Promise((c, e) => {
glob(
void glob(
'**/**.test.js',
{
cwd: testsRoot,
Expand Down
3 changes: 2 additions & 1 deletion src/test/suite/language/languageServerController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fs from 'fs';
import path from 'path';
import sinon from 'sinon';
import type { DataService } from 'mongodb-data-service';
import chaiAsPromised from 'chai-as-promised';

import ActiveDBCodeLensProvider from '../../../editors/activeConnectionCodeLensProvider';
import PlaygroundSelectedCodeActionProvider from '../../../editors/playgroundSelectedCodeActionProvider';
Expand All @@ -24,7 +25,7 @@ import { ExtensionContextStub } from '../stubs';

const expect = chai.expect;

chai.use(require('chai-as-promised'));
chai.use(chaiAsPromised);

suite('Language Server Controller Test Suite', () => {
const extensionContextStub = new ExtensionContextStub();
Expand Down
3 changes: 2 additions & 1 deletion src/test/suite/playground.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode';
import { afterEach, beforeEach } from 'mocha';
import chai from 'chai';
import sinon from 'sinon';
import chaiAsPromised from 'chai-as-promised';

import { mdbTestExtension } from './stubbableMdbExtension';
import {
Expand All @@ -12,7 +13,7 @@ import {
} from './suggestTestHelpers';

const expect = chai.expect;
chai.use(require('chai-as-promised'));
chai.use(chaiAsPromised);

const TEST_DATABASE_URI = 'mongodb://localhost:27018';

Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/snippets/stageAutocompleter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as chai from 'chai';
import chaiFs = require('chai-fs');
import chaiJsonSchema = require('chai-json-schema');
import chaiFs from 'chai-fs';
import chaiJsonSchema from 'chai-json-schema';

chai.use(chaiFs);
chai.use(chaiJsonSchema);
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from 'vscode-languageclient/node';
import { LanguageClient, TransportKind } from 'vscode-languageclient/node';
import { Duplex } from 'stream';
import path = require('path');
import path from 'path';
import type { Document, Filter, FindOptions } from 'mongodb';

import { StorageController } from '../../storage';
Expand Down
Loading

0 comments on commit 50a3234

Please sign in to comment.