eslint.config.mjs•2.25 kB
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import globals from "globals";
export default tseslint.config(
// Ignore non-source files
{ ignores: ["dist/**", "node_modules/**", "eslint.config.mjs"] },
// Recommended TS rules (non-type-aware) for all TS
...tseslint.configs.recommended,
// Apply type-aware rules only to src/**/*
...tseslint.configs.recommendedTypeChecked.map((c) => ({
...c,
files: ["src/**/*.ts"],
})),
// Project-specific settings and rules for source files (type-aware)
{
files: ["src/**/*.ts"],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.node,
...globals.es2022,
},
},
rules: {
"@typescript-eslint/no-misused-promises": [
"error",
{ checksVoidReturn: { attributes: false } },
],
// Relax overly strict rules to establish a clean baseline in source too
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
},
},
// Looser rules for tests and scripts (no type-aware requirements)
{
files: ["test/**/*.ts", "scripts/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
},
},
// Disable formatting rules in favor of Prettier
eslintConfigPrettier,
);