Skip to content

Commit d949d93

Browse files
Apply strict eslint rule (#11389)
1 parent 44e2a0e commit d949d93

File tree

20 files changed

+37
-30
lines changed

20 files changed

+37
-30
lines changed

Extension/.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
22
"extends": [
33
"eslint:recommended",
4-
"plugin:@typescript-eslint/eslint-recommended"
5-
//"plugin:@typescript-eslint/strict", // I want to enable this. Lots of little changes will happen.
4+
"plugin:@typescript-eslint/eslint-recommended",
5+
"plugin:@typescript-eslint/strict",
66
],
77
"env": {
88
"browser": true,
@@ -59,6 +59,8 @@ module.exports = {
5959
}
6060
}
6161
],
62+
"@typescript-eslint/no-explicit-any": "off",
63+
"@typescript-eslint/no-extraneous-class": "off",
6264
"no-case-declarations": "off",
6365
"no-useless-escape": "off",
6466
"no-floating-decimal": "error",

Extension/.scripts/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export async function read(filename: string) {
152152
return content.toString();
153153
}
154154

155-
export async function readJson(filename: string, fallback?: {}): Promise<CommentJSONValue> {
155+
export async function readJson(filename: string, fallback = {}): Promise<CommentJSONValue> {
156156
try {
157157
return parse(await read(filename));
158158
} catch {

Extension/.scripts/generateOptionsSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function updateDefaults(object: any, defaults: any): any {
5656

5757
function refReplace(definitions: any, ref: any): any {
5858
// $ref is formatted as "#/definitions/ObjectName"
59-
const referenceStringArray: string[] = ref['$ref'].split('/');
59+
const referenceStringArray: string[] = ref.$ref.split('/');
6060

6161
// Getting "ObjectName"
6262
const referenceName: string = referenceStringArray[referenceStringArray.length - 1];
@@ -71,7 +71,7 @@ function refReplace(definitions: any, ref: any): any {
7171
ref = appendFieldsToObject(reference, ref);
7272

7373
// Remove $ref field
74-
delete ref['$ref'];
74+
delete ref.$ref;
7575

7676
return ref;
7777
}

Extension/src/Debugger/configurationProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
661661
const newSourceFileMapSource: string = util.resolveVariables(sourceFileMapSource, undefined);
662662
if (sourceFileMapSource !== newSourceFileMapSource) {
663663
message = "\t" + localize("replacing.sourcepath", "Replacing {0} '{1}' with '{2}'.", "sourcePath", sourceFileMapSource, newSourceFileMapSource);
664+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
664665
delete config.sourceFileMap[sourceFileMapSource];
665666
source = newSourceFileMapSource;
666667
}

Extension/src/LanguageServer/client.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,9 @@ enum SemanticTokenTypes {
461461

462462
enum SemanticTokenModifiers {
463463
// These are camelCase as the enum names are used directly as strings in our legend.
464-
// eslint-disable-next-line no-bitwise
465-
static = (1 << 0),
466-
// eslint-disable-next-line no-bitwise
467-
global = (1 << 1),
468-
// eslint-disable-next-line no-bitwise
469-
local = (1 << 2)
464+
static = 0b001,
465+
global = 0b010,
466+
local = 0b100
470467
}
471468

472469
interface IntelliSenseSetup {

Extension/src/LanguageServer/configurations.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ export class CppProperties {
494494
for (const [dep, execCmd] of nodeAddonMap) {
495495
if (dep in packageJson.dependencies) {
496496
try {
497-
let stdout: string | void = await util.execChildProcess(execCmd, rootPath);
497+
let stdout: string = await util.execChildProcess(execCmd, rootPath);
498498
if (!stdout) {
499499
continue;
500500
}
@@ -1413,12 +1413,12 @@ export class CppProperties {
14131413

14141414
// Remove disallowed variable overrides
14151415
if (this.configurationJson.env) {
1416-
delete this.configurationJson.env['workspaceRoot'];
1417-
delete this.configurationJson.env['workspaceFolder'];
1418-
delete this.configurationJson.env['workspaceFolderBasename'];
1419-
delete this.configurationJson.env['execPath'];
1420-
delete this.configurationJson.env['pathSeparator'];
1421-
delete this.configurationJson.env['default'];
1416+
delete this.configurationJson.env.workspaceRoot;
1417+
delete this.configurationJson.env.workspaceFolder;
1418+
delete this.configurationJson.env.workspaceFolderBasename;
1419+
delete this.configurationJson.env.execPath;
1420+
delete this.configurationJson.env.pathSeparator;
1421+
delete this.configurationJson.env.default;
14221422
}
14231423

14241424
// Warning: There is a chance that this is incorrect in the event that the c_cpp_properties.json file was created before

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class CppBuildTaskProvider implements TaskProvider {
138138
(path.basename(info.path) === "cl.exe") && compiler_condition(info));
139139
knownCompilers = knownCompilers.filter(info =>
140140
(info === cl_to_add) || (path.basename(info.path) !== "cl.exe" && compiler_condition(info)));
141-
knownCompilers.map<void>(info => {
141+
knownCompilers.forEach(info => {
142142
knownCompilerPathsSet.add(info.path);
143143
});
144144
}

Extension/src/LanguageServer/settingsTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class SettingsTracker {
4949
}
5050

5151
// Iterate through dotted "sub" settings.
52-
const collectSettingsRecursive = (key: string, val: Object, depth: number) => {
52+
const collectSettingsRecursive = (key: string, val: Record<string, any>, depth: number) => {
5353
if (depth > 4) {
5454
// Limit settings recursion to 4 dots (not counting the first one in: `C_Cpp.`)
5555
return;

Extension/src/SSH/sshCommandToConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function parseFlags(input: string[], entries: { [key: string]: string }): number
177177

178178
// eslint-disable-next-line no-constant-condition
179179
while (true) {
180-
const next: void | IParsedOption = parser.getopt();
180+
const next: IParsedOption | undefined = parser.getopt();
181181
if (!next) {
182182
break;
183183
}

Extension/src/Utility/Eventing/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export abstract class Emitter {
8484
* @param eventName - the string name of the event
8585
* @param options - options for the event trigger
8686
*/
87-
protected newEvent(eventName: string, options?: EventOptions): () => Promise<void | EventStatus>;
87+
protected newEvent(eventName: string, options?: EventOptions): () => Promise<undefined | EventStatus>;
8888

8989
/**
9090
* Creates a named event function for triggering events in an {@link Emitter}

0 commit comments

Comments
 (0)