Skip to content

Commit c11aa72

Browse files
committed
Fix deps
1 parent 93ddef9 commit c11aa72

14 files changed

+148
-84
lines changed

.eslintignore

-4
This file was deleted.

.eslintrc.json

-65
This file was deleted.

eslint.config.mjs

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import jest from 'eslint-plugin-jest';
2+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
3+
import globals from 'globals';
4+
import tsParser from '@typescript-eslint/parser';
5+
import stylisticTypescript from '@stylistic/eslint-plugin-ts';
6+
import github from 'eslint-plugin-github';
7+
8+
export default [
9+
{
10+
ignores: ['dist/', 'lib/', 'node_modules/', 'jest.config.js'],
11+
files: ['**/*.ts']
12+
},
13+
...github.getFlatConfigs().typescript,
14+
{
15+
plugins: {
16+
jest,
17+
'@typescript-eslint': typescriptEslint,
18+
'@typescript-eslint-stylistic': stylisticTypescript
19+
},
20+
21+
languageOptions: {
22+
globals: {
23+
...globals.node,
24+
...jest.environments.globals.globals,
25+
BufferEncoding: 'readonly'
26+
},
27+
28+
parser: tsParser,
29+
ecmaVersion: 9,
30+
sourceType: 'module',
31+
32+
parserOptions: {
33+
project: './tsconfig.eslint.json'
34+
}
35+
},
36+
37+
rules: {
38+
'i18n-text/no-en': 'off',
39+
'eslint-comments/no-use': 'off',
40+
'import/no-namespace': 'off',
41+
'no-unused-vars': 'off',
42+
'no-shadow': 'off',
43+
'@typescript-eslint/no-unused-vars': 'error',
44+
'@typescript-eslint/no-shadow': 'error',
45+
46+
'@typescript-eslint/explicit-member-accessibility': [
47+
'error',
48+
{
49+
accessibility: 'no-public'
50+
}
51+
],
52+
53+
'@typescript-eslint/no-require-imports': 'error',
54+
'@typescript-eslint/array-type': 'error',
55+
'@typescript-eslint/await-thenable': 'error',
56+
'@typescript-eslint/ban-ts-comment': 'error',
57+
camelcase: 'off',
58+
'@typescript-eslint/consistent-type-assertions': 'error',
59+
60+
'@typescript-eslint/explicit-function-return-type': [
61+
'error',
62+
{
63+
allowExpressions: true
64+
}
65+
],
66+
67+
'@typescript-eslint-stylistic/func-call-spacing': ['error', 'never'],
68+
'@typescript-eslint/no-array-constructor': 'error',
69+
'@typescript-eslint/no-empty-interface': 'error',
70+
'@typescript-eslint/no-explicit-any': 'error',
71+
'@typescript-eslint/no-extraneous-class': 'error',
72+
'@typescript-eslint/no-for-in-array': 'error',
73+
'@typescript-eslint/no-inferrable-types': 'error',
74+
'@typescript-eslint/no-misused-new': 'error',
75+
'@typescript-eslint/no-namespace': 'error',
76+
'@typescript-eslint/no-non-null-assertion': 'warn',
77+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
78+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
79+
'@typescript-eslint/no-useless-constructor': 'error',
80+
'@typescript-eslint/no-var-requires': 'error',
81+
'@typescript-eslint/prefer-for-of': 'warn',
82+
'@typescript-eslint/prefer-function-type': 'warn',
83+
'@typescript-eslint/prefer-includes': 'error',
84+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
85+
'@typescript-eslint/promise-function-async': 'error',
86+
'@typescript-eslint/require-array-sort-compare': 'error',
87+
'@typescript-eslint/restrict-plus-operands': 'error',
88+
semi: 'error',
89+
'@typescript-eslint-stylistic/semi': ['error', 'always'],
90+
'@typescript-eslint-stylistic/type-annotation-spacing': 'error',
91+
'@typescript-eslint/unbound-method': 'error',
92+
'@typescript-eslint/return-await': ['error', 'always'],
93+
'sort-imports': 'error',
94+
'sort-keys': 'error',
95+
'no-restricted-imports': ['error', 'fs'],
96+
'no-return-await': 'off'
97+
}
98+
}
99+
];

package-lock.json

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "tsc --build --verbose",
88
"format": "prettier --write **/*.ts",
99
"format-check": "prettier --check **/*.ts",
10-
"lint": "eslint --ext .ts src/",
10+
"lint": "eslint src/",
1111
"package": "ncc build ./lib/index.js --license licenses.txt && node ./.github/scripts/append_license",
1212
"test": "jest",
1313
"test-ci": "jest --reporters='@matteoh2o1999/github-actions-jest-reporter' --ci",
@@ -38,6 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@matteoh2o1999/github-actions-jest-reporter": "^3.0.0",
41+
"@stylistic/eslint-plugin-ts": "^2.11.0",
4142
"@types/node": "^22.10.0",
4243
"@types/semver": "^7.5.8",
4344
"@typescript-eslint/parser": "^8.16.0",

src/__tests__/utils.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ describe('Utils', () => {
8585

8686
describe('readFile', () => {
8787
test('calls fs.promises.readFile', async () => {
88+
mockedFs.promises.readFile.mockResolvedValueOnce('string content');
8889
await utils.readFile('path');
8990

9091
expect(mockedFs.promises.readFile).toBeCalledTimes(1);

src/builder/__tests__/builder.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ describe('class Builder', () => {
301301

302302
try {
303303
await builder['prepareSources']();
304-
} catch (error) {
304+
} catch {
305305
/* nop */
306306
}
307307

@@ -316,7 +316,7 @@ describe('class Builder', () => {
316316

317317
try {
318318
await builder['prepareSources']();
319-
} catch (error) {
319+
} catch {
320320
/* nop */
321321
}
322322

@@ -331,7 +331,7 @@ describe('class Builder', () => {
331331

332332
try {
333333
await builder['prepareSources']();
334-
} catch (error) {
334+
} catch {
335335
/* nop */
336336
}
337337

src/builder/__tests__/darwin.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe.each(getTags())(
5454

5555
try {
5656
await builder.build();
57-
} catch (error) {
57+
} catch {
5858
/* nop */
5959
}
6060

src/builder/__tests__/linux.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe.each(getTags())(
5454

5555
try {
5656
await builder.build();
57-
} catch (error) {
57+
} catch {
5858
/* nop */
5959
}
6060

src/builder/__tests__/windows.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe.each(getTags())(
5858

5959
try {
6060
await builder.build();
61-
} catch (error) {
61+
} catch {
6262
/* nop */
6363
}
6464

src/builder/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default abstract class Builder {
173173
await exec.exec(`${pythonExecutable} -m pip install --upgrade pip`, [], {
174174
silent: true
175175
});
176-
} catch (error) {
176+
} catch {
177177
core.info('Ensurepip failed. Trying using get_pip.py...');
178178
const splitVersion = this.specificVersion.split('.');
179179
const version = parseInt(splitVersion[0]);

src/builder/windows.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export default class WindowsBuilder extends Builder {
306306
core.startGroup('Searching for msbuild.exe');
307307
try {
308308
await exec.exec('vswhere', [], {silent: true});
309-
} catch (error) {
309+
} catch {
310310
await exec.exec('choco install vswhere', [], {ignoreReturnCode: true});
311311
}
312312
let msBuildPath = '';
@@ -437,7 +437,7 @@ export default class WindowsBuilder extends Builder {
437437
`${ftpPythonUrl}/${this.specificVersion}/${exeName}`,
438438
path.join(this.path, exeName)
439439
);
440-
} catch (error) {
440+
} catch {
441441
installerPath = '';
442442
}
443443
if (!installerPath) {
@@ -447,7 +447,7 @@ export default class WindowsBuilder extends Builder {
447447
`${ftpPythonUrl}/${this.specificVersion}/${msiName}`,
448448
path.join(this.path, msiName)
449449
);
450-
} catch (error) {
450+
} catch {
451451
installerPath = '';
452452
}
453453
}

src/inputs.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function getCache(): Promise<boolean> {
123123
core.debug('Parsing cache behavior...');
124124
try {
125125
return core.getBooleanInput(InputNames.CACHE_BUILD);
126-
} catch (error) {
126+
} catch {
127127
throw new Error(
128128
`Expected boolean value for input "${
129129
InputNames.CACHE_BUILD
@@ -138,7 +138,7 @@ async function getCheckLatest(): Promise<boolean> {
138138
core.debug('Parsing check latest input');
139139
try {
140140
return core.getBooleanInput(InputNames.CHECK_LATEST);
141-
} catch (error) {
141+
} catch {
142142
throw new Error(
143143
`Expected boolean value for input "${
144144
InputNames.CHECK_LATEST
@@ -153,7 +153,7 @@ async function getAllowPrereleases(): Promise<boolean> {
153153
core.debug('Parsing allow prereleases input');
154154
try {
155155
return core.getBooleanInput(InputNames.PRERELEASES);
156-
} catch (error) {
156+
} catch {
157157
throw new Error(
158158
`Expected boolean value for input "${
159159
InputNames.PRERELEASES

src/utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ export async function readFile(
5353
const content = await fs.promises.readFile(path, options);
5454
if (content instanceof Buffer) {
5555
return content.toString();
56+
} else if (typeof content == 'string') {
57+
return content;
5658
}
57-
return content;
59+
throw new Error('Unreachable');
5860
}
5961

6062
export async function writeFile(

0 commit comments

Comments
 (0)