@murky-web/oxlint-plugin-solid 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@murky-web/oxlint-plugin-solid",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Local Oxlint JS plugin port for Solid rules plus Murky-specific Solid conventions.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -15,18 +15,44 @@ function isAstNode(value) {
15
15
  );
16
16
  }
17
17
 
18
- function isExportedFunctionComponent(node) {
19
- return (
20
- node.type === "FunctionDeclaration" &&
21
- node.id?.type === "Identifier" &&
22
- isPascalCaseComponentName(node.id.name) &&
23
- node.parent?.type === "ExportNamedDeclaration" &&
24
- node.async !== true &&
25
- node.generator !== true &&
26
- !node.typeParameters
27
- );
18
+ function hasJsxElementReturnType(node) {
19
+ const rt = node.returnType?.typeAnnotation;
20
+ if (!rt) return false;
21
+ // JSX.Element
22
+ if (
23
+ rt.type === "TSTypeReference" &&
24
+ rt.typeName?.type === "TSQualifiedName" &&
25
+ rt.typeName.left?.name === "JSX" &&
26
+ rt.typeName.right?.name === "Element"
27
+ ) return true;
28
+ // JSX.Element via plain identifier (rare but possible)
29
+ if (rt.type === "TSTypeReference" && rt.typeName?.name === "JSXElement") return true;
30
+ return false;
28
31
  }
29
32
 
33
+ function isFunctionComponent(node) {
34
+ if (
35
+ node.type !== "FunctionDeclaration" ||
36
+ node.async === true ||
37
+ node.generator === true ||
38
+ node.typeParameters
39
+ ) return false;
40
+
41
+ if (node.id?.type !== "Identifier") return false;
42
+
43
+ // exported PascalCase — classic component
44
+ const isExported = node.parent?.type === "ExportNamedDeclaration";
45
+ if (isExported && isPascalCaseComponentName(node.id.name)) return true;
46
+
47
+ // has JSX.Element return type annotation — intent is clear regardless of export/casing
48
+ if (hasJsxElementReturnType(node)) return true;
49
+
50
+ return false;
51
+ }
52
+
53
+ // Keep old name as alias so call sites don't need changing
54
+ const isExportedFunctionComponent = isFunctionComponent;
55
+
30
56
  function isJsxLikeNode(node) {
31
57
  return node?.type === "JSXElement" || node?.type === "JSXFragment";
32
58
  }