131 lines
4.1 KiB
JavaScript
131 lines
4.1 KiB
JavaScript
import eslint from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import eslintPluginPrettier from "eslint-plugin-prettier";
|
|
import eslintPluginImport from "eslint-plugin-import";
|
|
import globals from "globals";
|
|
import prettierConfig from "eslint-config-prettier";
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores: [
|
|
"dist/**",
|
|
"node_modules/**",
|
|
"jest.config.js",
|
|
"coverage/**",
|
|
"database/migrations/**",
|
|
"pnpm-lock.yaml",
|
|
".prettierrc.js",
|
|
"commitlint.config.ts",
|
|
"eslint.config.mjs",
|
|
],
|
|
},
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
prettierConfig,
|
|
// Base configuration for all TypeScript files
|
|
{
|
|
files: ["**/*.ts"],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
...globals.jest,
|
|
},
|
|
ecmaVersion: 2022,
|
|
sourceType: "module",
|
|
parser: tseslint.parser,
|
|
parserOptions: {
|
|
projectService: true,
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
plugins: {
|
|
"@typescript-eslint": tseslint.plugin,
|
|
prettier: eslintPluginPrettier,
|
|
import: eslintPluginImport,
|
|
},
|
|
rules: {
|
|
// Import rules
|
|
"sort-imports": [
|
|
"error",
|
|
{
|
|
ignoreCase: false,
|
|
ignoreDeclarationSort: true,
|
|
ignoreMemberSort: false,
|
|
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
|
|
allowSeparatedGroups: true,
|
|
},
|
|
],
|
|
"import/order": [
|
|
"error",
|
|
{
|
|
groups: ["builtin", "external", "internal", ["sibling", "parent"], "index", "unknown"],
|
|
"newlines-between": "always",
|
|
alphabetize: {
|
|
order: "asc",
|
|
caseInsensitive: true,
|
|
},
|
|
},
|
|
],
|
|
|
|
// JavaScript Rules
|
|
"no-var": "error",
|
|
"prefer-const": "error",
|
|
"no-multi-spaces": "error",
|
|
"space-in-parens": "error",
|
|
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 0 }],
|
|
semi: ["error", "always"],
|
|
|
|
// Best Practices
|
|
"no-async-promise-executor": "warn",
|
|
"no-control-regex": "warn",
|
|
"no-empty": ["warn", { allowEmptyCatch: true }],
|
|
"no-extra-semi": "warn",
|
|
"no-prototype-builtins": "warn",
|
|
"no-regex-spaces": "warn",
|
|
"prefer-rest-params": "warn",
|
|
"prefer-spread": "warn",
|
|
|
|
// TypeScript-Specific Rules that don't need type information
|
|
"@typescript-eslint/ban-ts-comment": "warn",
|
|
"@typescript-eslint/no-explicit-any": "warn",
|
|
"@typescript-eslint/no-loss-of-precision": "warn",
|
|
"@typescript-eslint/no-misused-new": "warn",
|
|
"@typescript-eslint/no-namespace": "warn",
|
|
"@typescript-eslint/no-this-alias": "warn",
|
|
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
|
|
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{
|
|
argsIgnorePattern: "^_",
|
|
varsIgnorePattern: "^_",
|
|
caughtErrorsIgnorePattern: "^_",
|
|
ignoreRestSiblings: true,
|
|
},
|
|
],
|
|
"@typescript-eslint/no-var-requires": "warn",
|
|
"@typescript-eslint/triple-slash-reference": "warn",
|
|
},
|
|
},
|
|
// Additional configuration for type-checked files - disabled for now
|
|
{
|
|
files: ["**/*.ts"],
|
|
// Disable type-aware linting until we can configure it properly
|
|
rules: {
|
|
"@typescript-eslint/await-thenable": "off",
|
|
"@typescript-eslint/no-floating-promises": "off",
|
|
"@typescript-eslint/no-misused-promises": "off",
|
|
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
"@typescript-eslint/no-unsafe-return": "off",
|
|
"@typescript-eslint/require-await": "off",
|
|
"@typescript-eslint/restrict-plus-operands": "off",
|
|
"@typescript-eslint/restrict-template-expressions": "off",
|
|
"@typescript-eslint/unbound-method": "off",
|
|
},
|
|
},
|
|
);
|