@murky-web/oxlint-plugin-solid 1.4.1 → 1.5.1

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.
@@ -2,13 +2,13 @@ import {
2
2
  isFunctionNode,
3
3
  trackImports,
4
4
  isPropsByName,
5
- trace,
5
+ trace
6
6
  } from "../utils.mjs";
7
7
  // Store APIs that hand back a Proxy. Solid 2.0 exports these from `solid-js`.
8
8
  const PROXY_BACKED_STORE_APIS = new Set([
9
9
  "createStore",
10
10
  "createProjection",
11
- "createOptimisticStore",
11
+ "createOptimisticStore"
12
12
  ]);
13
13
  export default {
14
14
  meta: {
@@ -16,7 +16,7 @@ export default {
16
16
  docs: {
17
17
  description:
18
18
  "Disallow usage of APIs that use ES6 Proxies, only to target environments that don't support them.",
19
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-proxy-apis.md",
19
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-proxy-apis.md"
20
20
  },
21
21
  schema: [],
22
22
  messages: {
@@ -29,8 +29,8 @@ export default {
29
29
  proxyLiteral:
30
30
  "Proxies are incompatible with your target environment.",
31
31
  mergeProps:
32
- "If you pass a function to `mergeProps`, it will create a Proxy, which are incompatible with your target environment.",
33
- },
32
+ "If you pass a function to `mergeProps`, it will create a Proxy, which are incompatible with your target environment."
33
+ }
34
34
  },
35
35
  defaultOptions: [],
36
36
  create(context) {
@@ -57,7 +57,7 @@ export default {
57
57
  ) {
58
58
  context.report({
59
59
  node: specifier,
60
- messageId: "noStore",
60
+ messageId: "noStore"
61
61
  });
62
62
  }
63
63
  }
@@ -86,7 +86,7 @@ export default {
86
86
  .forEach((badArg) => {
87
87
  context.report({
88
88
  node: badArg,
89
- messageId: "mergeProps",
89
+ messageId: "mergeProps"
90
90
  });
91
91
  });
92
92
  }
@@ -99,7 +99,7 @@ export default {
99
99
  ) {
100
100
  context.report({
101
101
  node,
102
- messageId: "proxyLiteral",
102
+ messageId: "proxyLiteral"
103
103
  });
104
104
  }
105
105
  }
@@ -111,7 +111,7 @@ export default {
111
111
  ) {
112
112
  context.report({ node, messageId: "proxyLiteral" });
113
113
  }
114
- },
114
+ }
115
115
  };
116
- },
116
+ }
117
117
  };
@@ -5,14 +5,14 @@ export default {
5
5
  docs: {
6
6
  description:
7
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",
8
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-react-deps.md"
9
9
  },
10
10
  fixable: "code",
11
11
  schema: [],
12
12
  messages: {
13
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
- },
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
+ }
16
16
  },
17
17
  defaultOptions: [],
18
18
  create(context) {
@@ -25,14 +25,14 @@ export default {
25
25
  node.callee.type === "Identifier" &&
26
26
  matchImport(
27
27
  ["createEffect", "createMemo"],
28
- node.callee.name,
28
+ node.callee.name
29
29
  ) &&
30
30
  node.arguments.length === 2 &&
31
31
  node.arguments.every((arg) => arg.type !== "SpreadElement")
32
32
  ) {
33
33
  // grab both arguments, tracing any variables to their actual values if possible
34
34
  const [arg0, arg1] = node.arguments.map((arg) =>
35
- trace(arg, context),
35
+ trace(arg, context)
36
36
  );
37
37
  if (
38
38
  isFunctionNode(arg0) &&
@@ -46,17 +46,17 @@ export default {
46
46
  node: node.arguments[1], // if this is a variable, highlight the usage, not the initialization
47
47
  messageId: "noUselessDep",
48
48
  data: {
49
- name: node.callee.name,
49
+ name: node.callee.name
50
50
  },
51
51
  // remove dep array if it's given inline, otherwise don't fix
52
52
  fix:
53
53
  arg1 === node.arguments[1]
54
54
  ? (fixer) => fixer.remove(arg1)
55
- : undefined,
55
+ : undefined
56
56
  });
57
57
  }
58
58
  }
59
- },
59
+ }
60
60
  };
61
- },
61
+ }
62
62
  };
@@ -2,7 +2,7 @@ import { isDOMElementName, jsxGetProp, jsxHasProp } from "../utils.mjs";
2
2
 
3
3
  const REACT_SPECIFIC_PROPS = [
4
4
  { from: "className", to: "class" },
5
- { from: "htmlFor", to: "for" },
5
+ { from: "htmlFor", to: "for" }
6
6
  ];
7
7
 
8
8
  export const noReactSpecificPropsRule = {
@@ -10,16 +10,16 @@ export const noReactSpecificPropsRule = {
10
10
  docs: {
11
11
  description:
12
12
  "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",
13
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-react-specific-props.md"
14
14
  },
15
15
  fixable: "code",
16
16
  messages: {
17
17
  noUselessKey:
18
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.",
19
+ prefer: "Prefer the `{{ to }}` prop over the deprecated `{{ from }}` prop."
20
20
  },
21
21
  schema: [],
22
- type: "problem",
22
+ type: "problem"
23
23
  },
24
24
  defaultOptions: [],
25
25
  create(context) {
@@ -41,7 +41,7 @@ export const noReactSpecificPropsRule = {
41
41
  data: { from, to },
42
42
  fix,
43
43
  messageId: "prefer",
44
- node: attribute,
44
+ node: attribute
45
45
  });
46
46
  }
47
47
 
@@ -59,10 +59,10 @@ export const noReactSpecificPropsRule = {
59
59
  return fixer.remove(keyProp);
60
60
  },
61
61
  messageId: "noUselessKey",
62
- node: keyProp,
62
+ node: keyProp
63
63
  });
64
64
  }
65
- },
65
+ }
66
66
  };
67
- },
67
+ }
68
68
  };
@@ -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}}\' 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
+ }
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
  };
@@ -58,7 +58,7 @@ function writesSignalsAnywhere(node, setterNames) {
58
58
  candidate !== null &&
59
59
  typeof candidate === "object" &&
60
60
  !isFunctionNode(candidate) &&
61
- writesSignalsAnywhere(candidate, setterNames),
61
+ writesSignalsAnywhere(candidate, setterNames)
62
62
  );
63
63
  });
64
64
  }
@@ -76,7 +76,7 @@ function onlyWritesSignals(phase, setterNames) {
76
76
  body.every(
77
77
  (statement) =>
78
78
  statement.type === "ExpressionStatement" &&
79
- isSetterCall(statement.expression, setterNames),
79
+ isSetterCall(statement.expression, setterNames)
80
80
  )
81
81
  );
82
82
  }
@@ -87,15 +87,15 @@ export default {
87
87
  docs: {
88
88
  description:
89
89
  "Disallow effects that only copy a reactive value into another signal or store.",
90
- url: "https://docs.solidjs.com/",
90
+ url: "https://docs.solidjs.com/"
91
91
  },
92
92
  schema: [],
93
93
  messages: {
94
94
  asyncSetterInEffect:
95
95
  "This effect awaits and then writes the result into a signal or store. Return the value from a derivation instead: `createMemo(async () => ...)`, or the function form of `createStore` for nested data. Solid coordinates readiness, error propagation, and dropping superseded runs.",
96
96
  noSetterInEffect:
97
- "This effect only writes to a signal or store. Calculate the value where it is read instead: a derived function, `createMemo`, or a writable derived `createSignal(() => ...)` for a local override.",
98
- },
97
+ "This effect only writes to a signal or store. Calculate the value where it is read instead: a derived function, `createMemo`, or a writable derived `createSignal(() => ...)` for a local override."
98
+ }
99
99
  },
100
100
  defaultOptions: [],
101
101
  create(context) {
@@ -110,7 +110,7 @@ export default {
110
110
  node.init.callee.type !== "Identifier" ||
111
111
  !matchImport(
112
112
  ["createSignal", "createStore"],
113
- node.init.callee.name,
113
+ node.init.callee.name
114
114
  )
115
115
  ) {
116
116
  return;
@@ -126,7 +126,7 @@ export default {
126
126
  node.callee.type !== "Identifier" ||
127
127
  !matchImport(
128
128
  ["createEffect", "createRenderEffect"],
129
- node.callee.name,
129
+ node.callee.name
130
130
  )
131
131
  ) {
132
132
  return;
@@ -151,7 +151,7 @@ export default {
151
151
  ) {
152
152
  context.report({
153
153
  node: phase,
154
- messageId: "asyncSetterInEffect",
154
+ messageId: "asyncSetterInEffect"
155
155
  });
156
156
  return;
157
157
  }
@@ -159,10 +159,10 @@ export default {
159
159
  if (onlyWritesSignals(phase, setterNames)) {
160
160
  context.report({
161
161
  node: phase,
162
- messageId: "noSetterInEffect",
162
+ messageId: "noSetterInEffect"
163
163
  });
164
164
  }
165
- },
165
+ }
166
166
  };
167
- },
167
+ }
168
168
  };
@@ -12,7 +12,7 @@ const replacements = {
12
12
  "a camel-case event prop, or a ref callback with `addEventListener` when capture is needed",
13
13
  prop: "the standard property",
14
14
  style: "the `style` prop with an object value",
15
- use: "a ref callback or directive factory, composing with a ref array",
15
+ use: "a ref callback or directive factory, composing with a ref array"
16
16
  };
17
17
  export default {
18
18
  meta: {
@@ -20,7 +20,7 @@ export default {
20
20
  docs: {
21
21
  description:
22
22
  "Disallow Solid's removed JSX attribute namespaces. Solid 2.0 dropped `on:`, `oncapture:`, `use:`, `prop:`, `attr:`, `bool:`, `class:` and `style:`.",
23
- url: "https://docs.solidjs.com/",
23
+ url: "https://docs.solidjs.com/"
24
24
  },
25
25
  schema: [
26
26
  {
@@ -31,34 +31,53 @@ export default {
31
31
  "an array of additional namespace names to allow",
32
32
  type: "array",
33
33
  items: {
34
- type: "string",
34
+ type: "string"
35
35
  },
36
- default: [],
37
36
  minItems: 1,
38
- uniqueItems: true,
37
+ uniqueItems: true
39
38
  },
39
+ allowedNamespacedProps: {
40
+ description:
41
+ "an array of exact namespaced prop names to allow, such as `client:visible`",
42
+ type: "array",
43
+ items: {
44
+ type: "string",
45
+ pattern: "^[^:]+:[^:]+$"
46
+ },
47
+ minItems: 1,
48
+ uniqueItems: true
49
+ }
40
50
  },
41
- additionalProperties: false,
42
- },
51
+ additionalProperties: false
52
+ }
43
53
  ],
44
54
  messages: {
45
55
  removed:
46
56
  "'{{namespace}}:' was removed in Solid 2.0. Use {{replacement}} instead.",
47
57
  unknown:
48
58
  "'{{namespace}}:' is not a namespace Solid understands. Solid 2.0 has no special JSX prefixes.",
49
- component: "Namespaced props have no effect on components.",
50
- },
59
+ component: "Namespaced props have no effect on components."
60
+ }
51
61
  },
52
62
  defaultOptions: [],
53
63
  create(context) {
54
64
  const explicitlyAllowedNamespaces =
55
65
  context.options?.[0]?.allowedNamespaces;
66
+ const explicitlyAllowedProps =
67
+ context.options?.[0]?.allowedNamespacedProps;
56
68
  return {
57
69
  "JSXAttribute > JSXNamespacedName": (node) => {
58
70
  const namespace = node.namespace?.name;
59
- // The allow list covers every element: a framework can give a
71
+ // Both allow lists cover every element: a framework can give a
60
72
  // namespace meaning on components (`<Island client:visible>`).
61
- if (explicitlyAllowedNamespaces?.includes(namespace)) {
73
+ // `allowedNamespacedProps` names single props, so a typo or an
74
+ // unsupported prop of the same namespace is still reported.
75
+ if (
76
+ explicitlyAllowedNamespaces?.includes(namespace) ||
77
+ explicitlyAllowedProps?.includes(
78
+ `${namespace}:${node.name?.name}`
79
+ )
80
+ ) {
62
81
  return;
63
82
  }
64
83
  const openingElement = node.parent.parent;
@@ -80,16 +99,16 @@ export default {
80
99
  context.report({
81
100
  node,
82
101
  messageId: "removed",
83
- data: { namespace, replacement },
102
+ data: { namespace, replacement }
84
103
  });
85
104
  return;
86
105
  }
87
106
  context.report({
88
107
  node,
89
108
  messageId: "unknown",
90
- data: { namespace },
109
+ data: { namespace }
91
110
  });
92
- },
111
+ }
93
112
  };
94
- },
113
+ }
95
114
  };
@@ -81,13 +81,13 @@ export default {
81
81
  docs: {
82
82
  description:
83
83
  "Disallow reading reactive values in the untracked apply phase of an effect.",
84
- url: "https://docs.solidjs.com/",
84
+ url: "https://docs.solidjs.com/"
85
85
  },
86
86
  schema: [],
87
87
  messages: {
88
88
  untrackedEffectRead:
89
- "'{{name}}' is read in the effect's apply phase, which runs untracked — changes to it will not re-run this effect. Read it in the compute phase and take it as an argument instead.",
90
- },
89
+ "'{{name}}' is read in the effect's apply phase, which runs untracked — changes to it will not re-run this effect. Read it in the compute phase and take it as an argument instead."
90
+ }
91
91
  },
92
92
  defaultOptions: [],
93
93
  create(context) {
@@ -115,7 +115,7 @@ export default {
115
115
  node.callee.type !== "Identifier" ||
116
116
  !matchImport(
117
117
  ["createEffect", "createRenderEffect"],
118
- node.callee.name,
118
+ node.callee.name
119
119
  )
120
120
  ) {
121
121
  return;
@@ -145,7 +145,7 @@ export default {
145
145
  context.report({
146
146
  node: candidate,
147
147
  messageId: "untrackedEffectRead",
148
- data: { name: candidate.callee.name },
148
+ data: { name: candidate.callee.name }
149
149
  });
150
150
  return;
151
151
  }
@@ -164,12 +164,12 @@ export default {
164
164
  node: candidate,
165
165
  messageId: "untrackedEffectRead",
166
166
  data: {
167
- name: `${candidate.object.name}.${candidate.property.name}`,
168
- },
167
+ name: `${candidate.object.name}.${candidate.property.name}`
168
+ }
169
169
  });
170
170
  }
171
171
  });
172
- },
172
+ }
173
173
  };
174
- },
174
+ }
175
175
  };
@@ -105,7 +105,7 @@ function getPropsParam(functionNode, sourceCode) {
105
105
  if (functionNode.params.length === NO_PARAMETERS) {
106
106
  return {
107
107
  name: "",
108
- text: "",
108
+ text: ""
109
109
  };
110
110
  }
111
111
 
@@ -117,14 +117,14 @@ function getPropsParam(functionNode, sourceCode) {
117
117
  if (param.type === "Identifier") {
118
118
  return {
119
119
  name: param.name,
120
- text: param.name,
120
+ text: param.name
121
121
  };
122
122
  }
123
123
 
124
124
  if (param.type === "ObjectPattern") {
125
125
  return {
126
126
  name: "",
127
- text: sourceCode.getText(param),
127
+ text: sourceCode.getText(param)
128
128
  };
129
129
  }
130
130
 
@@ -307,11 +307,11 @@ export const preferArrowComponentsRule = {
307
307
  docs: {
308
308
  description:
309
309
  "Prefer Solid components written as arrow consts typed with Component or ParentComponent.",
310
- recommended: false,
310
+ recommended: false
311
311
  },
312
312
  fixable: "code",
313
313
  schema: [],
314
- type: "suggestion",
314
+ type: "suggestion"
315
315
  },
316
316
  create(context) {
317
317
  const sourceCode = context.sourceCode;
@@ -361,20 +361,20 @@ export const preferArrowComponentsRule = {
361
361
  const plans = candidates.map((candidate) => {
362
362
  const localTypeName = findLocalTypeName(
363
363
  solidImports,
364
- candidate.desiredTypeName,
364
+ candidate.desiredTypeName
365
365
  );
366
366
 
367
367
  return {
368
368
  ...candidate,
369
369
  fixable: !isUsedBeforeDeclaration(
370
370
  candidate.node,
371
- firstJsxUse,
371
+ firstJsxUse
372
372
  ),
373
373
  resolvedTypeName:
374
374
  localTypeName === ""
375
375
  ? candidate.desiredTypeName
376
376
  : localTypeName,
377
- needsImport: localTypeName === "",
377
+ needsImport: localTypeName === ""
378
378
  };
379
379
  });
380
380
 
@@ -397,7 +397,7 @@ export const preferArrowComponentsRule = {
397
397
  referencedTypes.has(name) &&
398
398
  findLocalTypeName(solidImports, name) === ""
399
399
  );
400
- }),
400
+ })
401
401
  ]) {
402
402
  if (!namesToImport.includes(name)) {
403
403
  namesToImport.push(name);
@@ -419,7 +419,7 @@ export const preferArrowComponentsRule = {
419
419
  fixer,
420
420
  sourceCode,
421
421
  target,
422
- namesToImport.map((name) => `${typeKeyword}${name}`),
422
+ namesToImport.map((name) => `${typeKeyword}${name}`)
423
423
  );
424
424
  }
425
425
 
@@ -429,7 +429,7 @@ export const preferArrowComponentsRule = {
429
429
  SOLID_IMPORT_SOURCE,
430
430
  namesToImport,
431
431
  undefined,
432
- true,
432
+ true
433
433
  );
434
434
  };
435
435
 
@@ -459,7 +459,7 @@ export const preferArrowComponentsRule = {
459
459
  }
460
460
 
461
461
  const edits = [
462
- fixer.replaceText(nodeToReplace, replacement),
462
+ fixer.replaceText(nodeToReplace, replacement)
463
463
  ];
464
464
  if (
465
465
  plan === carrier &&
@@ -474,7 +474,7 @@ export const preferArrowComponentsRule = {
474
474
  return edits;
475
475
  },
476
476
  message,
477
- node,
477
+ node
478
478
  });
479
479
  }
480
480
  };
@@ -489,7 +489,7 @@ export const preferArrowComponentsRule = {
489
489
  const propsParam = getPropsParam(node, sourceCode);
490
490
  const typeReference = getTypeReferenceForProps(
491
491
  node,
492
- sourceCode,
492
+ sourceCode
493
493
  );
494
494
  if (
495
495
  propsParam === FALSE_SENTINEL ||
@@ -506,9 +506,9 @@ export const preferArrowComponentsRule = {
506
506
  desiredTypeName: getDesiredSolidTypeName(usesChildren),
507
507
  node,
508
508
  propsParam,
509
- typeReference,
509
+ typeReference
510
510
  });
511
- },
511
+ }
512
512
  };
513
- },
513
+ }
514
514
  };