-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
52 lines (51 loc) · 2.65 KB
/
Copy patheslint.config.mjs
File metadata and controls
52 lines (51 loc) · 2.65 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
import eslint from '@eslint/js'
import reactHooks from 'eslint-plugin-react-hooks'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{ ignores: ['**/dist/**', '**/node_modules/**', '**/*.vue'] },
eslint.configs.recommended,
tseslint.configs.recommended,
{
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
// react-hooks rules (rules-of-hooks, ref immutability, etc.) are React-specific and don't apply
// to packages/vanilla's Solid components — Solid's ref callbacks/reactivity model is
// structurally different (e.g. reassigning a plain `let` ref variable in a callback ref is the
// normal, idiomatic Solid pattern, not a rules-of-hooks violation) — so this plugin is scoped to
// packages/react only, rather than applied to every .tsx file in the repo.
{
files: ['packages/react/**/*.{ts,tsx}'],
plugins: { 'react-hooks': reactHooks },
rules: reactHooks.configs.recommended.rules,
},
// ESLint's core `no-unassigned-vars` (in `eslint.configs.recommended` as of ESLint 10) flags
// every `let x: HTMLDivElement | undefined` that's only ever written via Solid's `ref={x}`
// idiom — passing a plain variable as `ref` compiles (via babel-preset-solid) into an
// assignment to that variable, invisible to ESLint's static analysis since it runs on the
// pre-compile JSX. Same root cause as the react-hooks exclusion above: Solid's ref model reads,
// to a rule written for plain JS/React, as "declared but never assigned" when it's actually the
// normal way this package attaches a ref to a JSX element. Applies to both packages/vanilla
// (its own thin wrapper) and packages/solid (the actual Solid components it wraps).
{
files: ['packages/vanilla/**/*.tsx', 'packages/solid/**/*.tsx'],
rules: { 'no-unassigned-vars': 'off' },
},
// `@vates/data-table-core` (and its sub-paths) is internal-only, shared between the adapter
// packages themselves — a consumer of `@vates/data-table-react`/`-vue`/`-solid`/`-vanilla`
// should never need to import core directly (see packages/core/README.md's "Public API
// surface"). Demo apps are written the same way a real consumer would use these packages, so
// this catches a demo regressing back to a direct core import (as `demo/react`/`demo/vue`
// used to for `renderThemeCss`, before each adapter grew its own `/theme` re-export).
{
files: ['demo/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{ patterns: [{ group: ['@vates/data-table-core', '@vates/data-table-core/*'] }] },
],
},
},
)