@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
@@ -34,7 +34,7 @@ export default {
34
34
  docs: {
35
35
  description:
36
36
  "Disallow extra closing tags for components without children.",
37
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/self-closing-comp.md",
37
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/self-closing-comp.md"
38
38
  },
39
39
  fixable: "code",
40
40
  schema: [
@@ -46,23 +46,25 @@ export default {
46
46
  description:
47
47
  "which Solid components should be self-closing when possible",
48
48
  enum: ["all", "none"],
49
- default: "all",
49
+ default: "all"
50
50
  },
51
51
  html: {
52
52
  type: "string",
53
53
  description:
54
54
  "which native elements should be self-closing when possible",
55
55
  enum: ["all", "void", "none"],
56
- default: "all",
57
- },
56
+ default: "all"
57
+ }
58
58
  },
59
- additionalProperties: false,
60
- },
59
+ additionalProperties: false
60
+ }
61
61
  ],
62
62
  messages: {
63
- selfClose: "Empty components are self-closing.",
64
- dontSelfClose: "This element should not be self-closing.",
65
- },
63
+ selfClose:
64
+ "`<{{name}}></{{name}}>` has no children, so the closing tag only adds noise. Fix: `<{{name}} />`.",
65
+ dontSelfClose:
66
+ "`<{{name}} />` is written self-closing, and this rule's `component`/`html` options ask for an explicit closing tag on `<{{name}}>`. Fix: `<{{name}}></{{name}}>`."
67
+ }
66
68
  },
67
69
  defaultOptions: [],
68
70
  create(context) {
@@ -93,10 +95,12 @@ export default {
93
95
  if (canSelfClose) {
94
96
  const shouldSelfClose =
95
97
  shouldBeSelfClosedWhenPossible(node);
98
+ const name = getSourceCode(context).getText(node.name);
96
99
  if (shouldSelfClose && !node.selfClosing) {
97
100
  context.report({
98
101
  node,
99
102
  messageId: "selfClose",
103
+ data: { name },
100
104
  fix(fixer) {
101
105
  // Represents the last character of the JSXOpeningElement, the '>' character
102
106
  const openingElementEnding = node.range[1] - 1;
@@ -106,15 +110,16 @@ export default {
106
110
  // Replace />.*<\/.*>/ with '/>'
107
111
  const range = [
108
112
  openingElementEnding,
109
- closingElementEnding,
113
+ closingElementEnding
110
114
  ];
111
115
  return fixer.replaceTextRange(range, " />");
112
- },
116
+ }
113
117
  });
114
118
  } else if (!shouldSelfClose && node.selfClosing) {
115
119
  context.report({
116
120
  node,
117
121
  messageId: "dontSelfClose",
122
+ data: { name },
118
123
  fix(fixer) {
119
124
  const sourceCode = getSourceCode(context);
120
125
  const tagName = sourceCode.getText(node.name);
@@ -123,28 +128,28 @@ export default {
123
128
  // Replace ' />' or '/>' with '></${tagName}>'
124
129
  const lastTokens = sourceCode.getLastTokens(
125
130
  node,
126
- { count: 3 },
131
+ { count: 3 }
127
132
  ); // JSXIdentifier, '/', '>'
128
133
  const isSpaceBeforeSelfClose =
129
134
  sourceCode.isSpaceBetween?.(
130
135
  lastTokens[0],
131
- lastTokens[1],
136
+ lastTokens[1]
132
137
  );
133
138
  const range = [
134
139
  isSpaceBeforeSelfClose
135
140
  ? selfCloseEnding - 3
136
141
  : selfCloseEnding - 2,
137
- selfCloseEnding,
142
+ selfCloseEnding
138
143
  ];
139
144
  return fixer.replaceTextRange(
140
145
  range,
141
- `></${tagName}>`,
146
+ `></${tagName}>`
142
147
  );
143
- },
148
+ }
144
149
  });
145
150
  }
146
151
  }
147
- },
152
+ }
148
153
  };
149
- },
154
+ }
150
155
  };
@@ -1,4 +1,10 @@
1
- import { isFunctionNode, jsxPropName, trackImports } from "../utils.mjs";
1
+ import { getSourceCode } from "../compat.mjs";
2
+ import {
3
+ isFunctionNode,
4
+ jsxPropName,
5
+ messageCode,
6
+ trackImports
7
+ } from "../utils.mjs";
2
8
 
3
9
  const EVENT_HANDLER_NAME = /^on(?::|[A-Z])/;
4
10
  const DOM_EVENT_NAME = /^on[a-z]/;
@@ -14,7 +20,7 @@ const PLAIN_VALUE_TYPES = new Set([
14
20
  "Literal",
15
21
  "ObjectExpression",
16
22
  "TemplateLiteral",
17
- "UpdateExpression",
23
+ "UpdateExpression"
18
24
  ]);
19
25
 
20
26
  function isVoidExpression(expression) {
@@ -25,6 +31,16 @@ function isVoidExpression(expression) {
25
31
  );
26
32
  }
27
33
 
34
+ // `(el) => (input = el)` as `(el) => { input = el; }`: the arrow up to its
35
+ // `=>`, then the body as a statement. Parentheses around the body are not in
36
+ // its range, so they are dropped with everything between `=>` and the body.
37
+ function blockBody(callback, sourceCode) {
38
+ const text = sourceCode.getText(callback);
39
+ const head = text.slice(0, callback.body.range[0] - callback.range[0]);
40
+ const arrow = head.slice(0, head.lastIndexOf("=>") + 2);
41
+ return `${arrow} { ${sourceCode.getText(callback.body)}; }`;
42
+ }
43
+
28
44
  function describe(expression) {
29
45
  return expression.type === "CallExpression"
30
46
  ? "the call's result"
@@ -79,21 +95,22 @@ export const strictVoidReturnRule = {
79
95
  docs: {
80
96
  description:
81
97
  "Disallow returning a value from callbacks Solid ignores the return of (event handlers, ref callbacks, onCleanup, onSettled).",
82
- url: "https://docs.solidjs.com/",
98
+ url: "https://docs.solidjs.com/"
83
99
  },
84
100
  schema: [],
85
101
  messages: {
86
102
  handlerReturnsValue:
87
- "This `{{attribute}}` callback is an expression-bodied arrow, so it returns {{what}}, which Solid ignores. Write a block body (`() => { … }`) or discard it explicitly with `void …`.",
103
+ "The `{{attribute}}` callback is an expression-bodied arrow, so it returns {{what}}, which Solid ignores: a returned cleanup, promise or `false` does nothing there. Fix: a block body, `{{attribute}}={{{fix}}}`.",
88
104
  cleanupReturnsValue:
89
- "This `{{primitive}}` callback returns a value, which is ignored. Remove the `return`, or use a block body that does not return.",
105
+ "The `{{primitive}}` callback returns `{{value}}`, which Solid ignores. Fix: {{fix}}",
90
106
  settledReturnsValue:
91
- "This `onSettled` callback returns a value that is not a function. Only a returned cleanup function is used; remove the `return` or return `() => { … }`.",
92
- },
107
+ "The `onSettled` callback returns `{{value}}`, which is not a function. Solid only uses a returned cleanup function and ignores anything else. Fix: return nothing, or return the cleanup, `return () => { … };`."
108
+ }
93
109
  },
94
110
  defaultOptions: [],
95
111
  create(context) {
96
112
  const { matchImport, handleImportDeclaration } = trackImports();
113
+ const sourceCode = getSourceCode(context);
97
114
 
98
115
  function checkHandler(callback, attribute) {
99
116
  if (
@@ -110,7 +127,11 @@ export const strictVoidReturnRule = {
110
127
  data: {
111
128
  attribute,
112
129
  what: describe(callback.body),
113
- },
130
+ fix: messageCode(
131
+ blockBody(callback, sourceCode),
132
+ "(event) => { … }"
133
+ )
134
+ }
114
135
  });
115
136
  }
116
137
 
@@ -124,20 +145,29 @@ export const strictVoidReturnRule = {
124
145
 
125
146
  // A call may well return nothing (`() => clearInterval(id)`); without
126
147
  // types only values that are certainly not void are reported.
127
- if (
128
- values.some(
129
- (value) =>
130
- PLAIN_VALUE_TYPES.has(value.type) &&
131
- !isVoidExpression(value),
132
- )
133
- ) {
148
+ const returned = values.find(
149
+ (value) =>
150
+ PLAIN_VALUE_TYPES.has(value.type) &&
151
+ !isVoidExpression(value)
152
+ );
153
+ if (returned) {
154
+ const value = messageCode(sourceCode.getText(returned), "…");
134
155
  context.report({
135
156
  node: callback,
136
157
  messageId:
137
158
  primitive === "onSettled"
138
159
  ? "settledReturnsValue"
139
160
  : "cleanupReturnsValue",
140
- data: { primitive },
161
+ data: {
162
+ primitive,
163
+ value,
164
+ // An expression body becomes a statement; a block
165
+ // keeps its code and drops the returned value.
166
+ fix:
167
+ callback.body.type === "BlockStatement"
168
+ ? `drop the value, \`return;\` in place of \`return ${value};\`.`
169
+ : `a block body, \`${primitive}(${messageCode(blockBody(callback, sourceCode), "() => { … }")})\`.`
170
+ }
141
171
  });
142
172
  }
143
173
  }
@@ -163,7 +193,7 @@ export const strictVoidReturnRule = {
163
193
 
164
194
  if (name === "ref") {
165
195
  for (const callback of getRefCallbacks(
166
- node.value.expression,
196
+ node.value.expression
167
197
  )) {
168
198
  checkHandler(callback, "ref");
169
199
  }
@@ -190,12 +220,12 @@ export const strictVoidReturnRule = {
190
220
 
191
221
  const primitive = matchImport(
192
222
  [...CLEANUP_PRIMITIVES, ...SETTLED_PRIMITIVES],
193
- node.callee.name,
223
+ node.callee.name
194
224
  );
195
225
  if (primitive) {
196
226
  checkCleanup(callback, primitive);
197
227
  }
198
- },
228
+ }
199
229
  };
200
- },
230
+ }
201
231
  };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getPropertyName,
3
- getStaticValue,
3
+ getStaticValue
4
4
  } from "@eslint-community/eslint-utils";
5
5
  import kebabCase from "kebab-case";
6
6
  import { all as allCssProperties } from "known-css-properties";
7
7
  import parse from "style-to-object";
8
8
 
9
- import { getScope } from "../compat.mjs";
10
- import { jsxPropName } from "../utils.mjs";
9
+ import { getScope, getSourceCode } from "../compat.mjs";
10
+ import { jsxPropName, messageCode } from "../utils.mjs";
11
11
  const lengthPercentageRegex =
12
12
  /\b(?:width|height|margin|padding|border-width|font-size)\b/i;
13
13
  export default {
@@ -17,7 +17,7 @@ export default {
17
17
  description:
18
18
  "Require CSS properties in the `style` prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, " +
19
19
  "and that property values with dimensions are strings, not numbers with implicit 'px' units.",
20
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/style-prop.md",
20
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/style-prop.md"
21
21
  },
22
22
  fixable: "code",
23
23
  schema: [
@@ -30,35 +30,38 @@ export default {
30
30
  default: ["style"],
31
31
  type: "array",
32
32
  items: {
33
- type: "string",
33
+ type: "string"
34
34
  },
35
35
  minItems: 1,
36
- uniqueItems: true,
36
+ uniqueItems: true
37
37
  },
38
38
  allowString: {
39
39
  description:
40
40
  "if allowString is set to true, this rule will not convert a style string literal into a style object (not recommended for performance)",
41
41
  type: "boolean",
42
- default: false,
43
- },
42
+ default: false
43
+ }
44
44
  },
45
- additionalProperties: false,
46
- },
45
+ additionalProperties: false
46
+ }
47
47
  ],
48
48
  messages: {
49
- kebabStyleProp: "Use {{ kebabName }} instead of {{ name }}.",
50
- invalidStyleProp: "{{ name }} is not a valid CSS property.",
49
+ kebabStyleProp:
50
+ "`{{ name }}` is React's camelCase. Solid passes each key to `style.setProperty`, which only takes CSS names, so this style is dropped. Fix: `{{ fix }}`.",
51
+ invalidStyleProp:
52
+ "`{{ name }}` is not a CSS property, so `style.setProperty` drops it. Fix: correct the spelling, or start a custom property with `--` (`--{{ name }}`).",
51
53
  numericStyleValue:
52
- 'This CSS property value should be a string with a unit; Solid does not automatically append a "px" unit.',
54
+ "`{{ name }}: {{ value }}` is a number without a unit. Solid passes it to `style.setProperty` as is, without adding `px`, and the browser drops a unitless length. Fix: `{{ fix }}`.",
53
55
  stringStyle:
54
- "Use an object for the style prop instead of a string.",
55
- },
56
+ "`style` gets a string, which Solid sets as the whole `cssText`, so a change rewrites every property; an object lets Solid update the single property that changed. Fix: `{{ fix }}`."
57
+ }
56
58
  },
57
59
  defaultOptions: [],
58
60
  create(context) {
59
61
  const allCssPropertiesSet = new Set(allCssProperties);
60
62
  const allowString = Boolean(context.options[0]?.allowString);
61
63
  const styleProps = context.options[0]?.styleProps || ["style"];
64
+ const sourceCode = getSourceCode(context);
62
65
  return {
63
66
  JSXAttribute(node) {
64
67
  if (styleProps.indexOf(jsxPropName(node)) === -1) {
@@ -85,28 +88,39 @@ export default {
85
88
  context.report({
86
89
  node: style,
87
90
  messageId: "stringStyle",
91
+ data: {
92
+ fix: messageCode(
93
+ objectStyles
94
+ ? `style={${JSON.stringify(objectStyles)}}`
95
+ : "",
96
+ 'style={{ "font-size": "10px" }}'
97
+ )
98
+ },
88
99
  // replace full prop value, wrap in JSXExpressionContainer, more fixes may be applied below
89
100
  fix:
90
101
  objectStyles &&
91
102
  ((fixer) =>
92
103
  fixer.replaceText(
93
104
  node.value,
94
- `{${JSON.stringify(objectStyles)}}`,
95
- )),
105
+ `{${JSON.stringify(objectStyles)}}`
106
+ ))
96
107
  });
97
108
  } else if (style.type === "TemplateLiteral" && !allowString) {
98
109
  context.report({
99
110
  node: style,
100
111
  messageId: "stringStyle",
112
+ data: {
113
+ fix: 'style={{ "font-size": `${size()}px` }}'
114
+ }
101
115
  });
102
116
  } else if (style.type === "ObjectExpression") {
103
117
  const properties = style.properties.filter(
104
- (prop) => prop.type === "Property",
118
+ (prop) => prop.type === "Property"
105
119
  );
106
120
  properties.forEach((prop) => {
107
121
  const name = getPropertyName(
108
122
  prop,
109
- getScope(context, prop),
123
+ getScope(context, prop)
110
124
  );
111
125
  if (
112
126
  name &&
@@ -119,18 +133,24 @@ export default {
119
133
  context.report({
120
134
  node: prop.key,
121
135
  messageId: "kebabStyleProp",
122
- data: { name, kebabName },
136
+ data: {
137
+ name,
138
+ fix: messageCode(
139
+ `"${kebabName}": ${sourceCode.getText(prop.value)}`,
140
+ `"${kebabName}": …`
141
+ )
142
+ },
123
143
  fix: (fixer) =>
124
144
  fixer.replaceText(
125
145
  prop.key,
126
- `"${kebabName}"`,
127
- ), // wrap kebab name in quotes to be a valid object key
146
+ `"${kebabName}"`
147
+ ) // wrap kebab name in quotes to be a valid object key
128
148
  });
129
149
  } else {
130
150
  context.report({
131
151
  node: prop.key,
132
152
  messageId: "invalidStyleProp",
133
- data: { name },
153
+ data: { name }
134
154
  });
135
155
  }
136
156
  } else if (
@@ -142,15 +162,23 @@ export default {
142
162
  // and suggests quoting or appending 'px'
143
163
  const value = getStaticValue(prop.value)?.value;
144
164
  if (typeof value === "number" && value !== 0) {
165
+ const key = name
166
+ ? `"${name}"`
167
+ : `[${sourceCode.getText(prop.key)}]`;
145
168
  context.report({
146
169
  node: prop.value,
147
170
  messageId: "numericStyleValue",
171
+ data: {
172
+ name: key,
173
+ value: sourceCode.getText(prop.value),
174
+ fix: `${key}: "${value}px"`
175
+ }
148
176
  });
149
177
  }
150
178
  }
151
179
  });
152
180
  }
153
- },
181
+ }
154
182
  };
155
- },
183
+ }
156
184
  };
@@ -0,0 +1,88 @@
1
+ // An object literal passed to `merge` loses its types: TypeScript widens
2
+ // `{ variant: "primary" }` to `string`, and annotating the defaults as
3
+ // `Partial<Props>` makes every defaulted prop optional again. Writing the
4
+ // literal with `satisfies Partial<Props>` keeps the literal types and checks
5
+ // the keys against the props; `as const` keeps the literal types too.
6
+ import { getSourceCode } from "../compat.mjs";
7
+ import { trackImports } from "../utils.mjs";
8
+
9
+ function isAsConst(node) {
10
+ return (
11
+ node.type === "TSAsExpression" &&
12
+ node.typeAnnotation.type === "TSTypeReference" &&
13
+ node.typeAnnotation.typeName.type === "Identifier" &&
14
+ node.typeAnnotation.typeName.name === "const"
15
+ );
16
+ }
17
+
18
+ export default {
19
+ meta: {
20
+ type: "suggestion",
21
+ docs: {
22
+ description:
23
+ "Require `satisfies Partial<Props>` (or `as const`) on object literals passed to `merge`, so the defaults keep their types."
24
+ },
25
+ schema: [],
26
+ messages: {
27
+ untypedDefaults:
28
+ 'The defaults `{{object}}` passed to `{{name}}` have no checked type, so their literals widen (`"primary"` becomes `string`) and their keys are not checked against the props. Fix: `{{object}} satisfies {{type}}`{{where}}. Do not: write `as Partial<Props>` or use a `Partial<Props>` variable; both make the defaulted props optional again.'
29
+ }
30
+ },
31
+ defaultOptions: [],
32
+ create(context) {
33
+ const { matchImport, handleImportDeclaration } = trackImports();
34
+ const sourceCode = getSourceCode(context);
35
+ // A one-line literal is quoted as written; a longer one is elided.
36
+ const quote = (node) => {
37
+ const text = sourceCode.getText(node);
38
+ return text.includes("\n") ? "{ … }" : text;
39
+ };
40
+ return {
41
+ ImportDeclaration: handleImportDeclaration,
42
+ CallExpression(node) {
43
+ if (node.callee.type !== "Identifier") {
44
+ return;
45
+ }
46
+ // `@solidjs/web` re-exports `merge` as `mergeProps`.
47
+ const name = matchImport(
48
+ ["merge", "mergeProps"],
49
+ node.callee.name
50
+ );
51
+ if (!name) {
52
+ return;
53
+ }
54
+ for (const argument of node.arguments) {
55
+ const untyped =
56
+ argument.type === "ObjectExpression" ||
57
+ (argument.type === "TSAsExpression" &&
58
+ !isAsConst(argument) &&
59
+ argument.expression.type === "ObjectExpression");
60
+ if (untyped) {
61
+ const literal =
62
+ argument.type === "TSAsExpression"
63
+ ? argument.expression
64
+ : argument;
65
+ const asType =
66
+ argument.type === "TSAsExpression"
67
+ ? sourceCode.getText(argument.typeAnnotation)
68
+ : null;
69
+ context.report({
70
+ data: {
71
+ name: node.callee.name,
72
+ object: quote(literal),
73
+ // `{ … } as Partial<ButtonProps>` names the type.
74
+ type: asType ?? "Partial<Props>",
75
+ where:
76
+ asType === null
77
+ ? ", with `Props` the props type of the component"
78
+ : ""
79
+ },
80
+ messageId: "untypedDefaults",
81
+ node: argument
82
+ });
83
+ }
84
+ }
85
+ }
86
+ };
87
+ }
88
+ };
@@ -36,7 +36,7 @@ import { isDOMElementName, jsxGetProp, jsxPropName } from "../utils.mjs";
36
36
  // `<body>` from a parsed document, used as the parsing context so fragments are
37
37
  // interpreted the way `innerHTML` would interpret them.
38
38
  const htmlElement = parse(
39
- "<!DOCTYPE html><html><head></head><body></body></html>",
39
+ "<!DOCTYPE html><html><head></head><body></body></html>"
40
40
  ).childNodes[1];
41
41
  const bodyContext = htmlElement.childNodes[1];
42
42
 
@@ -49,7 +49,7 @@ const tableWrappers = {
49
49
  tfoot: ["table"],
50
50
  tr: ["table", "tbody"],
51
51
  td: ["table", "tbody", "tr"],
52
- th: ["table", "tbody", "tr"],
52
+ th: ["table", "tbody", "tr"]
53
53
  };
54
54
 
55
55
  // Rows, row groups and the table itself keep a hidden input as a child, any
@@ -72,7 +72,7 @@ const voidElements = new Set([
72
72
  "param",
73
73
  "source",
74
74
  "track",
75
- "wbr",
75
+ "wbr"
76
76
  ]);
77
77
 
78
78
  // parse5 lowercases tag names outside SVG, so `<foreignObject>` comes back as
@@ -111,7 +111,7 @@ const parserRewrites = (parent, child, namespace) => {
111
111
  : `<${child}></${child}>`;
112
112
  const markup = wrappers.reduceRight(
113
113
  (content, tag) => `<${tag}>${content}</${tag}>`,
114
- `<${parent}>${childMarkup}</${parent}>`,
114
+ `<${parent}>${childMarkup}</${parent}>`
115
115
  );
116
116
  let fragment = documentParent
117
117
  ? parse(markup).childNodes.find((node) => node.nodeName === "html")
@@ -120,7 +120,7 @@ const parserRewrites = (parent, child, namespace) => {
120
120
  fragment = fragment?.childNodes.find((node) => node.nodeName === tag);
121
121
  }
122
122
  const roots = (fragment?.childNodes ?? []).filter(
123
- (node) => node.nodeName !== "#text",
123
+ (node) => node.nodeName !== "#text"
124
124
  );
125
125
  const root = documentParent
126
126
  ? roots.find((node) => node.nodeName === parent)
@@ -130,7 +130,7 @@ const parserRewrites = (parent, child, namespace) => {
130
130
  // `<template>` parks its children in `content`, not `childNodes`.
131
131
  const container = root && "content" in root ? root.content : root;
132
132
  const kids = (container?.childNodes ?? []).filter(
133
- (node) => node.nodeName !== "#text",
133
+ (node) => node.nodeName !== "#text"
134
134
  );
135
135
 
136
136
  // Foreign content can only clear a report the HTML reading makes, since
@@ -296,7 +296,7 @@ const foreignContentExits = new Set([
296
296
  "tt",
297
297
  "u",
298
298
  "ul",
299
- "var",
299
+ "var"
300
300
  ]);
301
301
 
302
302
  // `<font>` leaves foreign content when it has one of these attributes.
@@ -319,7 +319,7 @@ const switchesToHTML = (element, tag, namespace) => {
319
319
  return attributes.some(
320
320
  (attr) =>
321
321
  attr.type === "JSXAttribute" &&
322
- fontExitAttributes.has(jsxPropName(attr).toLowerCase()),
322
+ fontExitAttributes.has(jsxPropName(attr).toLowerCase())
323
323
  );
324
324
  }
325
325
  if (namespace === "svg") {
@@ -331,7 +331,7 @@ const switchesToHTML = (element, tag, namespace) => {
331
331
  const encoding = attributes.find(
332
332
  (attr) =>
333
333
  attr.type === "JSXAttribute" &&
334
- jsxPropName(attr).toLowerCase() === "encoding",
334
+ jsxPropName(attr).toLowerCase() === "encoding"
335
335
  )?.value;
336
336
  return (
337
337
  encoding?.type === "Literal" &&
@@ -427,15 +427,15 @@ export default {
427
427
  docs: {
428
428
  description:
429
429
  "Disallow HTML nesting the browser refuses to keep, like `<p><div /></p>`, which silently renders a different DOM than the JSX describes.",
430
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/validate-jsx-nesting.md",
430
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/validate-jsx-nesting.md"
431
431
  },
432
432
  messages: {
433
433
  invalidNesting:
434
- "Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The HTML parser restructures this, so the rendered DOM won't match this markup.",
434
+ "Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The HTML parser restructures this, so the rendered DOM won't match this markup. Fix: move the `<{{child}}>` out of the `<{{parent}}>`, or change one of the two tags so HTML allows the nesting.",
435
435
  invalidNestingInserted:
436
- "Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The client inserts it as written, but the HTML parser restructures it in server-rendered HTML, so hydration won't match this markup.",
436
+ "Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The client inserts it as written, but the HTML parser restructures it in server-rendered HTML, so hydration won't match this markup. Fix: move the `<{{child}}>` out of the `<{{parent}}>`, or change one of the two tags so HTML allows the nesting."
437
437
  },
438
- schema: [],
438
+ schema: []
439
439
  },
440
440
  defaultOptions: [],
441
441
  create(context) {
@@ -468,7 +468,7 @@ export default {
468
468
  messageId: isInserted(node, parentNode)
469
469
  ? "invalidNestingInserted"
470
470
  : "invalidNesting",
471
- data: { parent, child },
471
+ data: { parent, child }
472
472
  });
473
473
  };
474
474
 
@@ -483,7 +483,7 @@ export default {
483
483
  if (parentNode) {
484
484
  check(node, child, parentNode);
485
485
  }
486
- },
486
+ }
487
487
  };
488
- },
488
+ }
489
489
  };