eslint.config.cjs•3.74 kB
const eslint = require("@eslint/js")
const tseslint = require("@typescript-eslint/eslint-plugin")
const tsParser = require("@typescript-eslint/parser")
const prettierConfig = require("eslint-config-prettier")
const prettierPlugin = require("eslint-plugin-prettier")
module.exports = [
{
...eslint.configs.recommended,
languageOptions: {
globals: {
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
exports: "writable",
module: "writable",
require: "readonly",
global: "readonly",
URL: "readonly",
fetch: "readonly",
},
},
},
prettierConfig,
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
project: "./tsconfig.json",
},
globals: {
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
exports: "writable",
module: "writable",
require: "readonly",
global: "readonly",
URL: "readonly",
fetch: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/prefer-promise-reject-errors": "warn",
"no-console": "off",
"no-regex-spaces": "off",
},
},
{
// Test files - allow any types for mocking
files: ["**/__tests__/**/*.{ts,tsx}", "**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
project: "./tsconfig.json",
},
},
plugins: {
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
// Disable any-related rules for test files since mocks legitimately need any
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-promise-reject-errors": "warn",
"no-console": "off",
"no-regex-spaces": "off",
},
},
{
ignores: ["node_modules/**", "dist/**", "build/**", "*.config.js", "*.config.ts"],
},
]