Added @typescript-eslint/stylistic-type-checked preset with selective overrides for our deliberate choices: Preset Benefits: - 30+ battle-tested stylistic rules from the TypeScript ESLint team - Automatic maintenance and updates - Comprehensive coverage of TypeScript-specific patterns Targeted Overrides: - array-type: "array-simple" for better readability on complex types - consistent-generic-constructors: "type-annotation" to keep generics on left side - no-inferrable-types: "off" to avoid conflicts with typedef strictness - non-nullable-type-assertion-style: "off" to avoid conflicts with strict rules Manual Fixes Applied: - prefer-nullish-coalescing: library.ts, users.ts, users.spec.ts - prefer-optional-chain: users.ts - no-empty-function: logger.spec.ts, library.spec.ts - array-type: auto-fixed across multiple test files Zero ESLint violations remaining
110 lines
2.7 KiB
JavaScript
110 lines
2.7 KiB
JavaScript
import eslint from "@eslint/js";
|
|
import { defineConfig, globalIgnores } from "eslint/config";
|
|
import tseslint from "typescript-eslint";
|
|
|
|
export default defineConfig(
|
|
eslint.configs.recommended,
|
|
tseslint.configs.strictTypeChecked,
|
|
tseslint.configs.stylisticTypeChecked,
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
projectService: true,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
rules: {
|
|
"@typescript-eslint/consistent-type-imports": [
|
|
"error",
|
|
{
|
|
fixStyle: "inline-type-imports",
|
|
prefer: "type-imports",
|
|
},
|
|
],
|
|
|
|
"@typescript-eslint/explicit-function-return-type": [
|
|
"error",
|
|
{
|
|
allowDirectConstAssertionInArrowFunctions: true,
|
|
allowExpressions: false,
|
|
allowHigherOrderFunctions: true,
|
|
allowTypedFunctionExpressions: true,
|
|
},
|
|
],
|
|
|
|
"@typescript-eslint/no-explicit-any": "error",
|
|
|
|
"@typescript-eslint/typedef": [
|
|
"error",
|
|
{
|
|
arrayDestructuring: true,
|
|
arrowParameter: true,
|
|
memberVariableDeclaration: true,
|
|
objectDestructuring: true,
|
|
parameter: true,
|
|
propertyDeclaration: true,
|
|
variableDeclaration: true,
|
|
variableDeclarationIgnoreFunction: false,
|
|
},
|
|
],
|
|
|
|
"@typescript-eslint/naming-convention": [
|
|
"error",
|
|
{
|
|
selector: ["property"],
|
|
modifiers: ["requiresQuotes"],
|
|
format: null,
|
|
},
|
|
{
|
|
selector: "property",
|
|
format: ["camelCase", "PascalCase", "snake_case"],
|
|
},
|
|
{
|
|
selector: "default",
|
|
format: ["camelCase"],
|
|
},
|
|
{
|
|
selector: "variable",
|
|
format: ["camelCase", "UPPER_CASE", "PascalCase"],
|
|
},
|
|
{
|
|
selector: "typeLike",
|
|
format: ["PascalCase"],
|
|
},
|
|
{
|
|
selector: "import",
|
|
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
},
|
|
],
|
|
|
|
// conflicts with typedef strictness
|
|
"@typescript-eslint/no-inferrable-types": "off",
|
|
// conflicts with strict rules
|
|
"@typescript-eslint/non-nullable-type-assertion-style": "off",
|
|
|
|
// enforce array-simple for better readability on complex types
|
|
"@typescript-eslint/array-type": [
|
|
"error",
|
|
{
|
|
default: "array-simple",
|
|
readonly: "array-simple",
|
|
},
|
|
],
|
|
// keep generics on left side for consistency
|
|
"@typescript-eslint/consistent-generic-constructors": [
|
|
"error",
|
|
"type-annotation",
|
|
],
|
|
},
|
|
},
|
|
[
|
|
globalIgnores([
|
|
"**bundle.cjs",
|
|
"esbuild.ts",
|
|
"eslint.config.mjs",
|
|
"generated/**",
|
|
]),
|
|
],
|
|
);
|