Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
144 lines (142 loc) · 4.98 KB
/
Copy patheslint.config.js
File metadata and controls
144 lines (142 loc) · 4.98 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
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'eslint/config';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
import tseslint from 'typescript-eslint';
const unusedVarsOptions = {
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
};
export default defineConfig([
{
ignores: ['node_modules/**', 'coverage/**', 'dist/**', 'ee-dist/**']
},
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: Object.assign({}, globals.node, globals.es2022)
},
rules: {
// Error detection
'for-direction': 'error',
'no-await-in-loop': 'error',
'no-div-regex': 'error',
eqeqeq: 'error',
'dot-notation': 'error',
curly: 'error',
'no-fallthrough': 'error',
'no-unused-expressions': [
'error',
{
allowShortCircuit: true
}
],
'no-unused-vars': ['error', unusedVarsOptions],
'handle-callback-err': 'error',
'no-new': 'error',
'new-cap': 'error',
'no-eval': 'error',
'no-invalid-this': 'error',
radix: ['error', 'always'],
'no-use-before-define': ['error', 'nofunc'],
'callback-return': ['error', ['callback', 'cb', 'done']],
'no-regex-spaces': 'error',
'no-empty': 'error',
'no-duplicate-case': 'error',
'no-empty-character-class': 'error',
'no-redeclare': 'off', // Disabled per project preference
'block-scoped-var': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-void': 'error',
yoda: 'error',
'no-undef': 'error',
'no-var': 'error',
'no-bitwise': 'error',
'no-lonely-if': 'error',
'no-mixed-spaces-and-tabs': 'error',
'arrow-body-style': ['error', 'as-needed'],
'arrow-parens': ['error', 'as-needed'],
'prefer-arrow-callback': 'error',
'object-shorthand': 'error',
'prefer-spread': 'error',
'no-prototype-builtins': 'off', // Disabled per project preference
strict: ['error', 'global']
}
},
{
files: ['**/*.cjs'],
languageOptions: {
sourceType: 'commonjs'
}
},
{
files: ['**/*.ts'],
extends: [tseslint.configs.recommended],
rules: {
// Handled by the TypeScript compiler
'no-undef': 'off',
// TypeScript-aware replacements for the base rules
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', unusedVarsOptions],
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true
}
],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
typedefs: false,
ignoreTypeReferences: true
}
],
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',
// Project preferences
'prefer-const': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off'
}
},
{
// Type-aware rules for the library sources only
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url))
}
},
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-deprecated': 'error',
// `void promise;` marks a promise that is deliberately left unawaited
'no-void': ['error', { allowAsStatement: true }]
}
},
// Repo-specific: overrides go here, each with a one-line reason
{
// the examples are CommonJS (examples/package.json), they require the package like EmailEngine does
files: ['examples/**/*.js'],
languageOptions: {
sourceType: 'commonjs'
}
},
prettier
]);