Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
129 lines (120 loc) · 3.58 KB
/
Copy patheslint.config.js
File metadata and controls
129 lines (120 loc) · 3.58 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
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import globals from 'globals';
import promise from 'eslint-plugin-promise';
export default [
// Global ignores
{
ignores: [
'node_modules/**',
'out/**',
'dist/**',
'target/**',
'coverage/**',
'.githooks/**',
'.obsidian/**',
'test/fixtures/examples/out/**',
'test/fixtures/blade/out/**',
'test/browser/**',
'test/contracts/**',
'test/hosts/**',
'tests/generated/**'
]
},
// Base config for all JS/MJS files
js.configs.recommended,
promise.configs['flat/recommended'],
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.es2022
}
},
rules: {
// Promise plugin rules for proper async handling
'promise/catch-or-return': 'error',
'promise/no-return-wrap': 'error',
'promise/param-names': 'error',
'promise/always-return': 'error',
// Async/await rules
'no-async-promise-executor': 'error',
'no-await-in-loop': 'off',
'no-return-await': 'error',
'prefer-promise-reject-errors': 'error',
// ESM-specific rules
'no-undef': 'error',
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
// General best practices for JavaScript
'no-console': 'off',
semi: ['error', 'always'],
quotes: ['error', 'single', { avoidEscape: true }],
'comma-dangle': ['error', 'never'],
indent: ['error', 2],
'no-trailing-spaces': 'error',
'eol-last': 'error',
// Modern JavaScript features
'prefer-const': 'error',
'prefer-arrow-callback': 'error',
'no-var': 'error',
'object-shorthand': 'error'
}
},
// Core purity rules: no Node built-ins in @wesley/core src (not tests/demo)
{
files: ['packages/wesley-core/src/**/*.mjs', 'packages/wesley-core/src/**/*.js'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['node:*'],
message: 'Do not use Node built-ins in core (keep it pure).'
}
],
paths: [
{ name: 'fs', message: 'Use ports/adapters; no fs in core.' },
{ name: 'path', message: 'Use ports/adapters; no path in core.' },
{ name: 'process', message: 'Do not use process in core.' },
{ name: 'child_process', message: 'No child_process in core.' },
{ name: 'os', message: 'No os in core.' },
{ name: 'buffer', message: 'No Buffer usage in core.' }
]
}
]
}
},
// Test files: relax rules that conflict with test patterns
{
files: ['**/test/**', '**/*.test.mjs', '**/*.test.js', '**/*.spec.mjs', '**/*.spec.js'],
rules: {
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
// Test stubs often implement interfaces without using await
'require-await': 'off',
// Tests may use empty catch blocks for error-path testing
'no-empty': 'off',
'promise/catch-or-return': 'off',
'promise/always-return': 'off'
}
},
// Prettier owns stylistic formatting. Keep this last so ESLint does not
// re-litigate indentation or other formatter-owned layout choices.
eslintConfigPrettier
];