Skip to content

Commit

Permalink
Make new eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
burner1024 committed Jan 26, 2025
1 parent 187f77d commit 70a74e8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 25 deletions.
3 changes: 1 addition & 2 deletions client/src/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from "vscode";
import * as path from "path";
import * as vscode from "vscode";

export let doc: vscode.TextDocument;
export let editor: vscode.TextEditor;
Expand All @@ -16,7 +16,6 @@ export let platformEol: string;
*/
export async function activate(docUri: vscode.Uri) {
// The extensionId is `publisher.name` from package.json
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const ext = vscode.extensions.getExtension("bgforge.bgforge-mls")!;
await ext.activate();
try {
Expand Down
2 changes: 1 addition & 1 deletion client/src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error("Failed to run tests");
console.error(`Failed to run tests: ${err}`);
process.exit(1);
}
}
Expand Down
7 changes: 6 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import globals from "globals";

export default [
{
files: [
"client/src/*.ts",
"client/src/test/*.ts",
"server/src/**/*.ts",
"preview/src/**/*.ts",
],
ignores: [
"node_modules/**/*",
"client/node_modules/**/*",
Expand Down Expand Up @@ -35,7 +41,6 @@ export default [
},
],
"@typescript-eslint/no-explicit-any": "warn", // Warn when 'any' is used
"@typescript-eslint/explicit-function-return-type": "error", // Enforce return types for functions
"no-unused-vars": "error", // Disallow unused variables
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
"compile": "pnpm esbuild-client && pnpm esbuild-server",
"postinstall": "cd client && pnpm install && cd ../server && npm install -f && cd ../preview && pnpm install && cd ..",
"test": "sh ./scripts/e2e.sh",
"eslint": "eslint client/src/extension.ts && eslint client/src/test/*.ts && eslint server/src/*.ts && eslint preview/src/*.ts",
"eslint": "eslint client/src/*.ts --max-warnings 0 && eslint client/src/test/*.ts --max-warnings 0 && eslint server/src/*.ts --max-warnings 0 && eslint preview/src/*.ts --max-warnings 0",
"package": "pnpm vsce package --no-dependencies"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions preview/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const options = {
/* incremental layout options */

// Node repulsion (non overlapping) multiplier
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
nodeRepulsion: (node) => 4500,
// Ideal edge (non nested) length
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
idealEdgeLength: (edge) => 50,
// Divisor to compute edge forces
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
edgeElasticity: (edge) => 0.45,
// Nesting factor (multiplier) to compute ideal edge length for nested edges
nestingFactor: 0.1,
Expand Down
9 changes: 5 additions & 4 deletions server/src/fallout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cp from "child_process";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import { CompletionItemKind, ParameterInformation } from "vscode-languageserver";
import { MarkupKind } from "vscode-languageserver/node";
Expand All @@ -23,7 +24,6 @@ import { Edge, Node } from "./preview";
import { connection, documents } from "./server";
import { SSLsettings } from "./settings";
import * as signature from "./signature";
import * as os from "os";

interface FalloutHeaderData {
macros: Macros;
Expand All @@ -36,7 +36,7 @@ interface Procedure {
detail: string;
jsdoc?: jsdoc.JSdoc;
}
interface Procedures extends Array<Procedure> {}
interface Procedures extends Array<Procedure> { }
interface Macro {
label: string;
detail: string;
Expand All @@ -45,7 +45,7 @@ interface Macro {
firstline: string;
jsdoc?: jsdoc.JSdoc;
}
interface Macros extends Array<Macro> {}
interface Macros extends Array<Macro> { }

const tooltipLangId = "fallout-ssl-tooltip";
const sslExt = ".ssl";
Expand Down Expand Up @@ -668,7 +668,8 @@ export function getPreviewData(text: string) {
nodes.push(nodeItem);
}
if (body) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// Don't need body2
// eslint-disable-next-line no-unused-vars
for (const [name2, body2] of procs) {
const pattern = `\\b(${name2})\\b`;
const nameRegex = new RegExp(pattern, "g");
Expand Down
10 changes: 5 additions & 5 deletions server/src/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Language implements Language {

private reloadFileHover(oldHover: hover.HoverMapEx, fileHover: hover.HoverMapEx, uri: string) {
let newHover = new Map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
Array.from(oldHover).filter(([key, value]) => {
if (value.uri != uri) {
return true;
Expand All @@ -268,7 +268,7 @@ export class Language implements Language {
})
);
fileHover = new Map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
Array.from(fileHover).filter(([key, value]) => {
return !this.data.hover.static.has(key);
})
Expand All @@ -283,7 +283,7 @@ export class Language implements Language {
uri: string
) {
let newDefinition = new Map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
Array.from(oldDefinition).filter(([key, value]) => {
if (value.uri != uri) {
return true;
Expand All @@ -301,7 +301,7 @@ export class Language implements Language {
uri: string
) {
let newSignature = new Map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
Array.from(oldSignature).filter(([key, value]) => {
if (value.uri != uri) {
return true;
Expand All @@ -310,7 +310,7 @@ export class Language implements Language {
})
);
fileSignature = new Map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
Array.from(fileSignature).filter(([key, value]) => {
return !this.data.hover.static.has(key);
})
Expand Down
2 changes: 2 additions & 0 deletions server/src/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { HeaderData as LanguageHeaderData } from "./language";
export async function processHeaders(
headerFiles: string[],
headersDirectory: string,
// Func def is used
// eslint-disable-next-line no-unused-vars
func: (uri: string, text: string, filePath: string) => LanguageHeaderData,
external = false
) {
Expand Down
11 changes: 3 additions & 8 deletions server/src/tbaf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ function substituteVariables(callExpression: CallExpression, vars: varsContext)

// Check if the argument is a variable that we know
if (vars.has(argText)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const substitution = vars.get(argText)!;
// We explicitly check var.has. Eslint is wrong.

console.log(`Substituting variable: ${argText} -> ${substitution}`);
arg.replaceWithText(substitution);
}
Expand All @@ -185,8 +182,8 @@ function inlineFunction(callExpression: CallExpression, functionDeclarations: Fu
parameters.forEach((param, index) => {
const paramName = param.getName();
let argText = args[index]?.getText() || param.getInitializer()?.getText() || "undefined";
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (vars.has(argText)) argText = vars.get(argText)!; // We explicitly check var.has. Eslint is wrong.

if (vars.has(argText)) argText = vars.get(argText)!;
paramArgMap.set(paramName, argText);
});

Expand Down Expand Up @@ -265,9 +262,7 @@ function unrollForOfLoop(forOfStatement: ForOfStatement, vars: varsContext) {

// Resolve the array expression if it's a const variable
if (vars.has(arrayExpression)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
arrayExpression = vars.get(arrayExpression)!;
// We explicitly check var.has. Eslint is wrong.
}

console.log("Array Expression:", arrayExpression);
Expand Down Expand Up @@ -493,7 +488,7 @@ function unrollForLoop(forStatement: ForStatement, vars: varsContext) {

// Resolve initial value from context if it's a variable
if (vars.has(initialValue)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

initialValue = vars.get(initialValue)!;
// We explicitly check var.has. Eslint is wrong.
}
Expand Down

0 comments on commit 70a74e8

Please sign in to comment.