-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.js
More file actions
166 lines (150 loc) · 5.44 KB
/
Copy patheslint.config.js
File metadata and controls
166 lines (150 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { defineConfig } from "eslint/config";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default defineConfig([
// Base configuration for all files
{
extends: compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
),
plugins: {
"@typescript-eslint": typescriptEslint,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
parser: tsParser,
parserOptions: {
// Enable type-aware linting by pointing to the ESLint-specific tsconfig only
project: [
path.resolve(__dirname, "tsconfig.eslint.json")
],
tsconfigRootDir: __dirname,
sourceType: "module",
ecmaVersion: 2022
}
},
rules: {
// 'sort-imports': ['error', {
// ignoreCase: false,
// ignoreDeclarationSort: true, // don"t want to sort import lines, use eslint-plugin-import instead
// ignoreMemberSort: false,
// memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
// allowSeparatedGroups: true,
// }],
// Indent with 4 spaces (as warning to allow formatter to handle it)
"indent": ["warn", 4, {
"SwitchCase": 1,
"MemberExpression": 1,
"ObjectExpression": 1
}],
// Prefer double quotes but don't error
"quotes": ["warn", "double", {
"allowTemplateLiterals": true,
"avoidEscape": true
}],
// Additional recommended rules
"no-console": "warn",
"no-unused-vars": "off", // Use TypeScript version instead
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/no-unused-vars": ["warn", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}],
// Allow legacy files to use ts-nocheck pragmas without failing the build
"@typescript-eslint/ban-ts-comment": ["warn", {
"ts-nocheck": false
}],
// Downgrade a few noisy rules to warnings to allow legacy code to pass CI
"no-case-declarations": "warn",
"no-async-promise-executor": "warn",
"no-empty": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"no-useless-escape": "warn",
// Simplified naming conventions following modern TypeScript best practices
"@typescript-eslint/naming-convention": [
"warn",
// Classes should be PascalCase
{
selector: "class",
format: ["PascalCase"]
},
// Interfaces should be PascalCase (no I prefix - modern best practice)
{
selector: "interface",
format: ["PascalCase"]
},
// Type aliases should be PascalCase
{
selector: "typeAlias",
format: ["PascalCase"]
},
// Enums and enum members should be PascalCase
{
selector: "enum",
format: ["PascalCase"]
},
{
selector: "enumMember",
format: ["PascalCase", "UPPER_CASE"]
}
],
// Custom rules for imports
"@typescript-eslint/no-require-imports": ["warn", {
"allow": [
"path"
]
}],
// More relaxed line length
"max-len": ["warn", {
"code": 140,
"tabWidth": 4,
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}]
},
},
// Special configuration for test files
{
files: ["**/test/**/*.ts"],
rules: {
// Allow chai's expect expressions in tests
"@typescript-eslint/no-unused-expressions": "off"
}
},
// Special configuration for CLI files
{
files: ["**/cli/**/*.ts"],
rules: {
// Allow console.log in CLI applications
"no-console": "off"
}
},
// Special configuration for test files
{
ignores: [
"**/lib/src/pow/**", // This will ignore all files in the lib/src/pow directory and its subdirectories
]
}
]);