-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
101 lines (95 loc) · 3.41 KB
/
eslint.config.mjs
File metadata and controls
101 lines (95 loc) · 3.41 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
// eslint.config.js
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
import { defineConfig } from 'eslint/config';
export default defineConfig([
// --- 1. Global Ignores ---
// Files and directories to ignore across the entire project
{
ignores: [
'out/**',
'dist/**',
'**/*.d.ts',
'node_modules/**',
'.vscode-test/**',
'.vscode-test.mjs',
'eslint.config.mjs',
],
},
// --- 2. Base Configurations (Applied to ALL files by default) ---
// Recommended JavaScript rules
js.configs.recommended,
// Recommended TypeScript rules from typescript-eslint
// This automatically sets up the parser and disables conflicting JS rules.
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked, // Adds stylistic TypeScript rules (e.g., consistent-type-imports)
// Disables ESLint rules that might conflict with Prettier
// Always put this last in the base configs to ensure it overrides others.
prettierConfig,
// weird thing to do, but it works
{
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
// --- 3. Configuration for VS Code Extension (Node.js/TypeScript) ---
{
files: ['src/**/*.ts'], // Only apply to your extension's TypeScript files
// Specific language options for this part of the project
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
// Define global variables for the Node.js environment
globals: {
...globals.node,
// Add any other specific globals for your extension if needed
},
// Specify the TypeScript parser for these files
parser: tseslint.parser,
// Configuration for the TypeScript parser, crucial for type-aware linting
parserOptions: {
// project: ['./tsconfig.json'], // Path to your main tsconfig.json
tsconfigRootDir: import.meta.dirname, // Helps resolve relative paths correctly
projectService: true,
},
},
// Specific rules for your extension's TypeScript files
rules: {
// You can override or add rules here.
// Example: 'warn' level for specific TypeScript rules
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'import',
format: ['camelCase', 'PascalCase'],
},
],
curly: 'warn', // Require curly braces for all control statements
eqeqeq: 'warn', // Require the use of '===' and '!=='
'no-throw-literal': 'warn', // Disallow throwing literals as exceptions
semi: 'off', // Let Prettier handle semicolons (or enforce no semicolons)
'@typescript-eslint/no-floating-promises': 'error', // Good for async operations
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true,
allowHigherOrderFunctions: true,
allowTypedFunctionExpressions: true,
allowDirectConstAssertionInArrowFunctions: true,
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_', // Ignore unused arguments starting with _
varsIgnorePattern: '^_', // Ignore unused variables starting with _
},
],
'@typescript-eslint/no-explicit-any': 'off', // Or 'warn' depending on your preference
},
},
]);