Skip to content

Commit 8e46d2c

Browse files
authored
Merge pull request #134 from Codex-/renovate/major-eslint-monorepo
chore(deps): update dependency eslint to v9
2 parents ba4d502 + 95a3e23 commit 8e46d2c

File tree

9 files changed

+518
-380
lines changed

9 files changed

+518
-380
lines changed

.eslintrc.json

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ jobs:
6363
run: pnpm test:coverage
6464
- name: codecov
6565
uses: codecov/codecov-action@v4
66+
env:
67+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ jobs:
5353
- name: codecov # Perform after version publishing
5454
if: steps.test.outcome == 'success'
5555
uses: codecov/codecov-action@v4
56+
env:
57+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

eslint.config.mjs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// @ts-check
2+
3+
import jsEslint from "@eslint/js";
4+
import eslintConfigPrettier from "eslint-config-prettier";
5+
import eslintPluginImportX from "eslint-plugin-import-x";
6+
import * as tsEslint from "typescript-eslint";
7+
8+
export default tsEslint.config(
9+
jsEslint.configs.recommended,
10+
eslintPluginImportX.flatConfigs.recommended,
11+
eslintPluginImportX.flatConfigs.typescript,
12+
...tsEslint.configs.strictTypeChecked,
13+
...tsEslint.configs.stylisticTypeChecked,
14+
{
15+
languageOptions: {
16+
parserOptions: {
17+
projectService: {
18+
allowDefaultProject: ["*.js", "*.mjs"],
19+
},
20+
tsconfigRootDir: import.meta.dirname,
21+
},
22+
},
23+
},
24+
{
25+
ignores: [
26+
"**/coverage",
27+
"**/dist",
28+
"**/esbuild.config.mjs",
29+
"**/lib/__fixtures__/**/*.ts",
30+
"**/jest.config.mjs",
31+
"**/smoke-tests",
32+
],
33+
},
34+
{
35+
rules: {
36+
"@typescript-eslint/await-thenable": "warn",
37+
"@typescript-eslint/explicit-function-return-type": "warn",
38+
"@typescript-eslint/no-floating-promises": [
39+
"warn",
40+
{ ignoreIIFE: true, ignoreVoid: false },
41+
],
42+
"@typescript-eslint/no-unused-vars": [
43+
"warn",
44+
{ argsIgnorePattern: "^_" },
45+
],
46+
"@typescript-eslint/restrict-template-expressions": [
47+
"error",
48+
{
49+
allowNever: true,
50+
allowNumber: true,
51+
},
52+
],
53+
"import-x/no-named-as-default-member": "off",
54+
"import-x/no-unresolved": "off",
55+
"import-x/order": [
56+
"warn",
57+
{ "newlines-between": "always", alphabetize: { order: "asc" } },
58+
],
59+
"no-console": ["warn"],
60+
},
61+
},
62+
{
63+
files: ["**/*.spec.ts"],
64+
rules: {
65+
"@typescript-eslint/explicit-function-return-type": "off",
66+
"@typescript-eslint/no-non-null-assertion": "off",
67+
"@typescript-eslint/no-unsafe-argument": "off",
68+
"@typescript-eslint/no-unsafe-assignment": "off",
69+
"@typescript-eslint/no-unsafe-member-access": "off",
70+
},
71+
},
72+
{
73+
files: ["**/*.js", "**/*.mjs"],
74+
...tsEslint.configs.disableTypeChecked,
75+
},
76+
eslintConfigPrettier,
77+
);

lib/index.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe("TypeScriptLoader", () => {
4040
try {
4141
cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts"));
4242
fail("Should fail to load invalid TS");
43+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4344
} catch (error: any) {
4445
expect(error?.name).toStrictEqual("TypeScriptCompileError");
4546
}
@@ -72,6 +73,7 @@ describe("TypeScriptLoader", () => {
7273
try {
7374
await cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts"));
7475
fail("Should fail to load invalid TS");
76+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7577
} catch (error: any) {
7678
expect(error?.name).toStrictEqual("TypeScriptCompileError");
7779
}
@@ -104,7 +106,7 @@ describe("TypeScriptLoader", () => {
104106

105107
expect(() =>
106108
cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts")),
107-
).toThrowError();
109+
).toThrow();
108110
});
109111
});
110112
});

lib/loader.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ describe("TypeScriptLoader", () => {
3737

3838
it("should fail on parsing an invalid TS file", () => {
3939
const filePath = path.resolve(fixturesPath, "invalid.fixture.ts");
40-
expect(() => loader(filePath, readFixtureContent(filePath))).toThrowError();
40+
expect((): unknown =>
41+
loader(filePath, readFixtureContent(filePath)),
42+
).toThrow();
4143
});
4244

4345
it("should use the same instance of jiti across multiple calls", () => {
@@ -66,9 +68,9 @@ describe("TypeScriptLoader", () => {
6668

6769
beforeEach(() => {
6870
stub = jest.spyOn(jiti, "default").mockImplementation((() => () => {
69-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
71+
// eslint-disable-next-line @typescript-eslint/only-throw-error
7072
throw unknownError;
71-
}) as any);
73+
}) as never);
7274

7375
loader = TypeScriptLoader();
7476
});

lib/loader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { TypeScriptCompileError } from "./typescript-compile-error.js";
55

66
export function TypeScriptLoader(options?: JITIOptions): Loader {
77
const loader = jiti("", { interopDefault: true, ...options });
8-
return (path: string) => {
8+
return (path: string): unknown => {
99
try {
10-
const result = loader(path);
10+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11+
const result: { default?: unknown } = loader(path);
1112

1213
// `default` is used when exporting using export default, some modules
1314
// may still use `module.exports` or if in TS `export = `

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"check:types": "tsc -p tsconfig.json",
3838
"format": "pnpm format:check --write",
3939
"format:check": "prettier --check \"{**/*,*}.{js,cjs,mjs,ts}\"",
40-
"lint": "eslint --ext \".js,.cjs,.mjs,.ts\" .",
40+
"lint": "eslint",
4141
"lint:fix": "pnpm lint --fix",
4242
"release": "release-it",
4343
"test": "jest",
@@ -58,19 +58,19 @@
5858
"@swc/core": "^1.7.26",
5959
"@swc/jest": "^0.2.36",
6060
"@types/jest": "^29.5.13",
61-
"@typescript-eslint/eslint-plugin": "^7.18.0",
61+
"@typescript-eslint/eslint-plugin": "^8.10.0",
6262
"chalk": "^5.3.0",
6363
"cosmiconfig": "^9.0.0",
6464
"esbuild": "^0.24.0",
65-
"eslint": "^8.57.1",
66-
"eslint-config-airbnb-typescript": "^18.0.0",
65+
"eslint": "^9.13.0",
6766
"eslint-config-prettier": "^9.1.0",
68-
"eslint-plugin-import": "^2.30.0",
69-
"eslint-plugin-prettier": "^5.2.1",
67+
"eslint-import-resolver-typescript": "^3.6.3",
68+
"eslint-plugin-import-x": "^4.3.1",
7069
"jest": "^29.7.0",
7170
"prettier": "^3.3.3",
7271
"release-it": "^17.6.0",
73-
"typescript": "^5.6.2"
72+
"typescript": "^5.6.2",
73+
"typescript-eslint": "^8.10.0"
7474
},
7575
"keywords": [
7676
"cosmiconfig",

0 commit comments

Comments
 (0)