112 lines
2.8 KiB
JavaScript
112 lines
2.8 KiB
JavaScript
import tsParser from "@typescript-eslint/parser";
|
|
import tsPlugin from "@typescript-eslint/eslint-plugin";
|
|
import importPlugin from "eslint-plugin-import";
|
|
import unusedImports from "eslint-plugin-unused-imports";
|
|
|
|
export default [
|
|
{
|
|
files: ["**/*.ts", "**/*.tsx"],
|
|
plugins: {
|
|
"@typescript-eslint": tsPlugin,
|
|
import: importPlugin,
|
|
"unused-imports": unusedImports,
|
|
},
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
parserOptions: {
|
|
project: "./tsconfig.json",
|
|
ecmaVersion: "latest",
|
|
sourceType: "module",
|
|
},
|
|
},
|
|
rules: {
|
|
// Core rules - all as errors
|
|
"max-classes-per-file": ["error", 1],
|
|
"prefer-const": "error",
|
|
|
|
// TypeScript specific rules
|
|
"@typescript-eslint/no-floating-promises": "off",
|
|
|
|
// Import rules
|
|
"import/order": [
|
|
"error",
|
|
{
|
|
groups: [
|
|
"builtin",
|
|
"external",
|
|
"internal",
|
|
"parent",
|
|
"sibling",
|
|
"index",
|
|
],
|
|
"newlines-between": "always",
|
|
alphabetize: {
|
|
order: "asc",
|
|
caseInsensitive: true,
|
|
},
|
|
},
|
|
],
|
|
"import/no-default-export": "error",
|
|
|
|
// Unused code detection
|
|
"no-unused-vars": "off",
|
|
"@typescript-eslint/no-unused-vars": "off",
|
|
"unused-imports/no-unused-imports": "error",
|
|
"unused-imports/no-unused-vars": [
|
|
"error",
|
|
{
|
|
vars: "all",
|
|
varsIgnorePattern: "^_",
|
|
args: "after-used",
|
|
argsIgnorePattern: "^_",
|
|
},
|
|
],
|
|
|
|
// Turn off rules that might be too strict
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
|
|
// Allow console for CLI tool
|
|
"no-console": "off",
|
|
},
|
|
settings: {
|
|
"import/resolver": {
|
|
typescript: {
|
|
project: "./tsconfig.json",
|
|
},
|
|
node: true,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
// Allow default exports in specific files
|
|
files: ["src/index.ts", "*.config.js", "*.config.ts"],
|
|
rules: {
|
|
"import/no-default-export": "off",
|
|
},
|
|
},
|
|
{
|
|
// Test files can have different rules
|
|
files: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"],
|
|
rules: {
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
"unused-imports/no-unused-vars": "off",
|
|
"max-classes-per-file": "off",
|
|
},
|
|
},
|
|
{
|
|
ignores: [
|
|
"dist/**",
|
|
"node_modules/**",
|
|
"coverage/**",
|
|
"*.d.ts",
|
|
"src/__mocks__/**",
|
|
"jest.setup.ts",
|
|
"vitest.config.ts",
|
|
"*.config.js",
|
|
"*.config.ts",
|
|
],
|
|
},
|
|
];
|