test: enable strict TypeScript ESLint configuration

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
This commit is contained in:
Alfi Maulana 2025-06-23 11:05:50 +07:00
parent 54f1f8eb66
commit 09c0693d6c
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
5 changed files with 22 additions and 11 deletions

4
dist/action.mjs generated vendored
View File

@ -82,7 +82,7 @@ async function exec(command, args) {
resolve();
}
else {
reject(new Error(`Command exited with status code ${code}`));
reject(new Error(`Command exited with status code ${code.toString()}`));
}
});
});
@ -136,7 +136,7 @@ function parse(str) {
const args = [];
let match;
while ((match = regex.exec(str)) !== null) {
args.push(match[1] ?? match[2] ?? match[3] ?? match[4]);
args.push(match[1] || match[2] || match[3] || match[4]);
}
return args;
}

View File

@ -1,9 +1,20 @@
import eslint from "@eslint/js";
import { globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";
export default [
export default tseslint.config(
globalIgnores(["dist"]),
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{ ignores: ["dist"] },
];
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["eslint.config.js", "rollup.config.js"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
);

View File

@ -183,7 +183,7 @@ describe("get action context", () => {
const { getInput } = await import("gha-utils");
const { getContext } = await import("./context.js");
const inputs = testCase.inputs || {};
const inputs = testCase.inputs ?? {};
vi.mocked(getInput).mockImplementation((name) => inputs[name] ?? "");
expect(getContext()).toStrictEqual({

View File

@ -17,11 +17,11 @@ export async function exec(command: string, args: string[]): Promise<void> {
});
logCommand(proc.spawnfile, ...proc.spawnargs.splice(1));
proc.on("error", reject);
proc.on("close", (code) => {
proc.on("close", (code: number) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Command exited with status code ${code}`));
reject(new Error(`Command exited with status code ${code.toString()}`));
}
});
});

View File

@ -12,7 +12,7 @@ export function parse(str: string): string[] {
const args: string[] = [];
let match: RegExpExecArray | null;
while ((match = regex.exec(str)) !== null) {
args.push(match[1] ?? match[2] ?? match[3] ?? match[4]);
args.push(match[1] || match[2] || match[3] || match[4]);
}
return args;
}