Skip to content

Commit b45c67f

Browse files
committed
Autofix prefer-template
1 parent 30cf72b commit b45c67f

40 files changed

Lines changed: 97 additions & 117 deletions

extensions/ql-vscode/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ module.exports = {
6666
"no-fallthrough": "off",
6767
"no-console": "off",
6868
"no-shadow": "off",
69-
"prefer-template": "off",
7069
"github/array-foreach": "off",
7170
"github/no-then": "off",
7271
},

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function deployPackage(
5555
if (isDevBuild) {
5656
// NOTE: rootPackage.name had better not have any regex metacharacters
5757
const oldDevBuildPattern = new RegExp(
58-
"^" + packageJson.name + "[^/]+-dev[0-9.]+\\.vsix$",
58+
`^${packageJson.name}[^/]+-dev[0-9.]+\\.vsix$`,
5959
);
6060
// Dev package filenames are of the form
6161
// vscode-codeql-0.0.1-dev.2019.9.27.19.55.20.vsix
@@ -67,8 +67,7 @@ export async function deployPackage(
6767
});
6868
const now = new Date();
6969
packageJson.version =
70-
packageJson.version +
71-
`-dev.${now.getUTCFullYear()}.${
70+
`${packageJson.version}-dev.${now.getUTCFullYear()}.${
7271
now.getUTCMonth() + 1
7372
}.${now.getUTCDate()}` +
7473
`.${now.getUTCHours()}.${now.getUTCMinutes()}.${now.getUTCSeconds()}`;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ function getNodeMatchText(rule: any): string {
6161
for (const patternIndex in rule.patterns) {
6262
const pattern = rule.patterns[patternIndex];
6363
if (pattern.include !== null) {
64-
patterns.push("(?" + pattern.include + ")");
64+
patterns.push(`(?${pattern.include})`);
6565
}
6666
}
6767

68-
return "(?:" + patterns.join("|") + ")";
68+
return `(?:${patterns.join("|")})`;
6969
} else {
7070
return "";
7171
}
@@ -149,8 +149,8 @@ function visitAllMatchesInRule(rule: any, action: (match: any) => any) {
149149
* @param key Base key of the property to be transformed.
150150
*/
151151
function expandPatternMatchProperties(rule: any, key: "begin" | "end") {
152-
const patternKey = key + "Pattern";
153-
const capturesKey = key + "Captures";
152+
const patternKey = `${key}Pattern`;
153+
const capturesKey = `${key}Captures`;
154154
const pattern = rule[patternKey];
155155
if (pattern !== undefined) {
156156
const patterns: string[] = Array.isArray(pattern) ? pattern : [pattern];
@@ -207,7 +207,7 @@ function transformFile(yaml: any) {
207207
});
208208

209209
if (yaml.regexOptions !== undefined) {
210-
const regexOptions = "(?" + yaml.regexOptions + ")";
210+
const regexOptions = `(?${yaml.regexOptions})`;
211211
visitAllRulesInFile(yaml, (rule) => {
212212
visitAllMatchesInRule(rule, (match) => {
213213
return regexOptions + match;

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,16 @@ function goodReporter(): ts.reporter.Reporter {
99
error: (error, typescript) => {
1010
if (error.tsFile) {
1111
console.log(
12-
"[" +
13-
gray("gulp-typescript") +
14-
"] " +
15-
red(
16-
error.fullFilename +
17-
"(" +
18-
(error.startPosition!.line + 1) +
19-
"," +
20-
error.startPosition!.character +
21-
"): ",
22-
) +
23-
"error TS" +
24-
error.diagnostic.code +
25-
": " +
26-
typescript.flattenDiagnosticMessageText(
27-
error.diagnostic.messageText,
28-
"\n",
29-
),
12+
`[${gray("gulp-typescript")}] ${red(
13+
`${error.fullFilename}(${error.startPosition!.line + 1},${
14+
error.startPosition!.character
15+
}): `,
16+
)}error TS${
17+
error.diagnostic.code
18+
}: ${typescript.flattenDiagnosticMessageText(
19+
error.diagnostic.messageText,
20+
"\n",
21+
)}`,
3022
);
3123
} else {
3224
console.log(error.message);
@@ -39,7 +31,7 @@ const tsProject = ts.createProject("tsconfig.json");
3931

4032
export function cleanOutput() {
4133
return tsProject.projectDirectory
42-
? del(tsProject.projectDirectory + "/out/*")
34+
? del(`${tsProject.projectDirectory}/out/*`)
4335
: Promise.resolve();
4436
}
4537

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function addFieldsToRepository(repository: RepositoryWithMetadata) {
8282

8383
async function addFieldsToScenarios() {
8484
if (!(await pathExists(scenariosDirectory))) {
85-
console.error("Scenarios directory does not exist: " + scenariosDirectory);
85+
console.error(`Scenarios directory does not exist: ${scenariosDirectory}`);
8686
return;
8787
}
8888

extensions/ql-vscode/scripts/fix-scenario-file-numbering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const scenarioDirectory = resolve(scenariosDirectory, scenarioName);
2626
async function fixScenarioFiles() {
2727
console.log(scenarioDirectory);
2828
if (!(await pathExists(scenarioDirectory))) {
29-
console.error("Scenario directory does not exist: " + scenarioDirectory);
29+
console.error(`Scenario directory does not exist: ${scenarioDirectory}`);
3030
return;
3131
}
3232

extensions/ql-vscode/scripts/lint-scenarios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ async function lintScenarios() {
2525
const ajv = new Ajv();
2626

2727
if (!ajv.validateSchema(schema)) {
28-
throw new Error("Invalid schema: " + ajv.errorsText());
28+
throw new Error(`Invalid schema: ${ajv.errorsText()}`);
2929
}
3030

3131
const validate = await ajv.compile(schema);
3232

3333
let invalidFiles = 0;
3434

3535
if (!(await pathExists(scenariosDirectory))) {
36-
console.error("Scenarios directory does not exist: " + scenariosDirectory);
36+
console.error(`Scenarios directory does not exist: ${scenariosDirectory}`);
3737
// Do not exit with a non-zero status code, as this is not a fatal error.
3838
return;
3939
}

extensions/ql-vscode/src/archive-filesystem-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function encodeSourceArchiveUri(ref: ZipFileReference): vscode.Uri {
7575
if (encodedPath.startsWith("/")) {
7676
sourceArchiveZipPathStartIndex = 0;
7777
} else {
78-
encodedPath = "/" + encodedPath;
78+
encodedPath = `/${encodedPath}`;
7979
sourceArchiveZipPathStartIndex = 1;
8080
}
8181

@@ -85,7 +85,7 @@ export function encodeSourceArchiveUri(ref: ZipFileReference): vscode.Uri {
8585
const sourceArchiveZipPathEndIndex =
8686
sourceArchiveZipPathStartIndex + sourceArchiveZipPath.length;
8787
const authority = `${sourceArchiveZipPathStartIndex}-${sourceArchiveZipPathEndIndex}`;
88-
return vscode.Uri.parse(zipArchiveScheme + ":/", true).with({
88+
return vscode.Uri.parse(`${zipArchiveScheme}:/`, true).with({
8989
path: encodedPath,
9090
authority,
9191
});

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,7 @@ export class CodeQLCliServer implements Disposable {
930930
const additionalArgs = sourceInfo
931931
? [
932932
"--dot-location-url-format",
933-
"file://" +
934-
sourceInfo.sourceLocationPrefix +
935-
"{path}:{start:line}:{start:column}:{end:line}:{end:column}",
933+
`file://${sourceInfo.sourceLocationPrefix}{path}:{start:line}:{start:column}:{end:line}:{end:column}`,
936934
]
937935
: [];
938936

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ async function promptForLanguage(
753753
*/
754754
async function ensureZippedSourceLocation(databasePath: string): Promise<void> {
755755
const srcFolderPath = join(databasePath, "src");
756-
const srcZipPath = srcFolderPath + ".zip";
756+
const srcZipPath = `${srcFolderPath}.zip`;
757757

758758
if ((await pathExists(srcFolderPath)) && !(await pathExists(srcZipPath))) {
759759
await zip(srcFolderPath, srcZipPath);

0 commit comments

Comments
 (0)