From e0ed9f71b82ae56ae4e475ce03dcfe7784c17f89 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 18 Jul 2018 10:52:35 -0400 Subject: [PATCH] tslint: Enable no-var-requires Rationale from the rule's page: AMD-style require([]) and CommonJS-style require("") statements are environment-specific and more difficult to statically analyze. ES2015-style imports are part of the JavaScript language specfication and recommended as the path going forward. TypeScript will compile them to environment-specific forms as needed. --- src/backend/mi2/mi2.ts | 2 +- test/index.ts | 2 +- tslint.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index d8d2879..116bfaa 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -8,7 +8,7 @@ import * as fs from "fs" import { posix } from "path" import * as nativePath from "path" const path = posix; -const Client = require("ssh2").Client; +import { Client } from "ssh2"; export function escape(str: string) { return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\""); diff --git a/test/index.ts b/test/index.ts index 93023b9..23a298b 100644 --- a/test/index.ts +++ b/test/index.ts @@ -10,7 +10,7 @@ // to report the results back to the caller. When the tests are finished, return // a possible error to the callback or null if none. -const testRunner = require('vscode/lib/testrunner'); +import * as testRunner from "vscode/lib/testrunner"; // You can directly control Mocha options by uncommenting the following lines // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info diff --git a/tslint.json b/tslint.json index 92c3442..cfab942 100644 --- a/tslint.json +++ b/tslint.json @@ -26,7 +26,6 @@ "no-shadowed-variable": false, "no-trailing-whitespace": false, "no-unnecessary-initializer": false, - "no-var-requires": false, "object-literal-shorthand": false, "object-literal-sort-keys": false, "one-line": false,