-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
132 lines (122 loc) · 4 KB
/
eslint.config.js
File metadata and controls
132 lines (122 loc) · 4 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
// ESLint flat config for TypeScript project
const tsParser = require('@typescript-eslint/parser');
const tsPlugin = require('@typescript-eslint/eslint-plugin');
const globals = require('globals');
// Additional plugins
const importPlugin = require('eslint-plugin-import');
const promisePlugin = require('eslint-plugin-promise');
const nPlugin = require('eslint-plugin-n');
const jestPlugin = require('eslint-plugin-jest');
module.exports = [
// Ignore build artifacts and generated code
{
ignores: [
'dist/**',
'src/api/**',
'node_modules/**',
'scripts/generator/protos/**',
'scripts/generator/nebius/**',
'scripts/generator/extensions/**',
'nebius-api/**',
],
},
// TypeScript files
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
globals: {
...globals.node,
...globals.es2021,
...globals.jest,
},
},
// Settings for plugins
settings: {
// Let eslint-plugin-import resolve TS paths via tsconfig
'import/resolver': {
typescript: {
project: ['./tsconfig.json', './tsconfig.scripts.json'],
},
},
// Extensions to consider for Node resolution (used by eslint-plugin-n)
n: {
tryExtensions: ['.ts', '.tsx', '.js', '.json', '.node'],
},
},
plugins: {
'@typescript-eslint': tsPlugin,
import: importPlugin,
promise: promisePlugin,
n: nPlugin,
jest: jestPlugin,
// prettier formatting handled by Prettier directly; eslint-plugin-prettier removed to avoid conflicts
},
rules: {
// Ignore unused caught error variables in try/catch, allow underscore-args
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', caughtErrors: 'none' },
],
'@typescript-eslint/explicit-function-return-type': 'off',
// Keep as a warning by default; will be disabled in specific folders below
'@typescript-eslint/no-explicit-any': 'warn',
// Approximate "lll" (long line linter)
'max-len': [
'warn',
{ code: 120, ignoreUrls: true, ignoreStrings: true, ignoreTemplateLiterals: true },
],
// import hygiene
'import/no-unresolved': 'error',
'import/no-duplicates': 'error',
'import/newline-after-import': 'warn',
'import/no-cycle': 'warn',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// promises
'promise/no-return-wrap': 'error',
'promise/catch-or-return': 'warn',
'promise/no-multiple-resolved': 'error',
// Node.js checks
'n/no-missing-import': 'error',
'n/no-extraneous-import': 'error',
'n/no-process-exit': 'warn',
// Basic Jest safety even in TS files (tests block below adds more)
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
// stylistic / consistency
'prefer-const': 'warn',
'no-var': 'error',
'object-shorthand': 'warn',
'arrow-body-style': ['warn', 'as-needed'],
'prefer-arrow-callback': 'warn',
'spaced-comment': ['warn', 'always', { markers: ['/'], exceptions: ['-'] }],
curly: ['warn', 'multi-line'],
// Prettier runs separately; keep ESLint focused on semantic/style rules only
},
},
// Tests: be less strict about unused vars and allow any, and apply more jest rules
{
files: ['src/__tests__/**/*.ts'],
plugins: { jest: jestPlugin },
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// Jest-specific
'jest/expect-expect': 'warn',
'jest/no-test-prefixes': 'warn',
'jest/no-conditional-expect': 'warn',
},
},
];