@murky-web/oxlint-plugin-solid 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,10 +8,27 @@ projektspezifische Regeln wie `solid/prefer-arrow-components`.
8
8
  Die Regelmodule unter `src/rules/` sind aus dem Upstream-Quellstand abgeleitet
9
9
  und laufen ohne `eslint-plugin-solid` als Zielprojekt-Dependency.
10
10
 
11
+ Das Paket zieht auch ESLint selbst nicht mehr nach. Die Regeln sind schlichte
12
+ Objekte, wie Oxlint sie erwartet -- der `createRule`-Wrapper aus
13
+ `@typescript-eslint/utils` war nur eine TypeScript-Typhilfe und ist entfallen.
14
+ Geblieben sind fuenf AST-Helfer, die jetzt direkt aus
15
+ `@eslint-community/eslint-utils` kommen, statt die komplette
16
+ TypeScript-ESLint-Toolchain in den Baum jedes Konsumenten zu ziehen.
17
+
11
18
  Aktuell sind enthalten:
12
19
 
13
20
  - die komplette von `eslint-plugin-solid` exportierte Regelmenge
14
- - die zusaetzliche Projektregel `solid/prefer-arrow-components`
21
+ - die zusaetzlichen Projektregeln `solid/prefer-arrow-components`,
22
+ `solid/no-setter-in-effect` (meldet Effects, die nur in ein Signal oder einen
23
+ Store schreiben, statt den Wert abzuleiten -- und Effects, die etwas awaiten
24
+ und das Ergebnis zurueckschreiben, statt es aus einer Derivation zu liefern)
25
+ `solid/no-untracked-effect-read` (meldet reaktive Reads in der
26
+ apply-Phase eines zweiphasigen `createEffect`, die dort nicht tracken) und
27
+ `solid/no-owned-primitives-in-ref` (meldet `createEffect`/`onCleanup` und
28
+ Verwandte in einem Ref-Callback -- der laeuft ohne Owner, nichts raeumt sie
29
+ je wieder ab),
30
+ `solid/reactive-async`, `solid/no-server-import-in-client` und
31
+ `solid/strict-void-return` (siehe unten)
15
32
  - ein Test-Harness, der die exportierte Rule-Surface und echte Diagnostik
16
33
  gegen Temp-Projekte prueft
17
34
 
@@ -27,6 +44,66 @@ Wichtig dabei:
27
44
  - Zielprojekte brauchen dadurch weiter nur die kopierte Runtime unter
28
45
  `./oxc/jsplugins/solid/`, nicht dieses Paket als direkte Dependency
29
46
 
47
+ ## Regeln fuer das Solid-2.0-Modell
48
+
49
+ Die drei Regeln arbeiten ohne Typinformation, nur mit Syntax und Scope. Sie
50
+ sind in `config/oxc/linting/solid.jsonc` aktiv und ersetzen dort fuer
51
+ `*.tsx`/`*.jsx` die Typ-Regeln `typescript/promise-function-async` und
52
+ `typescript/strict-void-return`.
53
+
54
+ ### `solid/reactive-async`
55
+
56
+ In einer reaktiven Berechnung liest Solid ein zurueckgegebenes Promise wie einen
57
+ Wert; `createMemo(() => getProduct(props.id))` braucht kein `async`. Geprueft
58
+ werden die Callbacks von `createMemo`, `createSignal(fn)`, `createStore(fn)`,
59
+ `createProjection`, `createOptimistic`, `createOptimisticStore` und die
60
+ Compute-Phase des zweiphasigen `createEffect`/`createRenderEffect`.
61
+
62
+ Gemeldet wird
63
+
64
+ - ein Read nach dem ersten `await` im selben Callback (Aufruf eines Signals oder
65
+ Memos, `props.x`, Property-Read eines Stores): Solid meldet das zur Laufzeit
66
+ als `UNTRACKED_READ_AFTER_AWAIT`, es wird nie eine Dependency. Lies den Wert
67
+ vor dem `await` in eine lokale Variable.
68
+ - ein `async`-Callback, dessen einziges `await` ein `return await x` ist: `async`
69
+ und `await` weglassen und das Promise zurueckgeben. Innerhalb von `try` bleibt
70
+ `return await` erlaubt, weil es das `catch` erst moeglich macht.
71
+
72
+ Grenzen: Reads in verschachtelten Funktionen, Helfern und `.then`-Callbacks
73
+ sieht die Regel nicht (die Laufzeit-Diagnose schon). Ob ein Name ein Signal ist,
74
+ folgt nur aus `createSignal`/`createMemo`/den Store-Primitiven in derselben
75
+ Datei und aus dem Namen `props`.
76
+
77
+ ### `solid/no-server-import-in-client`
78
+
79
+ Client-Dateien (`.tsx` und `.ts` ausserhalb von `src/server/`, ohne
80
+ Test-Dateien) duerfen ein Modul unter `src/server/` nur importieren, wenn dessen
81
+ erste Anweisung `"use server"` ist. Der Pfad wird vom importierenden File aus
82
+ aufgeloest (relativ oder `~/` = `<Projekt>/src/`, Projektwurzel = naechstes
83
+ Verzeichnis mit `package.json`) und die Zieldatei gelesen. Fehlt das Ziel,
84
+ wird nichts gemeldet. `import type` wird ignoriert. Geprueft werden auch
85
+ `export ... from` und `import("...")` mit String-Literal.
86
+
87
+ Grenze: andere Aliase und Server-Code ausserhalb von `src/server/` kennt die
88
+ Regel nicht.
89
+
90
+ ### `solid/strict-void-return`
91
+
92
+ Ohne Typen meldet sie Funktionen, deren Rueckgabewert Solid verwirft:
93
+
94
+ - ein Arrow mit Expression-Body (nicht `void x`) in einem `on*`-Attribut,
95
+ `on:event` oder in `ref` (auch in einem Ref-Array). Erlaubt sind Block-Body
96
+ und ein direkt uebergebener Setter (`ref={setInput}`).
97
+ - ein `onCleanup`-Callback, der einen sicher nicht-void Wert zurueckgibt
98
+ (Literal, Zuweisung, Objekt, ...). Ein Call wie `() => clearInterval(id)`
99
+ bleibt erlaubt.
100
+ - ein `onSettled`-Callback, der etwas anderes als eine Cleanup-Funktion
101
+ zurueckgibt (Literal, Zuweisung, ...).
102
+
103
+ Die Regel ist schwaecher als `typescript/strict-void-return`: sie sieht nur
104
+ Inline-Callbacks, keine Funktionen, die per Namen uebergeben werden, und bei
105
+ `onCleanup`/`onSettled` keine Calls, deren Rueckgabetyp sie nicht kennt.
106
+
30
107
  ## Nutzung ueber @murky-web/config
31
108
 
32
109
  Im Zielprojekt:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@murky-web/oxlint-plugin-solid",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Local Oxlint JS plugin port for Solid rules plus Murky-specific Solid conventions.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -26,8 +26,7 @@
26
26
  },
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
- "@typescript-eslint/utils": "^8.57.1",
30
- "eslint": "^9.38.0",
29
+ "@eslint-community/eslint-utils": "^4.9.1",
31
30
  "estraverse": "^5.3.0",
32
31
  "is-html": "^2.0.0",
33
32
  "kebab-case": "^1.0.2",
@@ -35,7 +34,7 @@
35
34
  "style-to-object": "^1.0.8"
36
35
  },
37
36
  "devDependencies": {
38
- "solid-js": "^1.9.11"
37
+ "solid-js": "^1.9.15"
39
38
  },
40
39
  "publishConfig": {
41
40
  "access": "public",
package/src/compat.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { ASTUtils } from "@typescript-eslint/utils";
1
+ import { findVariable as utilsFindVariable } from "@eslint-community/eslint-utils";
2
2
 
3
3
  export function getSourceCode(context) {
4
4
  if (typeof context.getSourceCode === "function") {
@@ -23,7 +23,7 @@ export function getScope(context, node) {
23
23
  }
24
24
 
25
25
  export function findVariable(context, node) {
26
- return ASTUtils.findVariable(getScope(context, node), node);
26
+ return utilsFindVariable(getScope(context, node), node);
27
27
  }
28
28
 
29
29
  export function markVariableAsUsed(context, name, node) {
package/src/index.mjs CHANGED
@@ -8,16 +8,22 @@ import { jsxUsesVarsRule } from "./rules/jsx_uses_vars.mjs";
8
8
  import { noArrayHandlersRule } from "./rules/no_array_handlers.mjs";
9
9
  import noDestructureRule from "./rules/no_destructure.mjs";
10
10
  import noInnerhtmlRule from "./rules/no_innerhtml.mjs";
11
+ import noOwnedPrimitivesInRefRule from "./rules/no_owned_primitives_in_ref.mjs";
11
12
  import noProxyApisRule from "./rules/no_proxy_apis.mjs";
12
13
  import noReactDepsRule from "./rules/no_react_deps.mjs";
13
14
  import { noReactSpecificPropsRule } from "./rules/no_react_specific_props.mjs";
15
+ import noSetterInEffectRule from "./rules/no_setter_in_effect.mjs";
16
+ import { noServerImportInClientRule } from "./rules/no_server_import_in_client.mjs";
14
17
  import noUnknownNamespacesRule from "./rules/no_unknown_namespaces.mjs";
18
+ import noUntrackedEffectReadRule from "./rules/no_untracked_effect_read.mjs";
15
19
  import { preferArrowComponentsRule } from "./rules/prefer_arrow_components.mjs";
16
20
  import preferClassObjectRule from "./rules/prefer_class_object.mjs";
17
21
  import preferForRule from "./rules/prefer_for.mjs";
18
22
  import preferShowRule from "./rules/prefer_show.mjs";
23
+ import { reactiveAsyncRule } from "./rules/reactive_async.mjs";
19
24
  import reactivityRule from "./rules/reactivity.mjs";
20
25
  import selfClosingCompRule from "./rules/self_closing_comp.mjs";
26
+ import { strictVoidReturnRule } from "./rules/strict_void_return.mjs";
21
27
  import stylePropRule from "./rules/style_prop.mjs";
22
28
  import validateJsxNestingRule from "./rules/validate_jsx_nesting.mjs";
23
29
 
@@ -37,16 +43,22 @@ const extendedPlugin = {
37
43
  "no-array-handlers": noArrayHandlersRule,
38
44
  "no-destructure": noDestructureRule,
39
45
  "no-innerhtml": noInnerhtmlRule,
46
+ "no-owned-primitives-in-ref": noOwnedPrimitivesInRefRule,
40
47
  "no-proxy-apis": noProxyApisRule,
41
48
  "no-react-deps": noReactDepsRule,
42
49
  "no-react-specific-props": noReactSpecificPropsRule,
50
+ "no-setter-in-effect": noSetterInEffectRule,
51
+ "no-server-import-in-client": noServerImportInClientRule,
43
52
  "no-unknown-namespaces": noUnknownNamespacesRule,
53
+ "no-untracked-effect-read": noUntrackedEffectReadRule,
44
54
  "prefer-arrow-components": preferArrowComponentsRule,
45
55
  "prefer-class-object": preferClassObjectRule,
46
56
  "prefer-for": preferForRule,
47
57
  "prefer-show": preferShowRule,
58
+ "reactive-async": reactiveAsyncRule,
48
59
  reactivity: reactivityRule,
49
60
  "self-closing-comp": selfClosingCompRule,
61
+ "strict-void-return": strictVoidReturnRule,
50
62
  "style-prop": stylePropRule,
51
63
  "validate-jsx-nesting": validateJsxNestingRule,
52
64
  },
@@ -1,8 +1,5 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { getSourceCode } from "../compat.mjs";
4
2
  import { getFunctionName } from "../utils.mjs";
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
3
  const isNothing = (node) => {
7
4
  if (!node) {
8
5
  return true;
@@ -17,7 +14,7 @@ const isNothing = (node) => {
17
14
  }
18
15
  };
19
16
  const getLineLength = (loc) => loc.end.line - loc.start.line + 1;
20
- export default createRule({
17
+ export default {
21
18
  meta: {
22
19
  type: "problem",
23
20
  docs: {
@@ -199,4 +196,4 @@ export default createRule({
199
196
  },
200
197
  };
201
198
  },
202
- });
199
+ };
@@ -1,9 +1,7 @@
1
- import { ESLintUtils, ASTUtils } from "@typescript-eslint/utils";
1
+ import { getStaticValue } from "@eslint-community/eslint-utils";
2
2
 
3
3
  import { getScope, getSourceCode } from "../compat.mjs";
4
4
  import { isDOMElementName } from "../utils.mjs";
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
- const { getStaticValue } = ASTUtils;
7
5
  const COMMON_EVENTS = [
8
6
  "onAnimationEnd",
9
7
  "onAnimationIteration",
@@ -82,7 +80,7 @@ const isNonstandardEventName = (lowercaseEventName) =>
82
80
  Boolean(NONSTANDARD_EVENTS_MAP[lowercaseEventName]);
83
81
  const getStandardEventHandlerName = (lowercaseEventName) =>
84
82
  NONSTANDARD_EVENTS_MAP[lowercaseEventName];
85
- export default createRule({
83
+ export default {
86
84
  meta: {
87
85
  type: "problem",
88
86
  docs: {
@@ -295,4 +293,4 @@ export default createRule({
295
293
  },
296
294
  };
297
295
  },
298
- });
296
+ };
@@ -1,8 +1,5 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { getSourceCode } from "../compat.mjs";
4
2
  import { appendImports, insertImports, removeSpecifier } from "../utils.mjs";
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
3
  // Solid 2.0 moved the renderers into `@solidjs/*` packages and pulled the store
7
4
  // APIs into the core. Symbols that are legitimately exported from more than one
8
5
  // package (the control-flow components, `ComponentProps`) are deliberately left
@@ -14,12 +11,19 @@ for (const primitive of [
14
11
  "children",
15
12
  "createContext",
16
13
  "createEffect",
14
+ // The primitive forms of `Loading`, `Errored` and `Reveal`. Only custom
15
+ // boundary components and renderer integrations reach for them, which is
16
+ // why they were missing here — and why a wrong-module import of one went
17
+ // unreported while every neighbouring primitive was checked.
18
+ "createErrorBoundary",
19
+ "createLoadingBoundary",
17
20
  "createMemo",
18
21
  "createOptimistic",
19
22
  "createOptimisticStore",
20
23
  "createProjection",
21
24
  "createReaction",
22
25
  "createRenderEffect",
26
+ "createRevealOrder",
23
27
  "createRoot",
24
28
  "createSignal",
25
29
  "createStore",
@@ -98,7 +102,7 @@ for (const type of ["ClassValue", "IntrinsicElement", "JSX", "RequestEvent"]) {
98
102
  }
99
103
  const sourceRegex = /^(?:solid-js|@solidjs\/(?:web|h|html|universal))$/;
100
104
  const isSource = (source) => sourceRegex.test(source);
101
- export default createRule({
105
+ export default {
102
106
  meta: {
103
107
  type: "suggestion",
104
108
  docs: {
@@ -189,4 +193,4 @@ export default createRule({
189
193
  },
190
194
  };
191
195
  },
192
- });
196
+ };
@@ -1,8 +1,5 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { jsxGetAllProps } from "../utils.mjs";
4
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
5
- export default createRule({
2
+ export default {
6
3
  meta: {
7
4
  type: "problem",
8
5
  docs: {
@@ -26,7 +23,7 @@ export default createRule({
26
23
  messages: {
27
24
  noDuplicateProps: "Duplicate props are not allowed.",
28
25
  noDuplicateClass:
29
- "Duplicate `class` props are not allowed; while it might seem to work, it can break unexpectedly. Use `classList` instead.",
26
+ "Duplicate `class` props are not allowed; while it might seem to work, it can break unexpectedly. Pass one `class` with the object or array form instead.",
30
27
  noDuplicateChildren:
31
28
  "Using {{used}} at the same time is not allowed.",
32
29
  },
@@ -84,4 +81,4 @@ export default createRule({
84
81
  },
85
82
  };
86
83
  },
87
- });
84
+ };
@@ -1,14 +1,12 @@
1
- import { ASTUtils, ESLintUtils } from "@typescript-eslint/utils";
1
+ import { getStaticValue } from "@eslint-community/eslint-utils";
2
2
 
3
3
  import { getScope } from "../compat.mjs";
4
4
 
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
- const { getStaticValue } = ASTUtils;
7
5
  const JAVASCRIPT_PROTOCOL_PATTERN =
8
6
  "^[\\\\u0000-\\\\u001F ]*j[\\\\r\\\\n\\\\t]*a[\\\\r\\\\n\\\\t]*v[\\\\r\\\\n\\\\t]*a[\\\\r\\\\n\\\\t]*s[\\\\r\\\\n\\\\t]*c[\\\\r\\\\n\\\\t]*r[\\\\r\\\\n\\\\t]*i[\\\\r\\\\n\\\\t]*p[\\\\r\\\\n\\\\t]*t[\\\\r\\\\n\\\\t]*:";
9
7
  const JAVASCRIPT_PROTOCOL_REGEX = new RegExp(JAVASCRIPT_PROTOCOL_PATTERN, "i");
10
8
 
11
- export const jsxNoScriptUrlRule = createRule({
9
+ export const jsxNoScriptUrlRule = {
12
10
  meta: {
13
11
  docs: {
14
12
  description: "Disallow javascript: URLs.",
@@ -51,4 +49,4 @@ export const jsxNoScriptUrlRule = createRule({
51
49
  },
52
50
  };
53
51
  },
54
- });
52
+ };
@@ -1,5 +1,3 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { getScope, getSourceCode } from "../compat.mjs";
4
2
  import {
5
3
  isDOMElementName,
@@ -7,7 +5,6 @@ import {
7
5
  appendImports,
8
6
  insertImports,
9
7
  } from "../utils.mjs";
10
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
11
8
  // Currently all of the control flow components are from 'solid-js'.
12
9
  // Solid 2.0 dropped `Index` (use `<For keyed={false}>`) and renamed the
13
10
  // async/error boundaries. All of these are exported from `solid-js`.
@@ -22,7 +19,7 @@ const AUTO_COMPONENTS = [
22
19
  "Reveal",
23
20
  ];
24
21
  const SOURCE_MODULE = "solid-js";
25
- export default createRule({
22
+ export default {
26
23
  meta: {
27
24
  type: "problem",
28
25
  docs: {
@@ -225,4 +222,4 @@ export default createRule({
225
222
  },
226
223
  };
227
224
  },
228
- });
225
+ };
@@ -1,10 +1,6 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { markVariableAsUsed } from "../compat.mjs";
4
2
 
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
-
7
- export const jsxUsesVarsRule = createRule({
3
+ export const jsxUsesVarsRule = {
8
4
  meta: {
9
5
  docs: {
10
6
  description:
@@ -52,4 +48,4 @@ export const jsxUsesVarsRule = createRule({
52
48
  },
53
49
  };
54
50
  },
55
- });
51
+ };
@@ -1,10 +1,6 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { isDOMElementName, trace } from "../utils.mjs";
4
2
 
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
-
7
- export const noArrayHandlersRule = createRule({
3
+ export const noArrayHandlersRule = {
8
4
  meta: {
9
5
  docs: {
10
6
  description: "Disallow usage of type-unsafe event handlers.",
@@ -50,4 +46,4 @@ export const noArrayHandlersRule = createRule({
50
46
  },
51
47
  };
52
48
  },
53
- });
49
+ };
@@ -1,8 +1,6 @@
1
- import { ESLintUtils, ASTUtils } from "@typescript-eslint/utils";
1
+ import { getStringIfConstant } from "@eslint-community/eslint-utils";
2
2
 
3
3
  import { getSourceCode } from "../compat.mjs";
4
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
5
- const { getStringIfConstant } = ASTUtils;
6
4
  const getName = (node) => {
7
5
  switch (node.type) {
8
6
  case "Literal":
@@ -32,7 +30,7 @@ const getPropertyInfo = (prop) => {
32
30
  return null;
33
31
  }
34
32
  };
35
- export default createRule({
33
+ export default {
36
34
  meta: {
37
35
  type: "problem",
38
36
  docs: {
@@ -212,4 +210,4 @@ export default createRule({
212
210
  },
213
211
  };
214
212
  },
215
- });
213
+ };
@@ -1,10 +1,8 @@
1
- import { ESLintUtils, ASTUtils } from "@typescript-eslint/utils";
1
+ import { getStringIfConstant } from "@eslint-community/eslint-utils";
2
2
  import isHtml from "is-html";
3
3
 
4
4
  import { jsxPropName } from "../utils.mjs";
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
- const { getStringIfConstant } = ASTUtils;
7
- export default createRule({
5
+ export default {
8
6
  meta: {
9
7
  type: "problem",
10
8
  docs: {
@@ -142,4 +140,4 @@ export default createRule({
142
140
  },
143
141
  };
144
142
  },
145
- });
143
+ };
@@ -0,0 +1,122 @@
1
+ import { isFunctionNode, jsxPropName, trackImports } from "../utils.mjs";
2
+
3
+ /**
4
+ * Primitives that attach to the current owner.
5
+ *
6
+ * An effect or memo created without an owner is never disposed, and a cleanup
7
+ * registered without one never runs.
8
+ */
9
+ const OWNED_PRIMITIVES = [
10
+ "createEffect",
11
+ "createMemo",
12
+ "createProjection",
13
+ "createReaction",
14
+ "createRenderEffect",
15
+ "onCleanup",
16
+ "onSettled",
17
+ ];
18
+
19
+ /** The callbacks a `ref` prop applies, including the ones in a ref array. */
20
+ function getRefCallbacks(expression) {
21
+ if (isFunctionNode(expression)) {
22
+ return [expression];
23
+ }
24
+
25
+ // `ref={[storeElement, autofocus, listen(...)]}` — Solid flattens the array
26
+ // and calls each entry, so an inline callback anywhere in it is a ref
27
+ // callback like any other.
28
+ if (expression?.type === "ArrayExpression") {
29
+ return expression.elements.flatMap((element) =>
30
+ element !== null && isFunctionNode(element) ? [element] : [],
31
+ );
32
+ }
33
+
34
+ return [];
35
+ }
36
+
37
+ /**
38
+ * Walk a callback body, stopping at nested functions.
39
+ *
40
+ * Only calls the ref callback makes itself are reported. A nested function may
41
+ * be handed to something that supplies an owner, and guessing wrong would flag
42
+ * working code.
43
+ */
44
+ function walkOwnBody(node, visit) {
45
+ if (node === null || typeof node !== "object") {
46
+ return;
47
+ }
48
+
49
+ visit(node);
50
+
51
+ for (const [key, value] of Object.entries(node)) {
52
+ if (key === "parent") {
53
+ continue;
54
+ }
55
+
56
+ const candidates = Array.isArray(value) ? value : [value];
57
+ for (const candidate of candidates) {
58
+ if (
59
+ candidate !== null &&
60
+ typeof candidate === "object" &&
61
+ typeof candidate.type === "string" &&
62
+ !isFunctionNode(candidate)
63
+ ) {
64
+ walkOwnBody(candidate, visit);
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ export default {
71
+ meta: {
72
+ type: "problem",
73
+ docs: {
74
+ description:
75
+ "Disallow creating owner-bound primitives inside a ref callback.",
76
+ url: "https://docs.solidjs.com/",
77
+ },
78
+ schema: [],
79
+ messages: {
80
+ ownedPrimitiveInRef:
81
+ "`{{name}}` is called inside a ref callback, which runs without an owner — nothing will ever dispose it. Create it in the directive factory instead, and let the returned callback only store the element.",
82
+ },
83
+ },
84
+ defaultOptions: [],
85
+ create(context) {
86
+ const { matchImport, handleImportDeclaration } = trackImports();
87
+
88
+ return {
89
+ ImportDeclaration: handleImportDeclaration,
90
+ JSXAttribute(node) {
91
+ if (jsxPropName(node) !== "ref") {
92
+ return;
93
+ }
94
+
95
+ if (node.value?.type !== "JSXExpressionContainer") {
96
+ return;
97
+ }
98
+
99
+ for (const callback of getRefCallbacks(node.value.expression)) {
100
+ walkOwnBody(callback.body, (candidate) => {
101
+ if (
102
+ candidate.type !== "CallExpression" ||
103
+ candidate.callee.type !== "Identifier" ||
104
+ !matchImport(
105
+ OWNED_PRIMITIVES,
106
+ candidate.callee.name,
107
+ )
108
+ ) {
109
+ return;
110
+ }
111
+
112
+ context.report({
113
+ node: candidate,
114
+ messageId: "ownedPrimitiveInRef",
115
+ data: { name: candidate.callee.name },
116
+ });
117
+ });
118
+ }
119
+ },
120
+ };
121
+ },
122
+ };
@@ -1,20 +1,16 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import {
4
2
  isFunctionNode,
5
3
  trackImports,
6
4
  isPropsByName,
7
5
  trace,
8
6
  } from "../utils.mjs";
9
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
10
-
11
7
  // Store APIs that hand back a Proxy. Solid 2.0 exports these from `solid-js`.
12
8
  const PROXY_BACKED_STORE_APIS = new Set([
13
9
  "createStore",
14
10
  "createProjection",
15
11
  "createOptimisticStore",
16
12
  ]);
17
- export default createRule({
13
+ export default {
18
14
  meta: {
19
15
  type: "problem",
20
16
  docs: {
@@ -116,4 +112,4 @@ export default createRule({
116
112
  },
117
113
  };
118
114
  },
119
- });
115
+ };
@@ -1,8 +1,5 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { isFunctionNode, trace, trackImports } from "../utils.mjs";
4
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
5
- export default createRule({
2
+ export default {
6
3
  meta: {
7
4
  type: "problem",
8
5
  docs: {
@@ -14,7 +11,7 @@ export default createRule({
14
11
  schema: [],
15
12
  messages: {
16
13
  noUselessDep:
17
- "In Solid, `{{name}}` doesn't accept a dependency array because it automatically tracks its dependencies. If you really need to override the list of dependencies, use `on`.",
14
+ "In Solid, `{{name}}` doesn't accept a dependency array because it automatically tracks its dependencies. To narrow what is tracked, read only those values in the compute phase.",
18
15
  },
19
16
  },
20
17
  defaultOptions: [],
@@ -62,4 +59,4 @@ export default createRule({
62
59
  },
63
60
  };
64
61
  },
65
- });
62
+ };
@@ -1,14 +1,11 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
2
-
3
1
  import { isDOMElementName, jsxGetProp, jsxHasProp } from "../utils.mjs";
4
2
 
5
- const createRule = ESLintUtils.RuleCreator.withoutDocs;
6
3
  const REACT_SPECIFIC_PROPS = [
7
4
  { from: "className", to: "class" },
8
5
  { from: "htmlFor", to: "for" },
9
6
  ];
10
7
 
11
- export const noReactSpecificPropsRule = createRule({
8
+ export const noReactSpecificPropsRule = {
12
9
  meta: {
13
10
  docs: {
14
11
  description:
@@ -68,4 +65,4 @@ export const noReactSpecificPropsRule = createRule({
68
65
  },
69
66
  };
70
67
  },
71
- });
68
+ };