Skip to content

chore(deps): update dependency eslint to v9 #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ jobs:
run: pnpm test:coverage
- name: codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ jobs:
- name: codecov # Perform after version publishing
if: steps.test.outcome == 'success'
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
77 changes: 77 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// @ts-check

import jsEslint from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginImportX from "eslint-plugin-import-x";
import * as tsEslint from "typescript-eslint";

export default tsEslint.config(
jsEslint.configs.recommended,
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
...tsEslint.configs.strictTypeChecked,
...tsEslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "*.mjs"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: [
"**/coverage",
"**/dist",
"**/esbuild.config.mjs",
"**/lib/__fixtures__/**/*.ts",
"**/jest.config.mjs",
"**/smoke-tests",
],
},
{
rules: {
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-floating-promises": [
"warn",
{ ignoreIIFE: true, ignoreVoid: false },
],
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNever: true,
allowNumber: true,
},
],
"import-x/no-named-as-default-member": "off",
"import-x/no-unresolved": "off",
"import-x/order": [
"warn",
{ "newlines-between": "always", alphabetize: { order: "asc" } },
],
"no-console": ["warn"],
},
},
{
files: ["**/*.spec.ts"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
},
},
{
files: ["**/*.js", "**/*.mjs"],
...tsEslint.configs.disableTypeChecked,
},
eslintConfigPrettier,
);
4 changes: 3 additions & 1 deletion lib/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe("TypeScriptLoader", () => {
try {
cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts"));
fail("Should fail to load invalid TS");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
expect(error?.name).toStrictEqual("TypeScriptCompileError");
}
Expand Down Expand Up @@ -72,6 +73,7 @@ describe("TypeScriptLoader", () => {
try {
await cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts"));
fail("Should fail to load invalid TS");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
expect(error?.name).toStrictEqual("TypeScriptCompileError");
}
Expand Down Expand Up @@ -104,7 +106,7 @@ describe("TypeScriptLoader", () => {

expect(() =>
cfg.load(path.resolve(fixturesPath, "invalid.fixture.ts")),
).toThrowError();
).toThrow();
});
});
});
8 changes: 5 additions & 3 deletions lib/loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ describe("TypeScriptLoader", () => {

it("should fail on parsing an invalid TS file", () => {
const filePath = path.resolve(fixturesPath, "invalid.fixture.ts");
expect(() => loader(filePath, readFixtureContent(filePath))).toThrowError();
expect((): unknown =>
loader(filePath, readFixtureContent(filePath)),
).toThrow();
});

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

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

loader = TypeScriptLoader();
});
Expand Down
5 changes: 3 additions & 2 deletions lib/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { TypeScriptCompileError } from "./typescript-compile-error.js";

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

// `default` is used when exporting using export default, some modules
// may still use `module.exports` or if in TS `export = `
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"check:types": "tsc -p tsconfig.json",
"format": "pnpm format:check --write",
"format:check": "prettier --check \"{**/*,*}.{js,cjs,mjs,ts}\"",
"lint": "eslint --ext \".js,.cjs,.mjs,.ts\" .",
"lint": "eslint",
"lint:fix": "pnpm lint --fix",
"release": "release-it",
"test": "jest",
Expand All @@ -58,19 +58,19 @@
"@swc/core": "^1.7.26",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.13",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"chalk": "^5.3.0",
"cosmiconfig": "^9.0.0",
"esbuild": "^0.24.0",
"eslint": "^8.57.1",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import-x": "^4.3.1",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"release-it": "^17.6.0",
"typescript": "^5.6.2"
"typescript": "^5.6.2",
"typescript-eslint": "^8.10.0"
},
"keywords": [
"cosmiconfig",
Expand Down
Loading