@heyramzi/lint 2.4.0 → 2.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyramzi/lint",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Shared oxlint rules, base config and gates for Studio projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -3,11 +3,23 @@
3
3
  */
4
4
 
5
5
  /*
6
- * A union or a conditional type can't be an interface, so those stay allowed. The fix rewrites an object-literal alias, the common case.
6
+ * A union or a conditional type can't be an interface, even nested in a generic like `WithElementRef<A & (B | C)>`, so those stay allowed.
7
7
  */
8
8
 
9
9
  const NOT_AN_INTERFACE = new Set(["TSUnionType", "TSConditionalType", "TSMappedType"]);
10
10
 
11
+ function holdsNonInterface(node) {
12
+ if (!node || typeof node.type !== "string") return false;
13
+ if (NOT_AN_INTERFACE.has(node.type)) return true;
14
+ // An object literal's members can hold unions freely; only the alias's own shape matters.
15
+ if (node.type === "TSTypeLiteral") return false;
16
+ return Object.entries(node).some(
17
+ ([key, child]) =>
18
+ key !== "parent" &&
19
+ (Array.isArray(child) ? child.some(holdsNonInterface) : holdsNonInterface(child)),
20
+ );
21
+ }
22
+
11
23
  export default {
12
24
  meta: {
13
25
  type: "suggestion",
@@ -24,7 +36,7 @@ export default {
24
36
  return {
25
37
  TSTypeAliasDeclaration(node) {
26
38
  if (node.id.name !== "Props") return;
27
- if (NOT_AN_INTERFACE.has(node.typeAnnotation.type)) return;
39
+ if (holdsNonInterface(node.typeAnnotation)) return;
28
40
  const fixable =
29
41
  node.typeAnnotation.type === "TSTypeLiteral" && !node.typeParameters && !node.declare;
30
42
  context.report({