Skip to content

Commit 670c863

Browse files
committed
Autofix import/no-namespace
I'm leaving the rule turned off as it still has 100+ offenses that aren't autofixable.
1 parent 754fa67 commit 670c863

129 files changed

Lines changed: 1299 additions & 1381 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

extensions/ql-vscode/gulpfile.ts/appInsights.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as gulp from "gulp";
1+
import { src, dest } from "gulp";
22
// eslint-disable-next-line @typescript-eslint/no-var-requires
33
const replace = require("gulp-replace");
44

@@ -13,8 +13,7 @@ export function injectAppInsightsKey() {
1313
}
1414

1515
// replace the key
16-
return gulp
17-
.src(["out/telemetry.js"])
16+
return src(["out/telemetry.js"])
1817
.pipe(replace(/REPLACE-APP-INSIGHTS-KEY/, process.env.APP_INSIGHTS_KEY))
19-
.pipe(gulp.dest("out/"));
18+
.pipe(dest("out/"));
2019
}

extensions/ql-vscode/gulpfile.ts/deploy.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import * as fs from "fs-extra";
2-
import * as path from "path";
1+
import {
2+
copy,
3+
readFile,
4+
mkdirs,
5+
readdir,
6+
unlinkSync,
7+
remove,
8+
writeFile,
9+
} from "fs-extra";
10+
import { resolve, join } from "path";
311

412
export interface DeployedPackage {
513
distPath: string;
@@ -25,12 +33,9 @@ async function copyPackage(
2533
): Promise<void> {
2634
for (const file of packageFiles) {
2735
console.log(
28-
`copying ${path.resolve(sourcePath, file)} to ${path.resolve(
29-
destPath,
30-
file,
31-
)}`,
36+
`copying ${resolve(sourcePath, file)} to ${resolve(destPath, file)}`,
3237
);
33-
await fs.copy(path.resolve(sourcePath, file), path.resolve(destPath, file));
38+
await copy(resolve(sourcePath, file), resolve(destPath, file));
3439
}
3540
}
3641

@@ -39,13 +44,13 @@ export async function deployPackage(
3944
): Promise<DeployedPackage> {
4045
try {
4146
const packageJson: any = JSON.parse(
42-
await fs.readFile(packageJsonPath, "utf8"),
47+
await readFile(packageJsonPath, "utf8"),
4348
);
4449

4550
// Default to development build; use flag --release to indicate release build.
4651
const isDevBuild = !process.argv.includes("--release");
47-
const distDir = path.join(__dirname, "../../../dist");
48-
await fs.mkdirs(distDir);
52+
const distDir = join(__dirname, "../../../dist");
53+
await mkdirs(distDir);
4954

5055
if (isDevBuild) {
5156
// NOTE: rootPackage.name had better not have any regex metacharacters
@@ -54,11 +59,11 @@ export async function deployPackage(
5459
);
5560
// Dev package filenames are of the form
5661
// vscode-codeql-0.0.1-dev.2019.9.27.19.55.20.vsix
57-
(await fs.readdir(distDir))
62+
(await readdir(distDir))
5863
.filter((name) => name.match(oldDevBuildPattern))
5964
.map((build) => {
6065
console.log(`Deleting old dev build ${build}...`);
61-
fs.unlinkSync(path.join(distDir, build));
66+
unlinkSync(join(distDir, build));
6267
});
6368
const now = new Date();
6469
packageJson.version =
@@ -69,16 +74,16 @@ export async function deployPackage(
6974
`.${now.getUTCHours()}.${now.getUTCMinutes()}.${now.getUTCSeconds()}`;
7075
}
7176

72-
const distPath = path.join(distDir, packageJson.name);
73-
await fs.remove(distPath);
74-
await fs.mkdirs(distPath);
77+
const distPath = join(distDir, packageJson.name);
78+
await remove(distPath);
79+
await mkdirs(distPath);
7580

76-
await fs.writeFile(
77-
path.join(distPath, "package.json"),
81+
await writeFile(
82+
join(distPath, "package.json"),
7883
JSON.stringify(packageJson, null, 2),
7984
);
8085

81-
const sourcePath = path.join(__dirname, "..");
86+
const sourcePath = join(__dirname, "..");
8287
console.log(
8388
`Copying package '${packageJson.name}' and its dependencies to '${distPath}'...`,
8489
);

extensions/ql-vscode/gulpfile.ts/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import * as gulp from "gulp";
1+
import { series, parallel } from "gulp";
22
import { compileTypeScript, watchTypeScript, cleanOutput } from "./typescript";
33
import { compileTextMateGrammar } from "./textmate";
44
import { copyTestData, watchTestData } from "./tests";
55
import { compileView, watchView } from "./webpack";
66
import { packageExtension } from "./package";
77
import { injectAppInsightsKey } from "./appInsights";
88

9-
export const buildWithoutPackage = gulp.series(
9+
export const buildWithoutPackage = series(
1010
cleanOutput,
11-
gulp.parallel(
11+
parallel(
1212
compileTypeScript,
1313
compileTextMateGrammar,
1414
compileView,
@@ -27,7 +27,7 @@ export {
2727
injectAppInsightsKey,
2828
compileView,
2929
};
30-
export default gulp.series(
30+
export default series(
3131
buildWithoutPackage,
3232
injectAppInsightsKey,
3333
packageExtension,

extensions/ql-vscode/gulpfile.ts/package.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import * as path from "path";
1+
import { resolve } from "path";
22
import { deployPackage } from "./deploy";
3-
import * as childProcess from "child-process-promise";
3+
import { spawn } from "child-process-promise";
44

55
export async function packageExtension(): Promise<void> {
6-
const deployedPackage = await deployPackage(path.resolve("package.json"));
6+
const deployedPackage = await deployPackage(resolve("package.json"));
77
console.log(
88
`Packaging extension '${deployedPackage.name}@${deployedPackage.version}'...`,
99
);
1010
const args = [
1111
"package",
1212
"--out",
13-
path.resolve(
13+
resolve(
1414
deployedPackage.distPath,
1515
"..",
1616
`${deployedPackage.name}-${deployedPackage.version}.vsix`,
1717
),
1818
];
19-
const proc = childProcess.spawn("./node_modules/.bin/vsce", args, {
19+
const proc = spawn("./node_modules/.bin/vsce", args, {
2020
cwd: deployedPackage.distPath,
2121
});
2222
proc.childProcess.stdout!.on("data", (data) => {
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import * as gulp from "gulp";
1+
import { watch, src, dest } from "gulp";
22

33
export function copyTestData() {
44
return Promise.all([copyNoWorkspaceData(), copyCliIntegrationData()]);
55
}
66

77
export function watchTestData() {
8-
return gulp.watch(["src/vscode-tests/*/data/**/*"], copyTestData);
8+
return watch(["src/vscode-tests/*/data/**/*"], copyTestData);
99
}
1010

1111
function copyNoWorkspaceData() {
12-
return gulp
13-
.src("src/vscode-tests/no-workspace/data/**/*")
14-
.pipe(gulp.dest("out/vscode-tests/no-workspace/data"));
12+
return src("src/vscode-tests/no-workspace/data/**/*").pipe(
13+
dest("out/vscode-tests/no-workspace/data"),
14+
);
1515
}
1616

1717
function copyCliIntegrationData() {
18-
return gulp
19-
.src("src/vscode-tests/cli-integration/data/**/*")
20-
.pipe(gulp.dest("out/vscode-tests/cli-integration/data"));
18+
return src("src/vscode-tests/cli-integration/data/**/*").pipe(
19+
dest("out/vscode-tests/cli-integration/data"),
20+
);
2121
}

extensions/ql-vscode/gulpfile.ts/textmate.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as gulp from "gulp";
2-
import * as jsYaml from "js-yaml";
3-
import * as through from "through2";
1+
import { src, dest } from "gulp";
2+
import { load } from "js-yaml";
3+
import { obj } from "through2";
44
import * as PluginError from "plugin-error";
55
import * as Vinyl from "vinyl";
66

@@ -219,7 +219,7 @@ function transformFile(yaml: any) {
219219
}
220220

221221
export function transpileTextMateGrammar() {
222-
return through.obj(
222+
return obj(
223223
(
224224
file: Vinyl,
225225
_encoding: string,
@@ -230,7 +230,7 @@ export function transpileTextMateGrammar() {
230230
} else if (file.isBuffer()) {
231231
const buf: Buffer = file.contents;
232232
const yamlText: string = buf.toString("utf8");
233-
const jsonData: any = jsYaml.load(yamlText);
233+
const jsonData: any = load(yamlText);
234234
transformFile(jsonData);
235235

236236
file.contents = Buffer.from(JSON.stringify(jsonData, null, 2), "utf8");
@@ -247,8 +247,7 @@ export function transpileTextMateGrammar() {
247247
}
248248

249249
export function compileTextMateGrammar() {
250-
return gulp
251-
.src("syntaxes/*.tmLanguage.yml")
250+
return src("syntaxes/*.tmLanguage.yml")
252251
.pipe(transpileTextMateGrammar())
253-
.pipe(gulp.dest("out/syntaxes"));
252+
.pipe(dest("out/syntaxes"));
254253
}

extensions/ql-vscode/gulpfile.ts/typescript.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as colors from "ansi-colors";
2-
import * as gulp from "gulp";
3-
import * as sourcemaps from "gulp-sourcemaps";
1+
import { gray, red } from "ansi-colors";
2+
import { dest, watch } from "gulp";
3+
import { init, write } from "gulp-sourcemaps";
44
import * as ts from "gulp-typescript";
55
import * as del from "del";
66

@@ -10,9 +10,9 @@ function goodReporter(): ts.reporter.Reporter {
1010
if (error.tsFile) {
1111
console.log(
1212
"[" +
13-
colors.gray("gulp-typescript") +
13+
gray("gulp-typescript") +
1414
"] " +
15-
colors.red(
15+
red(
1616
error.fullFilename +
1717
"(" +
1818
(error.startPosition!.line + 1) +
@@ -46,17 +46,17 @@ export function cleanOutput() {
4646
export function compileTypeScript() {
4747
return tsProject
4848
.src()
49-
.pipe(sourcemaps.init())
49+
.pipe(init())
5050
.pipe(tsProject(goodReporter()))
5151
.pipe(
52-
sourcemaps.write(".", {
52+
write(".", {
5353
includeContent: false,
5454
sourceRoot: ".",
5555
}),
5656
)
57-
.pipe(gulp.dest("out"));
57+
.pipe(dest("out"));
5858
}
5959

6060
export function watchTypeScript() {
61-
gulp.watch("src/**/*.ts", compileTypeScript);
61+
watch("src/**/*.ts", compileTypeScript);
6262
}

extensions/ql-vscode/gulpfile.ts/webpack.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from "path";
1+
import { resolve } from "path";
22
import * as webpack from "webpack";
33
import * as MiniCssExtractPlugin from "mini-css-extract-plugin";
44

@@ -8,7 +8,7 @@ export const config: webpack.Configuration = {
88
webview: "./src/view/webview.tsx",
99
},
1010
output: {
11-
path: path.resolve(__dirname, "..", "out"),
11+
path: resolve(__dirname, "..", "out"),
1212
filename: "[name].js",
1313
},
1414
devtool: "inline-source-map",

extensions/ql-vscode/scripts/add-fields-to-scenarios.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* Usage: npx ts-node scripts/add-fields-to-scenarios.ts
1212
*/
1313

14-
import * as fs from "fs-extra";
15-
import * as path from "path";
14+
import { pathExists, readJson, writeJson } from "fs-extra";
15+
import { resolve, relative } from "path";
1616

1717
import { Octokit, type RestEndpointMethodTypes } from "@octokit/rest";
1818
import { throttling } from "@octokit/plugin-throttling";
@@ -23,11 +23,8 @@ import { isGetVariantAnalysisRequest } from "../src/mocks/gh-api-request";
2323
import { VariantAnalysis } from "../src/remote-queries/gh-api/variant-analysis";
2424
import { RepositoryWithMetadata } from "../src/remote-queries/gh-api/repository";
2525

26-
const extensionDirectory = path.resolve(__dirname, "..");
27-
const scenariosDirectory = path.resolve(
28-
extensionDirectory,
29-
"src/mocks/scenarios",
30-
);
26+
const extensionDirectory = resolve(__dirname, "..");
27+
const scenariosDirectory = resolve(extensionDirectory, "src/mocks/scenarios");
3128

3229
// Make sure we don't run into rate limits by automatically waiting until we can
3330
// make another request.
@@ -84,7 +81,7 @@ async function addFieldsToRepository(repository: RepositoryWithMetadata) {
8481
}
8582

8683
async function addFieldsToScenarios() {
87-
if (!(await fs.pathExists(scenariosDirectory))) {
84+
if (!(await pathExists(scenariosDirectory))) {
8885
console.error("Scenarios directory does not exist: " + scenariosDirectory);
8986
return;
9087
}
@@ -94,7 +91,7 @@ async function addFieldsToScenarios() {
9491
continue;
9592
}
9693

97-
const data: GitHubApiRequest = await fs.readJson(file);
94+
const data: GitHubApiRequest = await readJson(file);
9895

9996
if (!isGetVariantAnalysisRequest(data)) {
10097
continue;
@@ -104,9 +101,7 @@ async function addFieldsToScenarios() {
104101
continue;
105102
}
106103

107-
console.log(
108-
`Adding fields to '${path.relative(scenariosDirectory, file)}'`,
109-
);
104+
console.log(`Adding fields to '${relative(scenariosDirectory, file)}'`);
110105

111106
const variantAnalysis = data.response.body as VariantAnalysis;
112107

@@ -137,7 +132,7 @@ async function addFieldsToScenarios() {
137132
}
138133
}
139134

140-
await fs.writeJson(file, data, { spaces: 2 });
135+
await writeJson(file, data, { spaces: 2 });
141136
}
142137
}
143138

0 commit comments

Comments
 (0)