Skip to content
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

upgrade Eslint to version 9 and migrated the Eslint config #18

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 0 additions & 32 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx commitlint --edit $1
npx --no -- commitlint --edit \$1
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npm test
63 changes: 63 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsdoc from "eslint-plugin-tsdoc";
import _import from "eslint-plugin-import";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

// eslint-disable-next-line import/no-default-export
export default [
...fixupConfigRules(
compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
"plugin:@limegrass/import-alias/recommended",
),
),
{
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
tsdoc,
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.node,
},

parser: tsParser,
},

settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts"],
},

"import/resolver": {
typescript: {},
},
},

rules: {
"import/no-default-export": "error",
"tsdoc/syntax": "warn",
},
},
];
16 changes: 7 additions & 9 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import { Config } from "@jest/types";
const config: Config.InitialOptions = {
roots: ["<rootDir>/tests"],
testMatch: ["<rootDir>/tests/**/*.test.ts"],
preset: "ts-jest",
testEnvironment: "node",
transform: {
"^.+\\.(js|ts)$": "ts-jest",
"^.+\\.(js|ts)$": ["ts-jest", {
isolatedModules: true,
diagnostics: false,
}],
},
moduleNameMapper: {
"#src/(.*)": "<rootDir>/src/$1",
"#root/(.*)": "<rootDir>/$1",
},
moduleFileExtensions: ["js", "ts"],
globals: {
"ts-jest": {
isolatedModules: true,
diagnostics: false,
},
},
};

export = config;
// eslint-disable-next-line import/no-default-export
export default config;
Loading