@murky-web/oxlint-plugin-solid 1.5.0 → 1.6.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.
Files changed (45) hide show
  1. package/README.md +163 -18
  2. package/THIRD_PARTY_NOTICES.md +7 -4
  3. package/package.json +5 -2
  4. package/src/compat.mjs +3 -0
  5. package/src/index.mjs +26 -3
  6. package/src/rules/components_return_once.mjs +136 -89
  7. package/src/rules/event_handlers.mjs +55 -35
  8. package/src/rules/filename_matches_export.mjs +292 -0
  9. package/src/rules/function_size.mjs +189 -0
  10. package/src/rules/imports.mjs +24 -21
  11. package/src/rules/init_declarations.mjs +139 -0
  12. package/src/rules/jsx_no_duplicate_props.mjs +46 -18
  13. package/src/rules/jsx_no_script_url.mjs +7 -6
  14. package/src/rules/jsx_no_undef.mjs +35 -38
  15. package/src/rules/jsx_uses_vars.mjs +4 -4
  16. package/src/rules/no_array_handlers.mjs +38 -9
  17. package/src/rules/no_cleanup_in_effect_apply.mjs +154 -0
  18. package/src/rules/no_destructure.mjs +105 -35
  19. package/src/rules/no_innerhtml.mjs +64 -31
  20. package/src/rules/no_module_scope_reactive_primitive.mjs +73 -0
  21. package/src/rules/no_owned_primitives_in_ref.mjs +30 -9
  22. package/src/rules/no_proxy_apis.mjs +44 -15
  23. package/src/rules/no_react_deps.mjs +397 -41
  24. package/src/rules/no_react_specific_props.mjs +40 -11
  25. package/src/rules/no_server_import_in_client.mjs +9 -9
  26. package/src/rules/no_setter_in_effect.mjs +153 -30
  27. package/src/rules/no_single_arg_create_effect.mjs +55 -0
  28. package/src/rules/no_unassigned_vars.mjs +99 -0
  29. package/src/rules/no_unknown_namespaces.mjs +108 -29
  30. package/src/rules/no_untracked_effect_read.mjs +69 -32
  31. package/src/rules/no_write_in_pure_computation.mjs +273 -0
  32. package/src/rules/prefer_arrow_components.mjs +47 -21
  33. package/src/rules/prefer_class_object.mjs +52 -20
  34. package/src/rules/prefer_destructuring.mjs +164 -0
  35. package/src/rules/prefer_for.mjs +42 -12
  36. package/src/rules/prefer_ref_shorthand.mjs +142 -0
  37. package/src/rules/prefer_show.mjs +55 -24
  38. package/src/rules/reactive_async.mjs +64 -17
  39. package/src/rules/reactivity.mjs +1218 -350
  40. package/src/rules/self_closing_comp.mjs +23 -18
  41. package/src/rules/strict_void_return.mjs +50 -20
  42. package/src/rules/style_prop.mjs +53 -25
  43. package/src/rules/typed_merge_defaults.mjs +88 -0
  44. package/src/rules/validate_jsx_nesting.mjs +16 -16
  45. package/src/utils.mjs +65 -34
@@ -1,62 +1,418 @@
1
- import { isFunctionNode, trace, trackImports } from "../utils.mjs";
1
+ // Solid 2.0 has no dependency arrays. `createEffect(compute, effectFn)` tracks
2
+ // what compute reads and runs effectFn untracked; `createMemo(fn, options)`
3
+ // tracks what fn reads. A React-style array lands where Solid expects the
4
+ // effect function or the options object.
5
+ import { getSourceCode } from "../compat.mjs";
6
+ import {
7
+ appendImports,
8
+ getGetterName,
9
+ isFunctionNode,
10
+ isPropsByName,
11
+ localName,
12
+ messageCode,
13
+ trace,
14
+ trackImports,
15
+ walkOwnBody
16
+ } from "../utils.mjs";
17
+
18
+ const EFFECTS = ["createEffect", "createRenderEffect"];
19
+ const ACCESSOR_PAIRS = ["createSignal", "createOptimistic"];
20
+ const SECOND = 1;
21
+ const THIRD = 2;
22
+
23
+ /**
24
+ * The normalized read `node` stands for: `a()` for a call without arguments,
25
+ * `props.id` for a props member. Null for anything else.
26
+ */
27
+ function readText(node) {
28
+ if (
29
+ node?.type === "CallExpression" &&
30
+ node.callee.type === "Identifier" &&
31
+ node.arguments.length === 0
32
+ ) {
33
+ return `${node.callee.name}()`;
34
+ }
35
+
36
+ if (
37
+ node?.type === "MemberExpression" &&
38
+ !node.computed &&
39
+ node.object.type === "Identifier" &&
40
+ isPropsByName(node.object.name) &&
41
+ node.property.type === "Identifier"
42
+ ) {
43
+ return `${node.object.name}.${node.property.name}`;
44
+ }
45
+
46
+ return null;
47
+ }
48
+
49
+ /**
50
+ * Each dep as `{ key, read }`: accessor `a` -> `a: a()`, `a()` -> `a: a()`,
51
+ * `props.id` -> `id: props.id`. Null unless every dep resolves and no two claim
52
+ * the same key.
53
+ */
54
+ function resolveDeps(array, accessors) {
55
+ const byKey = new Map();
56
+ for (const element of array.elements) {
57
+ const read =
58
+ element?.type === "Identifier" && accessors.has(element.name)
59
+ ? `${element.name}()`
60
+ : readText(element);
61
+ if (read === null) {
62
+ return null;
63
+ }
64
+
65
+ const key = localName(read.replace(/\(\)$/u, ""));
66
+ if (byKey.has(key) && byKey.get(key) !== read) {
67
+ return null;
68
+ }
69
+ byKey.set(key, read);
70
+ }
71
+
72
+ return [...byKey].map(([key, read]) => ({ key, read }));
73
+ }
74
+
75
+ /** A name that is not a variable reference: `obj.id`, `{ id: 1 }`. */
76
+ function isNonReference(node) {
77
+ const { parent } = node;
78
+
79
+ return (
80
+ (parent?.type === "MemberExpression" &&
81
+ parent.property === node &&
82
+ !parent.computed) ||
83
+ (parent?.type === "Property" &&
84
+ parent.key === node &&
85
+ !parent.computed &&
86
+ !parent.shorthand)
87
+ );
88
+ }
89
+
90
+ /**
91
+ * The function's body with each dep read replaced by its parameter, or null
92
+ * when a parameter would shadow a name the body still uses.
93
+ */
94
+ function rewriteBody(fn, deps, sourceCode) {
95
+ const keyByRead = new Map(deps.map(({ key, read }) => [read, key]));
96
+ const keys = new Set(deps.map(({ key }) => key));
97
+ const edits = [];
98
+ let clean = true;
99
+
100
+ // Nested functions are not rewritten (a read there is a live read, not
101
+ // the snapshot), but a parameter would still shadow their names.
102
+ const visit = (node, nested) => {
103
+ const read = readText(node);
104
+ if (!nested && keyByRead.has(read)) {
105
+ edits.push({ key: keyByRead.get(read), range: node.range });
106
+ return;
107
+ }
108
+ if (
109
+ node.type === "Identifier" &&
110
+ keys.has(node.name) &&
111
+ !isNonReference(node)
112
+ ) {
113
+ clean = false;
114
+ }
115
+ for (const [field, value] of Object.entries(node)) {
116
+ if (field === "parent") {
117
+ continue;
118
+ }
119
+ for (const child of [value].flat()) {
120
+ if (typeof child?.type === "string") {
121
+ visit(child, nested || isFunctionNode(child));
122
+ }
123
+ }
124
+ }
125
+ };
126
+ visit(fn.body, false);
127
+ if (!clean) {
128
+ return null;
129
+ }
130
+
131
+ const [start] = fn.body.range;
132
+ let text = sourceCode.getText(fn.body);
133
+ for (const { key, range } of edits.toSorted(
134
+ (left, right) => right.range[0] - left.range[0]
135
+ )) {
136
+ text = `${text.slice(0, range[0] - start)}${key}${text.slice(range[1] - start)}`;
137
+ }
138
+
139
+ // `() => ({ … })` loses its parentheses in getText.
140
+ return fn.body.type !== "BlockStatement" && text.startsWith("{")
141
+ ? `(${text})`
142
+ : text;
143
+ }
144
+
145
+ function computeText(deps) {
146
+ return `() => ({ ${deps.map(({ key, read }) => `${key}: ${read}`).join(", ")} })`;
147
+ }
148
+
149
+ function paramsText(deps) {
150
+ return `{ ${deps.map(({ key }) => key).join(", ")} }`;
151
+ }
152
+
153
+ /** `createEffect(() => ({ a: a() }), ({ a }) => { … })` for the message. */
154
+ function effectFixText(name, deps) {
155
+ return deps
156
+ ? `${name}(${computeText(deps)}, (${paramsText(deps)}) => { … })`
157
+ : `${name}(() => ({ value: source() }), ({ value }) => { … })`;
158
+ }
159
+
160
+ /** The effect function the single function becomes. */
161
+ function effectFunctionText(fn, deps, body) {
162
+ const prefix = fn.async ? "async " : "";
163
+ if (fn.type === "ArrowFunctionExpression") {
164
+ return `${prefix}(${paramsText(deps)}) => ${body}`;
165
+ }
166
+
167
+ return `${prefix}function${fn.generator ? "*" : ""} (${paramsText(deps)}) ${body}`;
168
+ }
169
+
2
170
  export default {
3
171
  meta: {
4
172
  type: "problem",
5
173
  docs: {
6
174
  description:
7
- "Disallow usage of dependency arrays in `createEffect` and `createMemo`.",
8
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-react-deps.md",
175
+ "Disallow dependency arrays in `createEffect`, `createRenderEffect` and `createMemo`.",
176
+ url: "https://github.com/MurkyTheMurloc/web_dev_tools/blob/main/docs/solid-2-effects.md"
9
177
  },
10
178
  fixable: "code",
179
+ hasSuggestions: true,
11
180
  schema: [],
12
181
  messages: {
13
- noUselessDep:
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.",
15
- },
182
+ effectDeps:
183
+ "`{{name}}` gets the dependency array `{{deps}}`, but Solid 2.0 has no dependency arrays: the compute function tracks what it reads, and the second argument must be the effect function. Fix: `{{fix}}`, reading each dependency in the compute function and moving the body into the effect function, which uses the parameters and still returns its cleanup. Do not: only delete the array (a one-argument `{{name}}` throws MISSING_EFFECT_FN), keep reading signals in the effect function (it runs untracked, so the effect stops re-running), wrap reads in `untrack()`, or disable the rule.",
184
+ effectMountDeps:
185
+ "`{{name}}` gets the empty dependency array `[]`, React's run-once idiom, but Solid 2.0 has no dependency arrays and expects the effect function there. Fix: `onSettled(() => { …; return cleanup; })` for one-time setup after mount; it runs once the render has settled and runs the returned cleanup on disposal. Do not: only delete the array (a one-argument `{{name}}` throws MISSING_EFFECT_FN), call `onCleanup` inside `onSettled` (Solid throws CLEANUP_IN_FORBIDDEN_SCOPE), or disable the rule.",
186
+ effectOptionsDeps:
187
+ "`{{name}}` gets the dependency array `{{deps}}` in the options slot, so it does nothing: the effect re-runs on what its compute function reads. Fix: delete `{{deps}}` and read those values in the compute function, `{{fix}}`. Do not: read them in the effect function (it runs untracked), wrap reads in `untrack()`, or disable the rule.",
188
+ memoDeps:
189
+ "`{{name}}` gets the dependency array `{{deps}}`, but Solid 2.0 has no dependency arrays: the memo tracks what its function reads, and the array lands in the options slot. Fix: delete `{{deps}}`, `{{fix}}`{{unread}}. Do not: move the array into the options object, wrap reads in `untrack()`, or disable the rule.",
190
+ deleteDeps: "Delete the dependency array.",
191
+ splitEffect:
192
+ "Split into a compute function and an effect function.",
193
+ useOnSettled: "Use `onSettled` for the one-time setup."
194
+ }
16
195
  },
17
196
  defaultOptions: [],
18
197
  create(context) {
19
- /** Tracks imports from 'solid-js', handling aliases. */
20
198
  const { matchImport, handleImportDeclaration } = trackImports();
199
+ const sourceCode = getSourceCode(context);
200
+ // Names that hold an accessor, so `[count]` can become `count()`.
201
+ const accessors = new Set();
202
+ let solidImport = null;
203
+ let onSettledName = null;
204
+
205
+ function reportEffect(node, fn, array) {
206
+ const name = node.callee.name;
207
+ const arg = node.arguments[SECOND];
208
+ const inline = arg === array && fn === node.arguments[0];
209
+
210
+ if (array.elements.length === 0) {
211
+ const importNode = onSettledName ? null : solidImport;
212
+ const canFix =
213
+ node.arguments.length === 2 &&
214
+ arg === array &&
215
+ (onSettledName !== null || importNode !== null);
216
+ context.report({
217
+ data: { name },
218
+ messageId: "effectMountDeps",
219
+ node: arg,
220
+ suggest: canFix
221
+ ? [
222
+ {
223
+ messageId: "useOnSettled",
224
+ fix: (fixer) => [
225
+ fixer.replaceText(
226
+ node,
227
+ `${onSettledName ?? "onSettled"}(${sourceCode.getText(node.arguments[0])})`
228
+ ),
229
+ ...(importNode
230
+ ? [
231
+ appendImports(
232
+ fixer,
233
+ sourceCode,
234
+ importNode,
235
+ ["onSettled"]
236
+ )
237
+ ]
238
+ : [])
239
+ ]
240
+ }
241
+ ]
242
+ : []
243
+ });
244
+ return;
245
+ }
246
+
247
+ const deps = resolveDeps(array, accessors);
248
+ const body = deps && inline && rewriteBody(fn, deps, sourceCode);
249
+ context.report({
250
+ data: {
251
+ deps: messageCode(sourceCode.getText(arg), "[…]"),
252
+ fix: effectFixText(name, deps),
253
+ name
254
+ },
255
+ messageId: "effectDeps",
256
+ node: arg,
257
+ // Never an autofix: the rewrite moves reads between phases.
258
+ suggest: body
259
+ ? [
260
+ {
261
+ messageId: "splitEffect",
262
+ fix: (fixer) =>
263
+ fixer.replaceTextRange(
264
+ [fn.range[0], array.range[1]],
265
+ `${computeText(deps)}, ${effectFunctionText(fn, deps, body)}`
266
+ )
267
+ }
268
+ ]
269
+ : []
270
+ });
271
+ }
272
+
273
+ function reportEffectOptions(node, array) {
274
+ const name = node.callee.name;
275
+ const arg = node.arguments[THIRD];
276
+ context.report({
277
+ data: {
278
+ deps: messageCode(sourceCode.getText(arg), "[…]"),
279
+ fix: effectFixText(name, resolveDeps(array, accessors)),
280
+ name
281
+ },
282
+ messageId: "effectOptionsDeps",
283
+ node: arg,
284
+ suggest:
285
+ arg === array
286
+ ? [
287
+ {
288
+ messageId: "deleteDeps",
289
+ fix: (fixer) =>
290
+ fixer.removeRange([
291
+ node.arguments[SECOND].range[1],
292
+ arg.range[1]
293
+ ])
294
+ }
295
+ ]
296
+ : []
297
+ });
298
+ }
299
+
300
+ function reportMemo(node, fn, array, index) {
301
+ const arg = node.arguments[index];
302
+ // What the memo's function reads itself.
303
+ const reads = new Set();
304
+ if (isFunctionNode(fn)) {
305
+ walkOwnBody(fn.body, (candidate) => {
306
+ const read = readText(candidate);
307
+ if (read) {
308
+ reads.add(read);
309
+ }
310
+ });
311
+ }
312
+ const unread = array.elements.flatMap((element) => {
313
+ const read =
314
+ element?.type === "Identifier"
315
+ ? `${element.name}()`
316
+ : readText(element);
317
+
318
+ return read && reads.has(read)
319
+ ? []
320
+ : [messageCode(sourceCode.getText(element), "…")];
321
+ });
322
+ const remove = (fixer) => fixer.remove(arg);
323
+ context.report({
324
+ data: {
325
+ deps: messageCode(sourceCode.getText(arg), "[…]"),
326
+ fix: `${node.callee.name}(${messageCode(sourceCode.getText(node.arguments[0]), "() => …")})`,
327
+ name: node.callee.name,
328
+ unread:
329
+ unread.length === 0
330
+ ? ""
331
+ : `; ${unread.map((text) => `\`${text}\``).join(", ")} ${unread.length === 1 ? "is" : "are"} not read in the function, so read ${unread.length === 1 ? "it" : "them"} there if the memo must recompute when ${unread.length === 1 ? "it changes" : "they change"}`
332
+ },
333
+ // Safe only when the function already reads every dep.
334
+ fix: arg === array && unread.length === 0 ? remove : undefined,
335
+ messageId: "memoDeps",
336
+ node: arg,
337
+ suggest:
338
+ arg === array && unread.length > 0
339
+ ? [{ messageId: "deleteDeps", fix: remove }]
340
+ : []
341
+ });
342
+ }
343
+
21
344
  return {
22
- ImportDeclaration: handleImportDeclaration,
23
- CallExpression(node) {
345
+ ImportDeclaration(node) {
346
+ handleImportDeclaration(node);
347
+ if (node.source.value === "solid-js") {
348
+ solidImport ??= node;
349
+ for (const specifier of node.specifiers) {
350
+ if (specifier.imported?.name === "onSettled") {
351
+ onSettledName = specifier.local.name;
352
+ }
353
+ }
354
+ }
355
+ },
356
+ VariableDeclarator(node) {
24
357
  if (
25
- node.callee.type === "Identifier" &&
26
- matchImport(
27
- ["createEffect", "createMemo"],
28
- node.callee.name,
29
- ) &&
30
- node.arguments.length === 2 &&
31
- node.arguments.every((arg) => arg.type !== "SpreadElement")
358
+ node.init?.type !== "CallExpression" ||
359
+ node.init.callee.type !== "Identifier"
32
360
  ) {
33
- // grab both arguments, tracing any variables to their actual values if possible
34
- const [arg0, arg1] = node.arguments.map((arg) =>
35
- trace(arg, context),
36
- );
37
- if (
38
- isFunctionNode(arg0) &&
39
- arg0.params.length === 0 &&
40
- arg1.type === "ArrayExpression"
41
- ) {
42
- // A second argument that looks like a dependency array was passed to
43
- // createEffect/createMemo, and the inline function doesn't accept a parameter, so it
44
- // can't just be an initial value.
45
- context.report({
46
- node: node.arguments[1], // if this is a variable, highlight the usage, not the initialization
47
- messageId: "noUselessDep",
48
- data: {
49
- name: node.callee.name,
50
- },
51
- // remove dep array if it's given inline, otherwise don't fix
52
- fix:
53
- arg1 === node.arguments[1]
54
- ? (fixer) => fixer.remove(arg1)
55
- : undefined,
56
- });
361
+ return;
362
+ }
363
+ if (matchImport(ACCESSOR_PAIRS, node.init.callee.name)) {
364
+ const getter = getGetterName(node);
365
+ if (getter) {
366
+ accessors.add(getter);
57
367
  }
368
+ } else if (
369
+ matchImport("createMemo", node.init.callee.name) &&
370
+ node.id.type === "Identifier"
371
+ ) {
372
+ accessors.add(node.id.name);
58
373
  }
59
374
  },
375
+ CallExpression(node) {
376
+ if (
377
+ node.callee.type !== "Identifier" ||
378
+ node.arguments.length < 2 ||
379
+ node.arguments.some((arg) => arg.type === "SpreadElement")
380
+ ) {
381
+ return;
382
+ }
383
+ const isEffect = Boolean(
384
+ matchImport(EFFECTS, node.callee.name)
385
+ );
386
+ if (!isEffect && !matchImport("createMemo", node.callee.name)) {
387
+ return;
388
+ }
389
+
390
+ // Trace variables to their values; a reported variable is
391
+ // highlighted at the call, not at its declaration.
392
+ const [fn, second, third] = node.arguments.map((arg) =>
393
+ trace(arg, context)
394
+ );
395
+ if (
396
+ second.type === "ArrayExpression" &&
397
+ isFunctionNode(fn) &&
398
+ // With a parameter, the second argument can be a seed.
399
+ fn.params.length === 0
400
+ ) {
401
+ if (isEffect) {
402
+ reportEffect(node, fn, second);
403
+ } else {
404
+ reportMemo(node, fn, second, SECOND);
405
+ }
406
+ return;
407
+ }
408
+ if (third?.type === "ArrayExpression") {
409
+ if (isEffect) {
410
+ reportEffectOptions(node, third);
411
+ } else {
412
+ reportMemo(node, fn, third, THIRD);
413
+ }
414
+ }
415
+ }
60
416
  };
61
- },
417
+ }
62
418
  };
@@ -1,8 +1,14 @@
1
- import { isDOMElementName, jsxGetProp, jsxHasProp } from "../utils.mjs";
1
+ import { getSourceCode } from "../compat.mjs";
2
+ import {
3
+ isDOMElementName,
4
+ jsxGetProp,
5
+ jsxHasProp,
6
+ messageCode
7
+ } from "../utils.mjs";
2
8
 
3
9
  const REACT_SPECIFIC_PROPS = [
4
10
  { from: "className", to: "class" },
5
- { from: "htmlFor", to: "for" },
11
+ { from: "htmlFor", to: "for" }
6
12
  ];
7
13
 
8
14
  export const noReactSpecificPropsRule = {
@@ -10,16 +16,16 @@ export const noReactSpecificPropsRule = {
10
16
  docs: {
11
17
  description:
12
18
  "Disallow usage of React-specific className/htmlFor props.",
13
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-react-specific-props.md",
19
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-react-specific-props.md"
14
20
  },
15
21
  fixable: "code",
16
22
  messages: {
17
23
  noUselessKey:
18
- "Elements in a <For> or <Index> list do not need a key prop.",
19
- prefer: "Prefer the `{{ to }}` prop over the deprecated `{{ from }}` prop.",
24
+ "`key` on `<{{element}}>` is React's list key. Solid gives it no meaning and sets it as a plain `key` attribute; `<For>` keys rows by item identity. Fix: remove `{{key}}`; to key a list by a field, `<For each={items()} keyed={(item) => item.id}>`.",
25
+ prefer: "`{{ from }}` is React's name for `{{ to }}`, and Solid 2.0 has no such alias: {{ effect }}. Fix: `{{ fix }}`{{ merge }}."
20
26
  },
21
27
  schema: [],
22
- type: "problem",
28
+ type: "problem"
23
29
  },
24
30
  defaultOptions: [],
25
31
  create(context) {
@@ -37,11 +43,27 @@ export const noReactSpecificPropsRule = {
37
43
  }
38
44
  : undefined;
39
45
 
46
+ const hasTarget = jsxHasProp(node.attributes, to);
47
+ const value = attribute.value
48
+ ? `=${getSourceCode(context).getText(attribute.value)}`
49
+ : "";
40
50
  context.report({
41
- data: { from, to },
51
+ data: {
52
+ from,
53
+ to,
54
+ effect:
55
+ node.name.type === "JSXIdentifier" &&
56
+ isDOMElementName(node.name.name)
57
+ ? `it sets an unknown \`${from}\` attribute and the element gets no \`${to}\``
58
+ : `the component receives a \`${from}\` prop, not \`${to}\``,
59
+ fix: messageCode(`${to}${value}`, `${to}={…}`),
60
+ merge: hasTarget
61
+ ? `, merged into the \`${to}\` the element already has`
62
+ : ""
63
+ },
42
64
  fix,
43
65
  messageId: "prefer",
44
- node: attribute,
66
+ node: attribute
45
67
  });
46
68
  }
47
69
 
@@ -55,14 +77,21 @@ export const noReactSpecificPropsRule = {
55
77
  }
56
78
 
57
79
  context.report({
80
+ data: {
81
+ element: node.name.name,
82
+ key: messageCode(
83
+ getSourceCode(context).getText(keyProp),
84
+ "key"
85
+ )
86
+ },
58
87
  fix(fixer) {
59
88
  return fixer.remove(keyProp);
60
89
  },
61
90
  messageId: "noUselessKey",
62
- node: keyProp,
91
+ node: keyProp
63
92
  });
64
93
  }
65
- },
94
+ }
66
95
  };
67
- },
96
+ }
68
97
  };
@@ -42,7 +42,7 @@ const CONTINUING_CHARACTERS = new Set([
42
42
  "|",
43
43
  "^",
44
44
  "/",
45
- "`",
45
+ "`"
46
46
  ]);
47
47
 
48
48
  function isDirectory(path) {
@@ -118,7 +118,7 @@ function findModuleFile(basePath) {
118
118
  basePath,
119
119
  ...EXTENSIONS.map((extension) => `${basePath}${extension}`),
120
120
  ...EXTENSIONS.map((extension) => `${withoutJsExtension}${extension}`),
121
- ...EXTENSIONS.map((extension) => join(basePath, `index${extension}`)),
121
+ ...EXTENSIONS.map((extension) => join(basePath, `index${extension}`))
122
122
  ];
123
123
 
124
124
  return candidates.find(isFile) ?? null;
@@ -260,7 +260,7 @@ function resolveImport(specifier, filename, projectRoot) {
260
260
  return resolve(
261
261
  projectRoot,
262
262
  "src",
263
- specifier.slice(ALIAS_PREFIX.length),
263
+ specifier.slice(ALIAS_PREFIX.length)
264
264
  );
265
265
  }
266
266
 
@@ -298,13 +298,13 @@ export const noServerImportInClientRule = {
298
298
  docs: {
299
299
  description:
300
300
  "Disallow importing modules from src/server/ into client code unless they are use-server modules.",
301
- url: "https://docs.solidjs.com/",
301
+ url: "https://docs.solidjs.com/"
302
302
  },
303
303
  schema: [],
304
304
  messages: {
305
305
  serverImportInClient:
306
- '\'{{specifier}}\' lives under src/server/ but does not have the "use server" directive, so importing it into client code ships server-only code to the browser. Import a server function module instead (a `"use server";` directive at the top, async exports only), and keep database clients and secrets inside it.',
307
- },
306
+ '`{{specifier}}` is under src/server/ without a `"use server"` directive, so this import ships server-only code (database clients, secrets) to the browser. Fix: import a server function module instead, one that starts with `"use server";` and exports async functions; for types only, `import type`. Do not: add `"use server"` to `{{specifier}}`; each exported function becomes a browser-callable endpoint.'
307
+ }
308
308
  },
309
309
  defaultOptions: [],
310
310
  create(context) {
@@ -347,7 +347,7 @@ export const noServerImportInClientRule = {
347
347
  context.report({
348
348
  node: sourceNode,
349
349
  messageId: "serverImportInClient",
350
- data: { specifier },
350
+ data: { specifier }
351
351
  });
352
352
  }
353
353
 
@@ -379,7 +379,7 @@ export const noServerImportInClientRule = {
379
379
  ) {
380
380
  check(node.arguments[0]);
381
381
  }
382
- },
382
+ }
383
383
  };
384
- },
384
+ }
385
385
  };