Skip to content

Commit f99a629

Browse files
chore: fix ESLint errors and type-check all files
- Add void operator to run() call to fix floating promise - Add eslint-disable comment for intentional non-Error throw test - Remove unnecessary conditionals in utils.ts - Create tsconfig.eslint.json for type-aware linting - Update lint:tsc to type-check all files including configs - Rename eslint.config.mjs to eslint.config.mts
1 parent 366bdaf commit f99a629

9 files changed

Lines changed: 33 additions & 38 deletions

File tree

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { fileURLToPath } from 'node:url';
22

3-
import { includeIgnoreFile } from '@eslint/compat';
4-
import eslint from '@eslint/js';
5-
import { defineConfig } from 'eslint/config';
3+
import js from '@eslint/js';
4+
import { defineConfig, includeIgnoreFile } from 'eslint/config';
65
import prettier from 'eslint-plugin-prettier';
76
import simpleImportSort from 'eslint-plugin-simple-import-sort';
87
import tsdoc from 'eslint-plugin-tsdoc';
@@ -23,17 +22,27 @@ export default defineConfig([
2322

2423
plugins: {
2524
'simple-import-sort': simpleImportSort,
26-
eslint,
25+
js,
2726
prettier,
2827
tsdoc,
2928
},
3029

31-
extends: [eslint.configs.recommended, tseslint.configs.recommended],
30+
extends: [
31+
js.configs.recommended,
32+
tseslint.configs.recommended,
33+
tseslint.configs.recommendedTypeChecked,
34+
tseslint.configs.strictTypeChecked,
35+
tseslint.configs.stylisticTypeChecked,
36+
],
3237

3338
languageOptions: {
3439
globals: {
3540
...globals.node,
36-
...globals.jest,
41+
...globals.vitest,
42+
},
43+
parserOptions: {
44+
project: ['tsconfig.eslint.json'],
45+
tsconfigRootDir: import.meta.dirname,
3746
},
3847
},
3948

package-lock.json

Lines changed: 0 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"clean": "rm -rf coverage dist",
1111
"lint": "eslint .",
1212
"lint:fix": "npm run lint -- --fix",
13-
"lint:tsc": "tsc --noEmit",
13+
"lint:tsc": "tsc -p tsconfig.eslint.json",
1414
"prepare": "husky",
1515
"test": "vitest run",
1616
"test:ci": "CI=true npm test -- --color --coverage",
@@ -24,7 +24,6 @@
2424
"devDependencies": {
2525
"@commitlint/cli": "21.0.2",
2626
"@commitlint/config-conventional": "21.0.2",
27-
"@eslint/compat": "2.1.0",
2827
"@eslint/eslintrc": "3.3.5",
2928
"@eslint/js": "10.0.1",
3029
"@types/node": "25.9.1",

src/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const platforms = ['darwin', 'win32', 'linux'];
3232
describe.each(platforms)('when platform is %s', (platform) => {
3333
beforeEach(() => {
3434
mockedOs.platform.mockReturnValue(platform as NodeJS.Platform);
35-
mockedOs.arch.mockReturnValue('arm64' as NodeJS.Architecture);
35+
mockedOs.arch.mockReturnValue('arm64');
3636

3737
mockedCore.getInput.mockImplementation((input) => {
3838
switch (input) {
@@ -92,6 +92,7 @@ describe('error', () => {
9292

9393
it('throws non-error', async () => {
9494
mockedCore.getInput.mockImplementationOnce(() => {
95+
// eslint-disable-next-line @typescript-eslint/only-throw-error
9596
throw 'string error';
9697
});
9798
await run();

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ export async function run() {
6464
}
6565
}
6666

67-
run();
67+
void run();

src/utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { getBinaryPath, getDownloadObject } from './utils.js';
1010
const platforms: NodeJS.Platform[] = ['darwin', 'linux', 'win32'];
1111
const architectures = ['arm', 'x32', 'x64'] as NodeJS.Architecture[];
1212

13-
const table = platforms.reduce(
13+
const table = platforms.reduce<[NodeJS.Platform, NodeJS.Architecture][]>(
1414
(testSuites, platform) => [
1515
...testSuites,
1616
...architectures.map(
1717
(arch) => [platform, arch] as [NodeJS.Platform, NodeJS.Architecture],
1818
),
1919
],
20-
[] as [NodeJS.Platform, NodeJS.Architecture][],
20+
[],
2121
);
2222

2323
describe('getDownloadObject', () => {

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum Architecture {
1717
* @returns - Return value in [arm, arm64, 386, amd64]
1818
*/
1919
function getArch(arch: NodeJS.Architecture) {
20-
return Architecture[arch as keyof typeof Architecture] || arch;
20+
return Architecture[arch as keyof typeof Architecture];
2121
}
2222

2323
enum Platform {
@@ -35,7 +35,7 @@ enum Platform {
3535
* @returns - Return value in [macOS, linux, windows]
3636
*/
3737
function getOS(os: NodeJS.Platform) {
38-
return Platform[os as keyof typeof Platform] || os;
38+
return Platform[os as keyof typeof Platform];
3939
}
4040

4141
/**
@@ -48,7 +48,7 @@ function getOS(os: NodeJS.Platform) {
4848
*/
4949
export function getDownloadObject(version: string) {
5050
const os = platform();
51-
const architecture = arch() as NodeJS.Architecture;
51+
const architecture = arch();
5252

5353
const filename = `gh_${version}_${getOS(os)}_${getArch(architecture)}`;
5454
const extension = os === 'win32' ? 'zip' : 'tar.gz';

tsconfig.eslint.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"skipLibCheck": true,
5+
"noEmit": true
6+
},
7+
"include": ["src", "*.config.ts", "*.config.mts", "eslint.config.mts"]
8+
}

0 commit comments

Comments
 (0)