forked from SignalK/signalk-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
159 lines (150 loc) · 4.46 KB
/
Copy patheslint.config.js
File metadata and controls
159 lines (150 loc) · 4.46 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const { defineConfig, globalIgnores } = require('eslint/config')
const js = require('@eslint/js')
const globals = require('globals')
const tseslint = require('typescript-eslint')
const prettier = require('eslint-config-prettier/flat')
const react = require('eslint-plugin-react')
const reactHooks = require('eslint-plugin-react-hooks')
const reactCompiler = require('eslint-plugin-react-compiler')
const eslintReact = require('@eslint-react/eslint-plugin')
const chai = require('eslint-plugin-chai-friendly')
module.exports = defineConfig([
globalIgnores([
'**/public',
'**/public_src',
'**/dist',
'**/.__mf__temp',
// WASM plugin examples - AssemblyScript has different semantics
'examples/wasm-plugins/**/assembly/**',
// AssemblyScript SDK - decorators and types not compatible with ESLint
'packages/assemblyscript-plugin-sdk/assembly/**',
// Auto-generated WASM bindings (created by AssemblyScript compiler)
'examples/wasm-plugins/**/build/**',
'examples/wasm-plugins/**/plugin.js',
'examples/wasm-plugins/**/plugin.d.ts',
'packages/assemblyscript-plugin-sdk/build/**'
]),
// TypeScript options
{
files: ['**/*.ts'],
extends: [common('@typescript-eslint/'), tseslint.configs.recommended],
languageOptions: {
parser: tseslint.parser,
globals: globals.node
}
},
// JavasScript-only options
{
files: ['**/*.js'],
extends: [common(), js.configs.recommended],
languageOptions: {
globals: globals.node
}
},
// Test-only options
{
files: [
'{src,packages/*/src}/**/*.test.{ts,js}',
'{test,packages/*/test}/**/*.{js,ts}'
],
plugins: { chai },
rules: {
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'chai/no-unused-expressions': 'error'
},
languageOptions: {
parser: tseslint.parser,
globals: globals.mocha
}
},
// Server-admin UI React 19 specific options
{
settings: {
react: {
version: 'detect'
}
},
files: ['packages/server-admin-ui/src/**/*.{js,jsx,ts,tsx}'],
extends: [
common('@typescript-eslint/'),
tseslint.configs.recommended,
react.configs.flat.recommended,
eslintReact.configs['recommended-typescript']
],
plugins: {
'react-hooks': reactHooks,
'react-compiler': reactCompiler
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaFeatures: {
jsx: true
},
project: './packages/server-admin-ui/tsconfig.json'
},
globals: {
...globals.browser
}
},
rules: {
// React hooks rules
...reactHooks.configs.recommended.rules,
// Duplicates react-hooks/set-state-in-effect, which is already an error
// from the official plugin. Reporting both means every annotated site
// needs two disable comments.
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 'off',
// React compiler rules
'react-compiler/react-compiler': 'warn',
// React 17+ with new JSX transform doesn't require React in scope
'react/react-in-jsx-scope': 'off',
// Disable prop-types (using TypeScript)
'react/prop-types': 'off',
'react/no-string-refs': 'off',
'react/no-direct-mutation-state': 'off'
}
},
// Admin UI tests. Must follow the React block above so these overrides win.
{
files: ['packages/server-admin-ui/src/**/*.test.{ts,tsx}'],
rules: {
// vi.mock factories must re-export hook names verbatim to replace the
// real module, so the use-prefix convention cannot apply here.
'@eslint-react/hooks-extra/no-unnecessary-use-prefix': 'off'
}
},
// Streams package - uses synchronous require() for lazy/dynamic imports
{
files: ['packages/streams/src/**/*.ts'],
rules: {
'@typescript-eslint/no-require-imports': 'off'
}
},
// Disable rules that prettier handles
prettier
])
// Common rules for all files
function common(prefix = '') {
return {
rules: {
[`${prefix}no-unused-vars`]: [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
[`${prefix}no-unused-expressions`]: [
'error',
{
allowShortCircuit: true,
allowTernary: true
}
],
'no-return-assign': ['error', 'always'],
eqeqeq: ['error', 'always']
}
}
}