-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.mjs
More file actions
94 lines (86 loc) · 2.6 KB
/
eslint.config.mjs
File metadata and controls
94 lines (86 loc) · 2.6 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
// @ts-check
import eslintJs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import globals from 'globals';
import typescriptEslint from 'typescript-eslint';
export default typescriptEslint.config(
// Global config
{
languageOptions: {
ecmaVersion: 2023,
sourceType: 'module',
globals: {
...globals.node,
},
},
},
// Ignored files
{
ignores: ['**/coverage/', '**/dist/', '**/node_modules/'],
},
// Enable recommended rules for JS files
eslintJs.configs.recommended,
// Custom basic rules
{
rules: {
// No console & debugger statements in production
'no-console': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
// Require empty line between certain statements
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: [
'block',
'block-like',
'cjs-export',
'class',
'export',
'import',
'multiline-block-like',
'multiline-const',
'multiline-expression',
'multiline-let',
'multiline-var',
],
next: '*',
},
{
blankLine: 'always',
prev: ['const', 'let'],
next: ['block', 'block-like', 'cjs-export', 'class', 'export', 'import'],
},
{
blankLine: 'always',
prev: '*',
next: ['multiline-block-like', 'multiline-const', 'multiline-expression', 'multiline-let', 'multiline-var'],
},
{ blankLine: 'any', prev: ['export', 'import'], next: ['export', 'import'] },
],
// Require empty line between class members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
// Disallow nested ternary expressions
'no-nested-ternary': 'error',
// Require brace style for multi-line control statements
curly: ['error', 'multi-line'],
// Disallow expressions where the operation doesn't affect the value
'no-constant-binary-expression': 'error',
},
},
// Enable TypeScript plugin and recommended rules for TypeScript files
...typescriptEslint.configs.recommended,
// Custom TypeScript rules
{
files: ['**/*.ts'],
rules: {
// Allow unused arguments and variables when they begin with an underscore
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
// Allow ts-directive comments (used to suppress TypeScript compiler errors)
'@typescript-eslint/ban-ts-comment': 'off',
// Allow usage of the any type (consider enabling this rule later on)
'@typescript-eslint/no-explicit-any': 'off',
},
},
eslintConfigPrettier,
);