-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy patheslint.config.js
More file actions
284 lines (279 loc) · 8.86 KB
/
Copy patheslint.config.js
File metadata and controls
284 lines (279 loc) · 8.86 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import panda from '@pandacss/eslint-plugin'
import stylistic from '@stylistic/eslint-plugin'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
import exportDefaultIdentifier from 'eslint-plugin-export-default-identifier'
import importPlugin from 'eslint-plugin-import'
import jsdoc from 'eslint-plugin-jsdoc'
import prettier from 'eslint-plugin-prettier'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import em from './packages/eslint-plugin-em/index.js'
const rules = {
'no-irregular-whitespace': 2,
'no-extra-semi': 2,
'prefer-const': 2,
'no-loop-func': 1,
'no-useless-constructor': 1,
'react/display-name': 2,
'no-restricted-globals': [
2,
{
name: 'localStorage',
message:
"Use the storage abstraction (import storage from '../util/storage') instead of accessing localStorage directly. This ensures cross-platform compatibility.",
},
],
'no-restricted-syntax': [
2,
{
selector: 'MemberExpression[object.name="expect"][property.name="poll"]',
message:
'expect.poll runs its callback in node, so every attempt is a devtools round trip on an interval. Wait in the page with page.waitForFunction (or a waitFor* helper) instead, which polls on every animation frame for a fixed handful of protocol messages. To report the value that was actually rendered, catch the wait and read it once — see docs/testing.md § Never wait for wall-clock time.',
},
{
selector: 'MemberExpression[object.name="vi"][property.name=/^(waitFor|waitUntil)$/]',
message:
'vi.waitFor polls on a real-time interval. In store and JSDOM tests, initStore and createTestApp already enable fake timers, so flush them instead — await vi.runAllTimersAsync() (wrapped in act when it causes React updates), then assert — which settles the work in one step and fails immediately rather than after the poll timeout. In Puppeteer, wait in the page with page.waitForFunction or a waitFor* helper. See docs/testing.md § Never wait for wall-clock time.',
},
],
'no-restricted-properties': [
2,
{
object: 'window',
property: 'getSelection',
message:
'Please import the appropriate helper function from /src/device/selection.ts to access the browser selection. This is done to abstract the browser selection API from the rest of the codebase.',
},
],
'export-default-identifier/export-default-identifier': 0,
'import/prefer-default-export': [
2,
{
// any: Any exporting file must contain a default export.
// single: When there is only a single export from a module, prefer using default export over named export.
target: 'any',
},
],
'jsdoc/check-alignment': 2,
'jsdoc/check-indentation': 2,
'jsdoc/check-syntax': 2,
'jsdoc/check-types': 2,
'jsdoc/implements-on-classes': 2,
'jsdoc/no-types': 2,
'jsdoc/no-undefined-types': 2,
'jsdoc/check-tag-names': [
2,
{
definedTags: ['packageDocumentation'],
},
],
'jsdoc/require-description-complete-sentence': [
2,
{
abbreviations: ['e.g.', 'i.e.'],
},
],
'jsdoc/require-jsdoc': [
2,
{
contexts: ['VariableDeclarator > ArrowFunctionExpression'],
enableFixer: false,
require: {
ClassDeclaration: true,
ClassExpression: true,
},
},
],
'jsx-a11y/anchor-is-valid': 0,
'@stylistic/jsx-curly-spacing': 2,
'@stylistic/jsx-equals-spacing': 2,
'react/react-in-jsx-scope': 0,
'@stylistic/jsx-tag-spacing': [2, { beforeSelfClosing: 'allow' }],
'react/no-children-prop': 0,
'react/no-unescaped-entities': 0,
'react/prop-types': 0,
'react-hooks/exhaustive-deps': 2,
'prettier/prettier': 2,
'arrow-body-style': 0,
'prefer-arrow-callback': 0,
'em/no-direct-durations-config-import': 2,
}
export default [
{
ignores: [
'node_modules/**',
'.claude/worktrees/**',
'packages/**/dist/**/*',
'packages/**/.build/**/*',
'**/styled-system/*',
'**/ios/*',
'**/android/**',
'**/desktop/**',
'**/build/*',
'**/docs/*',
'**/functions/*',
'public/wa-sqlite/**',
],
},
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
},
plugins: {
'@stylistic': stylistic,
'@stylistic/ts': stylistic,
'export-default-identifier': exportDefaultIdentifier,
jsdoc,
react,
'react-refresh': reactRefresh,
prettier,
'@typescript-eslint': typescriptEslint,
import: importPlugin,
'react-hooks': reactHooks,
'@pandacss': panda,
em,
},
rules,
settings: {
react: {
version: '19',
},
},
},
// Overrides for specific folders
{
files: ['src/e2e/**', '**/__tests__/*'],
rules: {
'no-restricted-globals': 0,
'no-restricted-properties': 0,
'jsdoc/check-tag-names': 0,
},
},
// Overrides for TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaFeatures: { jsx: true },
project: ['./tsconfig.json', './tsconfig.eslint.json'],
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
},
rules: {
...typescriptEslint.configs['eslint-recommended'].rules,
...typescriptEslint.configs.recommended.rules,
semi: [2, 'never'],
'no-extra-parens': 0,
'no-unused-vars': 0,
'no-use-before-define': 0,
'@stylistic/ts/member-delimiter-style': [
2,
{
multiline: {
delimiter: 'none',
},
},
],
'@typescript-eslint/no-var-requires': 2,
'@typescript-eslint/no-require-imports': 0,
'@typescript-eslint/no-explicit-any': 2,
'@typescript-eslint/prefer-namespace-keyword': 2,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-use-before-define': 2,
'@typescript-eslint/no-unused-vars': [2, { args: 'none', caughtErrors: 'none', varsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/array-type': 2,
'jsx-quotes': [2, 'prefer-single'],
'react-refresh/only-export-components': 2,
'em/no-store-subscribe-in-components': 2,
...panda.configs.recommended.rules,
'@pandacss/no-config-function-in-source': 0,
'@pandacss/prefer-longhand-properties': 2,
'@pandacss/no-dynamic-styling': 0,
'@pandacss/no-hardcoded-color': [
2,
{
whitelist: ['inherit', 'currentColor'],
},
],
'@pandacss/no-property-renaming': 2,
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
},
},
{
files: ['./src/**/*.ts', './src/**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
},
},
// The iOS WebdriverIO tests are typechecked by their own tsconfig, the only program that declares
// WebdriverIO's globals (browser, $, expect) and @wdio/browserstack-service's global interfaces. The root
// tsconfig excludes src/e2e/iOS, so type-aware linting of those files has to use theirs.
{
files: ['./src/e2e/iOS/**/*.ts'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: 'module',
project: './src/e2e/iOS/tsconfig.json',
},
},
},
{
files: ['./src/e2e/**/*.ts'],
rules: {
'jsdoc/check-tag-names': 0,
},
},
// Allow direct localStorage access only in the storage abstraction layer
{
files: ['./src/util/storage.ts'],
rules: {
'no-restricted-globals': 0,
},
},
// actions/github-script evaluates its `script:` body in a CommonJS context and resolves relative
// require() paths against the workspace, so the scripts it loads must be CommonJS. package.json
// sets "type": "module", hence the .cjs extension.
{
files: ['**/*.cjs'],
languageOptions: {
sourceType: 'commonjs',
globals: {
__dirname: 'readonly',
__filename: 'readonly',
module: 'writable',
process: 'readonly',
require: 'readonly',
},
},
},
// A constants module is a collection of peer values with no primary export, so there is no
// meaningful default export to prefer. Named exports keep them individually tree-shakeable and
// importable by name.
{
files: ['**/constants.ts'],
rules: {
'import/prefer-default-export': 0,
},
},
]