@conorroberts/utils 0.0.55 → 0.0.57

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 (35) hide show
  1. package/dist/oxlint/config.json +1 -0
  2. package/dist/oxlint/jsx-component-pascal-case.d.mts +8 -16
  3. package/dist/oxlint/jsx-component-pascal-case.mjs +1 -5
  4. package/dist/oxlint/jsx-component-pascal-case.mjs.map +1 -1
  5. package/dist/oxlint/no-component-date-instantiation.d.mts +8 -16
  6. package/dist/oxlint/no-component-date-instantiation.mjs +1 -5
  7. package/dist/oxlint/no-component-date-instantiation.mjs.map +1 -1
  8. package/dist/oxlint/no-emoji.d.mts +4 -12
  9. package/dist/oxlint/no-emoji.mjs +1 -5
  10. package/dist/oxlint/no-emoji.mjs.map +1 -1
  11. package/dist/oxlint/no-finally.d.mts +4 -12
  12. package/dist/oxlint/no-finally.mjs +1 -5
  13. package/dist/oxlint/no-finally.mjs.map +1 -1
  14. package/dist/oxlint/no-function-call-in-jsx.d.mts +7 -15
  15. package/dist/oxlint/no-function-call-in-jsx.mjs +1 -5
  16. package/dist/oxlint/no-function-call-in-jsx.mjs.map +1 -1
  17. package/dist/oxlint/no-inline-components.d.mts +11 -19
  18. package/dist/oxlint/no-inline-components.mjs +1 -5
  19. package/dist/oxlint/no-inline-components.mjs.map +1 -1
  20. package/dist/oxlint/no-react-namespace.d.mts +4 -12
  21. package/dist/oxlint/no-react-namespace.mjs +1 -5
  22. package/dist/oxlint/no-react-namespace.mjs.map +1 -1
  23. package/dist/oxlint/no-switch-plugin.d.mts +5 -11
  24. package/dist/oxlint/no-switch-plugin.mjs +1 -5
  25. package/dist/oxlint/no-switch-plugin.mjs.map +1 -1
  26. package/dist/oxlint/no-top-level-let.d.mts +4 -12
  27. package/dist/oxlint/no-top-level-let.mjs +1 -5
  28. package/dist/oxlint/no-top-level-let.mjs.map +1 -1
  29. package/dist/oxlint/no-type-cast.d.mts +4 -12
  30. package/dist/oxlint/no-type-cast.mjs +1 -5
  31. package/dist/oxlint/no-type-cast.mjs.map +1 -1
  32. package/dist/oxlint/pretty-props.d.mts +11 -0
  33. package/dist/oxlint/pretty-props.mjs +127 -0
  34. package/dist/oxlint/pretty-props.mjs.map +1 -0
  35. package/package.json +2 -2
@@ -10,6 +10,7 @@
10
10
  "node",
11
11
  "promise"
12
12
  ],
13
+ "jsPlugins": ["./src/oxlint-plugins/index.js"],
13
14
  "env": {
14
15
  "browser": true
15
16
  },
@@ -1,25 +1,17 @@
1
- import * as oxlint41 from "oxlint";
1
+ import * as oxlint39 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/jsx-component-pascal-case.d.ts
4
- declare const jsxComponentPascalCaseRule: oxlint41.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/jsx-component-pascal-case": oxlint41.Rule;
11
- };
12
- }
13
- type RuleContext = oxlint41.Context;
14
- type ESTNode = oxlint41.ESTree.Node;
15
- type ESTExpression = oxlint41.ESTree.Expression;
16
- type ReturnStatementNode = oxlint41.ESTree.ReturnStatement;
17
- type FunctionLikeNode = oxlint41.ESTree.Function | oxlint41.ESTree.ArrowFunctionExpression;
4
+ declare const jsxComponentPascalCaseRule: oxlint39.Rule;
5
+ type RuleContext = oxlint39.Context;
6
+ type ESTNode = oxlint39.ESTree.Node;
7
+ type ESTExpression = oxlint39.ESTree.Expression;
8
+ type ReturnStatementNode = oxlint39.ESTree.ReturnStatement;
9
+ type FunctionLikeNode = oxlint39.ESTree.Function | oxlint39.ESTree.ArrowFunctionExpression;
18
10
  type FunctionContext = {
19
11
  node: FunctionLikeNode;
20
12
  name: string;
21
13
  returnsJsx: boolean;
22
14
  };
23
15
  //#endregion
24
- export { ESTExpression, ESTNode, FunctionContext, FunctionLikeNode, ReturnStatementNode, RuleContext, _default as default, jsxComponentPascalCaseRule };
16
+ export { ESTExpression, ESTNode, FunctionContext, FunctionLikeNode, ReturnStatementNode, RuleContext, jsxComponentPascalCaseRule };
25
17
  //# sourceMappingURL=jsx-component-pascal-case.d.mts.map
@@ -149,11 +149,7 @@ const rule = defineRule({
149
149
  }
150
150
  });
151
151
  const jsxComponentPascalCaseRule = rule;
152
- var jsx_component_pascal_case_default = {
153
- meta: { name: "conorroberts/jsx-component-pascal-case" },
154
- rules: { "conorroberts/jsx-component-pascal-case": rule }
155
- };
156
152
 
157
153
  //#endregion
158
- export { jsx_component_pascal_case_default as default, jsxComponentPascalCaseRule };
154
+ export { jsxComponentPascalCaseRule };
159
155
  //# sourceMappingURL=jsx-component-pascal-case.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-component-pascal-case.mjs","names":[],"sources":["../../src/oxlint-plugins/jsx-component-pascal-case.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.Expression} ESTExpression\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {string} name\n * @property {boolean} returnsJsx\n */\n\nconst JSX_NODE_TYPES = new Set([\"JSXElement\", \"JSXFragment\"]);\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isPascalCase = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * Check if a name is a valid higher-order component name (starts with \"with\")\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isHOCName = (name) => typeof name === \"string\" && /^with[A-Z]/.test(name);\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n // Don't enforce naming for functions used as object property values or JSX props\n // These are often callbacks or configuration options, not standalone components\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return \"\";\n }\n\n // Handle functions passed as arguments to calls (e.g., useCallback, useMemo)\n if (parent.type === \"CallExpression\") {\n const callParent = parent.parent;\n if (callParent && isNode(callParent)) {\n if (callParent.type === \"VariableDeclarator\") {\n return callParent.id && callParent.id.type === \"Identifier\" ? callParent.id.name : \"\";\n }\n if (callParent.type === \"AssignmentExpression\") {\n return callParent.left && callParent.left.type === \"Identifier\" ? callParent.left.name : \"\";\n }\n }\n }\n\n return \"\";\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n */\nconst expressionContainsJsx = (root) => {\n if (!root || !isNode(root)) return false;\n\n const stack = [root];\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (JSX_NODE_TYPES.has(current.type)) {\n return true;\n }\n\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Enforce PascalCase naming for functions that return JSX elements (components).\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const name = getFunctionName(node);\n\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n name,\n returnsJsx: false,\n };\n\n functionStack.push(fnCtx);\n\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (expressionContainsJsx(node.body)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n // Allow PascalCase or HOC naming (withXxx)\n if (fnCtx.returnsJsx && fnCtx.name && !isPascalCase(fnCtx.name) && !isHOCName(fnCtx.name)) {\n context.report({\n node: fnCtx.node,\n message: `Function '${fnCtx.name}' returns JSX and should use PascalCase naming (e.g., '${fnCtx.name.charAt(0).toUpperCase()}${fnCtx.name.slice(1)}').`,\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument || isFunctionLike(argument)) return;\n\n if (expressionContainsJsx(argument)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n });\n },\n});\n\nexport const jsxComponentPascalCaseRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/jsx-component-pascal-case\" },\n rules: { \"conorroberts/jsx-component-pascal-case\": rule },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,iBAAiB,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAC7D,MAAM,sBAAsB,IAAI,IAAI;CAAC;CAAuB;CAAsB;CAA0B,CAAC;;;;;AAM7G,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,kBAAkB,SAAS,OAAO,KAAK,IAAI,oBAAoB,IAAI,KAAK,KAAK;;;;;AAMnF,MAAM,gBAAgB,SAAS,OAAO,SAAS,YAAY,SAAS,KAAK,KAAK;;;;;;AAO9E,MAAM,aAAa,SAAS,OAAO,SAAS,YAAY,aAAa,KAAK,KAAK;;;;AAK/E,MAAM,mBAAmB,SAAS;AAChC,KAAI,KAAK,SAAS,yBAAyB,KAAK,MAAM,KAAK,GAAG,SAAS,aACrE,QAAO,KAAK,GAAG;AAGjB,MAAK,KAAK,SAAS,wBAAwB,KAAK,SAAS,8BAA8B,KAAK,IAC1F;MAAI,KAAK,GAAG,SAAS,aAAc,QAAO,KAAK,GAAG;;CAGpD,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAE,QAAO;AAEvC,KAAI,OAAO,SAAS,qBAClB,QAAO,OAAO,MAAM,OAAO,GAAG,SAAS,eAAe,OAAO,GAAG,OAAO;AAGzE,KAAI,OAAO,SAAS,uBAClB,QAAO,OAAO,QAAQ,OAAO,KAAK,SAAS,eAAe,OAAO,KAAK,OAAO;AAK/E,KAAI,OAAO,SAAS,cAAc,OAAO,SAAS,mBAChD,QAAO;A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c,KAAK,MAAM;AAEzB,OAAI,KAAK,SAAS,6BAA6B,KAAK,QAAQ,KAAK,KAAK,SAAS,kBAC7E;QAAI,sBAAsB,KAAK,KAAK,CAClC,OAAM,aAAa;;;EAKzB,MAAM,qBAAqB;GACzB,MAAM,QAAQ,cAAc,KAAK;AACjC,OAAI,CAAC,MAAO;AAGZ,OAAI,MAAM,cAAc,MAAM,QAAQ,CAAC,aAAa,MAAM,KAAK,IAAI,CAAC,UAAU,MAAM,KAAK,CACvF,SAAQ,OAAO;IACb,MAAM,MAAM;IACZ,SAAS,aAAa,MAAM,KAAK,yDAAyD,MAAM,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC;IACpJ,CAAC;;;EAKN,MAAM,yBAAyB,SAAS;GACtC,MAAM,QAAQ,iBAAiB;AAC/B,OAAI,CAAC,MAAO;GAEZ,MAAM,WAAW,KAAK;AACtB,OAAI,CAAC,YAAY,eAAe,SAAS,CAAE;AAE3C,OAAI,sBAAsB,SAAS,CACjC,OAAM,aAAa;;AAIvB,SAAyD;GACvD,oBAAoB,MAAM;AACxB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,4BAA4B;GAC5B,mBAAmB,MAAM;AACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,2BAA2B;GAC3B,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAEnE;;CAEJ,CAAC;AAEF,MAAa,6BAA6B;AAE1C,wCAAe;CACb,MAAM,EAAE,MAAM,0CAA0C;CACxD,OAAO,EAAE,0CAA0C,MAAM;CAC1D"}
1
+ {"version":3,"file":"jsx-component-pascal-case.mjs","names":[],"sources":["../../src/oxlint-plugins/jsx-component-pascal-case.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.Expression} ESTExpression\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {string} name\n * @property {boolean} returnsJsx\n */\n\nconst JSX_NODE_TYPES = new Set([\"JSXElement\", \"JSXFragment\"]);\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isPascalCase = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * Check if a name is a valid higher-order component name (starts with \"with\")\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isHOCName = (name) => typeof name === \"string\" && /^with[A-Z]/.test(name);\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n // Don't enforce naming for functions used as object property values or JSX props\n // These are often callbacks or configuration options, not standalone components\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return \"\";\n }\n\n // Handle functions passed as arguments to calls (e.g., useCallback, useMemo)\n if (parent.type === \"CallExpression\") {\n const callParent = parent.parent;\n if (callParent && isNode(callParent)) {\n if (callParent.type === \"VariableDeclarator\") {\n return callParent.id && callParent.id.type === \"Identifier\" ? callParent.id.name : \"\";\n }\n if (callParent.type === \"AssignmentExpression\") {\n return callParent.left && callParent.left.type === \"Identifier\" ? callParent.left.name : \"\";\n }\n }\n }\n\n return \"\";\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n */\nconst expressionContainsJsx = (root) => {\n if (!root || !isNode(root)) return false;\n\n const stack = [root];\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (JSX_NODE_TYPES.has(current.type)) {\n return true;\n }\n\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Enforce PascalCase naming for functions that return JSX elements (components).\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const name = getFunctionName(node);\n\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n name,\n returnsJsx: false,\n };\n\n functionStack.push(fnCtx);\n\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (expressionContainsJsx(node.body)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n // Allow PascalCase or HOC naming (withXxx)\n if (fnCtx.returnsJsx && fnCtx.name && !isPascalCase(fnCtx.name) && !isHOCName(fnCtx.name)) {\n context.report({\n node: fnCtx.node,\n message: `Function '${fnCtx.name}' returns JSX and should use PascalCase naming (e.g., '${fnCtx.name.charAt(0).toUpperCase()}${fnCtx.name.slice(1)}').`,\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument || isFunctionLike(argument)) return;\n\n if (expressionContainsJsx(argument)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n });\n },\n});\n\nexport const jsxComponentPascalCaseRule = rule;\n\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,iBAAiB,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAC7D,MAAM,sBAAsB,IAAI,IAAI;CAAC;CAAuB;CAAsB;CAA0B,CAAC;;;;;AAM7G,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,kBAAkB,SAAS,OAAO,KAAK,IAAI,oBAAoB,IAAI,KAAK,KAAK;;;;;AAMnF,MAAM,gBAAgB,SAAS,OAAO,SAAS,YAAY,S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YAAY,eAAe,SAAS,CAAE;AAE3C,OAAI,sBAAsB,SAAS,CACjC,OAAM,aAAa;;AAIvB,SAAyD;GACvD,oBAAoB,MAAM;AACxB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,4BAA4B;GAC5B,mBAAmB,MAAM;AACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,2BAA2B;GAC3B,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAEnE;;CAEJ,CAAC;AAEF,MAAa,6BAA6B"}
@@ -1,20 +1,12 @@
1
- import * as oxlint33 from "oxlint";
1
+ import * as oxlint1 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-component-date-instantiation.d.ts
4
- declare const noComponentDateInstantiationRule: oxlint33.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-component-date-instantiation": oxlint33.Rule;
11
- };
12
- }
13
- type RuleContext = oxlint33.Context;
14
- type ESTNode = oxlint33.ESTree.Node;
15
- type NewExpressionNode = oxlint33.ESTree.NewExpression;
16
- type ReturnStatementNode = oxlint33.ESTree.ReturnStatement;
17
- type FunctionLikeNode = oxlint33.ESTree.Function | oxlint33.ESTree.ArrowFunctionExpression;
4
+ declare const noComponentDateInstantiationRule: oxlint1.Rule;
5
+ type RuleContext = oxlint1.Context;
6
+ type ESTNode = oxlint1.ESTree.Node;
7
+ type NewExpressionNode = oxlint1.ESTree.NewExpression;
8
+ type ReturnStatementNode = oxlint1.ESTree.ReturnStatement;
9
+ type FunctionLikeNode = oxlint1.ESTree.Function | oxlint1.ESTree.ArrowFunctionExpression;
18
10
  type FunctionContext = {
19
11
  node: FunctionLikeNode;
20
12
  parent: FunctionContext | null;
@@ -23,5 +15,5 @@ type FunctionContext = {
23
15
  dateInstantiations: NewExpressionNode[];
24
16
  };
25
17
  //#endregion
26
- export { ESTNode, FunctionContext, FunctionLikeNode, NewExpressionNode, ReturnStatementNode, RuleContext, _default as default, noComponentDateInstantiationRule };
18
+ export { ESTNode, FunctionContext, FunctionLikeNode, NewExpressionNode, ReturnStatementNode, RuleContext, noComponentDateInstantiationRule };
27
19
  //# sourceMappingURL=no-component-date-instantiation.d.mts.map
@@ -150,11 +150,7 @@ const rule = defineRule({
150
150
  }
151
151
  });
152
152
  const noComponentDateInstantiationRule = rule;
153
- var no_component_date_instantiation_default = {
154
- meta: { name: "conorroberts/no-component-date-instantiation" },
155
- rules: { "conorroberts/no-component-date-instantiation": rule }
156
- };
157
153
 
158
154
  //#endregion
159
- export { no_component_date_instantiation_default as default, noComponentDateInstantiationRule };
155
+ export { noComponentDateInstantiationRule };
160
156
  //# sourceMappingURL=no-component-date-instantiation.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-component-date-instantiation.mjs","names":[],"sources":["../../src/oxlint-plugins/no-component-date-instantiation.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.NewExpression} NewExpressionNode\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {FunctionContext | null} parent\n * @property {string} name\n * @property {boolean} returnsJsx\n * @property {NewExpressionNode[]} dateInstantiations\n */\n\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * Check if a function name follows React component naming convention (PascalCase)\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isComponentName = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * Get the name of a function node\n * @param {FunctionLikeNode} node\n * @returns {string}\n */\nconst getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return parent.key && parent.key.type === \"Identifier\" ? parent.key.name : \"\";\n }\n\n return \"\";\n};\n\n/**\n * Check if a node is a JSX element or fragment\n * @param {ESTNode | null | undefined} node\n * @returns {boolean}\n */\nconst isJSXNode = (node) => {\n if (!node || !isNode(node)) return false;\n return node.type === \"JSXElement\" || node.type === \"JSXFragment\";\n};\n\n/**\n * Check if a NewExpression is creating a Date instance\n * @param {NewExpressionNode} node\n * @returns {boolean}\n */\nconst isDateInstantiation = (node) => {\n if (node.callee.type === \"Identifier\" && node.callee.name === \"Date\") {\n return true;\n }\n return false;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow Date instantiation in the top scope of React components. Date instances declared on every render are bad because they change every render.\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const parent = currentFunction();\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n parent,\n name: getFunctionName(node),\n returnsJsx: false,\n dateInstantiations: [],\n };\n\n functionStack.push(fnCtx);\n\n // Check for arrow functions with expression body that returns JSX\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (isJSXNode(node.body)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n // Only report if this is a React component (PascalCase name + returns JSX)\n if (!fnCtx.returnsJsx) return;\n if (!isComponentName(fnCtx.name)) return;\n\n // Report all Date instantiations in the top scope of this component\n for (const dateNode of fnCtx.dateInstantiations) {\n context.report({\n node: dateNode,\n message: `Avoid instantiating Date in the top scope of component '${fnCtx.name}'. Date instances change on every render. Move it inside an effect, event handler, or use useMemo/useCallback.`,\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument) return;\n\n if (isJSXNode(argument)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n /** @param {NewExpressionNode} node */\n const handleNewExpression = (node) => {\n if (!isDateInstantiation(node)) return;\n\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n // Record this Date instantiation - we'll check if it's in top scope when the function exits\n fnCtx.dateInstantiations.push(node);\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n NewExpression(node) {\n if (node.type === \"NewExpression\") handleNewExpression(node);\n },\n });\n },\n});\n\nexport const noComponentDateInstantiationRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-component-date-instantiation\" },\n rules: { \"conorroberts/no-component-date-instantiation\": rule },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,sBAAsB,IAAI,IAAI;CAAC;CAAuB;CAAsB;CAA0B,CAAC;;;;;AAM7G,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,kBAAkB,SAAS,OAAO,KAAK,IAAI,oBAAoB,IAAI,KAAK,KAAK;;;;;;AAOnF,MAAM,mBAAmB,SAAS,OAAO,SAAS,YAAY,SAAS,KAAK,KAAK;;;;;;AAOjF,MAAM,mBAAmB,SAAS;AAChC,KAAI,KAAK,SAAS,yBAAyB,KAAK,MAAM,KAAK,GAAG,SAAS,aACrE,QAAO,KAAK,GAAG;AAGjB,MAAK,KAAK,SAAS,wBAAwB,KAAK,SAAS,8BAA8B,KAAK,IAC1F;MAAI,KAAK,GAAG,SAAS,aAAc,QAAO,KAAK,GAAG;;CAGpD,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAE,QAAO;AAEvC,KAAI,OAAO,SAAS,qBAClB,QAAO,OAAO,MAAM,OAAO,GAAG,SAAS,eAAe,OAAO,GAAG,OAAO;AAGzE,KAAI,OAAO,SAAS,uBAClB,QAAO,OAAO,QAAQ,OAAO,KAAK,SAAS,eAAe,OAAO,KAAK,OAAO;AAG/E,KAAI,OAAO,SAAS,cAAc,OAAO,SAAS,mBAChD,QAAO,OAAO,OAAO,OAAO,IAAI,SAAS,eAAe,OAAO,IAAI,OAAO;AAG5E,QAAO;;;;;;;AAQT,MAAM,aAAa,SAAS;AAC1B,KAAI,CAAC,QAAQ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;AAGZ,SAAM,mBAAmB,KAAK,KAAK;;AAGrC,SAAyD;GACvD,oBAAoB,MAAM;AACxB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,4BAA4B;GAC5B,mBAAmB,MAAM;AACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,2BAA2B;GAC3B,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAElE,cAAc,MAAM;AAClB,QAAI,KAAK,SAAS,gBAAiB,qBAAoB,KAAK;;GAE/D;;CAEJ,CAAC;AAEF,MAAa,mCAAmC;AAEhD,8CAAe;CACb,MAAM,EAAE,MAAM,gDAAgD;CAC9D,OAAO,EAAE,gDAAgD,MAAM;CAChE"}
1
+ {"version":3,"file":"no-component-date-instantiation.mjs","names":[],"sources":["../../src/oxlint-plugins/no-component-date-instantiation.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.NewExpression} NewExpressionNode\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {FunctionContext | null} parent\n * @property {string} name\n * @property {boolean} returnsJsx\n * @property {NewExpressionNode[]} dateInstantiations\n */\n\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * Check if a function name follows React component naming convention (PascalCase)\n * @param {unknown} name\n * @returns {name is string}\n */\nconst isComponentName = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * Get the name of a function node\n * @param {FunctionLikeNode} node\n * @returns {string}\n */\nconst getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return parent.key && parent.key.type === \"Identifier\" ? parent.key.name : \"\";\n }\n\n return \"\";\n};\n\n/**\n * Check if a node is a JSX element or fragment\n * @param {ESTNode | null | undefined} node\n * @returns {boolean}\n */\nconst isJSXNode = (node) => {\n if (!node || !isNode(node)) return false;\n return node.type === \"JSXElement\" || node.type === \"JSXFragment\";\n};\n\n/**\n * Check if a NewExpression is creating a Date instance\n * @param {NewExpressionNode} node\n * @returns {boolean}\n */\nconst isDateInstantiation = (node) => {\n if (node.callee.type === \"Identifier\" && node.callee.name === \"Date\") {\n return true;\n }\n return false;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow Date instantiation in the top scope of React components. Date instances declared on every render are bad because they change every render.\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const parent = currentFunction();\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n parent,\n name: getFunctionName(node),\n returnsJsx: false,\n dateInstantiations: [],\n };\n\n functionStack.push(fnCtx);\n\n // Check for arrow functions with expression body that returns JSX\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (isJSXNode(node.body)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n // Only report if this is a React component (PascalCase name + returns JSX)\n if (!fnCtx.returnsJsx) return;\n if (!isComponentName(fnCtx.name)) return;\n\n // Report all Date instantiations in the top scope of this component\n for (const dateNode of fnCtx.dateInstantiations) {\n context.report({\n node: dateNode,\n message: `Avoid instantiating Date in the top scope of component '${fnCtx.name}'. Date instances change on every render. Move it inside an effect, event handler, or use useMemo/useCallback.`,\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument) return;\n\n if (isJSXNode(argument)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n /** @param {NewExpressionNode} node */\n const handleNewExpression = (node) => {\n if (!isDateInstantiation(node)) return;\n\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n // Record this Date instantiation - we'll check if it's in top scope when the function exits\n fnCtx.dateInstantiations.push(node);\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n NewExpression(node) {\n if (node.type === \"NewExpression\") handleNewExpression(node);\n },\n });\n },\n});\n\nexport const noComponentDateInstantiationRule = rule;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,sBAAsB,IAAI,IAAI;CAAC;CAAuB;CAAsB;CAA0B,CAAC;;;;;AAM7G,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,kBAAkB,SAAS,OAAO,KAAK,IAAI,oBAAoB,IAAI,KAAK,KAAK;;;;;;AAOnF,MAAM,mBAAmB,SAAS,OAAO,SAAS,YAAY,SAAS,KAAK,KAAK;;;;;;AAOjF,MAAM,mBAAmB,SAAS;AAChC,KAAI,KAAK,SAAS,yBAAyB,KAAK,MAAM,KAAK,GAAG,SAAS,aACrE,QAAO,KAAK,GAAG;AAGjB,MAAK,KAAK,SAAS,wBAAwB,KAAK,SAAS,8BAA8B,KAAK,IAC1F;MAAI,KAAK,GAAG,SAAS,aAAc,QAAO,KAAK,GAAG;;CAGpD,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAE,QAAO;AAEvC,KAAI,OAAO,SAAS,qBAClB,QAAO,OAAO,MAAM,OAAO,GAAG,SAAS,eAAe,OAAO,GAAG,OAAO;AAGzE,KAAI,OAAO,SAAS,uBAClB,QAAO,OAAO,QAAQ,OAAO,KAAK,SAAS,eAAe,OAAO,KAAK,OAAO;AAG/E,KAAI,OAAO,SAAS,cAAc,OAAO,SAAS,mBAChD,QAAO,OAAO,OAAO,OAAO,IAAI,SAAS,eAAe,OAAO,IAAI,OAAO;AAG5E,QAAO;;;;;;;AAQT,MAAM,aAAa,SAAS;AAC1B,KAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAE,QAAO;AACnC,QAAO,KAAK,SAAS,gBAAgB,KAAK,SAAS;;;;;;;AAQrD,MAAM,u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AE,eAAc,KAAK;;GAE/C,4BAA4B;GAC5B,mBAAmB,MAAM;AACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,2BAA2B;GAC3B,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAElE,cAAc,MAAM;AAClB,QAAI,KAAK,SAAS,gBAAiB,qBAAoB,KAAK;;GAE/D;;CAEJ,CAAC;AAEF,MAAa,mCAAmC"}
@@ -1,16 +1,8 @@
1
- import * as oxlint19 from "oxlint";
1
+ import * as oxlint28 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-emoji.d.ts
4
- declare const noEmojiRule: oxlint19.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-emoji": oxlint19.Rule;
11
- };
12
- }
13
- type ESTNode = oxlint19.ESTree.Node;
4
+ declare const noEmojiRule: oxlint28.Rule;
5
+ type ESTNode = oxlint28.ESTree.Node;
14
6
  //#endregion
15
- export { ESTNode, _default as default, noEmojiRule };
7
+ export { ESTNode, noEmojiRule };
16
8
  //# sourceMappingURL=no-emoji.d.mts.map
@@ -79,11 +79,7 @@ const rule = defineRule({
79
79
  }
80
80
  });
81
81
  const noEmojiRule = rule;
82
- var no_emoji_default = {
83
- meta: { name: "conorroberts/no-emoji" },
84
- rules: { "conorroberts/no-emoji": rule }
85
- };
86
82
 
87
83
  //#endregion
88
- export { no_emoji_default as default, noEmojiRule };
84
+ export { noEmojiRule };
89
85
  //# sourceMappingURL=no-emoji.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-emoji.mjs","names":[],"sources":["../../src/oxlint-plugins/no-emoji.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Regex pattern to match emojis\n * Covers most common emoji ranges in Unicode\n */\nconst EMOJI_REGEX =\n /[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}\\u{1F000}-\\u{1F02F}\\u{1F0A0}-\\u{1F0FF}\\u{1F100}-\\u{1F64F}\\u{1F680}-\\u{1F6FF}\\u{1F900}-\\u{1F9FF}\\u{1FA00}-\\u{1FA6F}\\u{1FA70}-\\u{1FAFF}\\u{FE00}-\\u{FE0F}\\u{203C}\\u{2049}\\u{20E3}\\u{2139}\\u{2194}-\\u{2199}\\u{21A9}-\\u{21AA}\\u{231A}-\\u{231B}\\u{2328}\\u{23CF}\\u{23E9}-\\u{23F3}\\u{23F8}-\\u{23FA}\\u{24C2}\\u{25AA}-\\u{25AB}\\u{25B6}\\u{25C0}\\u{25FB}-\\u{25FE}\\u{2600}-\\u{2604}\\u{260E}\\u{2611}\\u{2614}-\\u{2615}\\u{2618}\\u{261D}\\u{2620}\\u{2622}-\\u{2623}\\u{2626}\\u{262A}\\u{262E}-\\u{262F}\\u{2638}-\\u{263A}\\u{2640}\\u{2642}\\u{2648}-\\u{2653}\\u{265F}-\\u{2660}\\u{2663}\\u{2665}-\\u{2666}\\u{2668}\\u{267B}\\u{267E}-\\u{267F}\\u{2692}-\\u{2697}\\u{2699}\\u{269B}-\\u{269C}\\u{26A0}-\\u{26A1}\\u{26A7}\\u{26AA}-\\u{26AB}\\u{26B0}-\\u{26B1}\\u{26BD}-\\u{26BE}\\u{26C4}-\\u{26C5}\\u{26C8}\\u{26CE}\\u{26CF}\\u{26D1}\\u{26D3}-\\u{26D4}\\u{26E9}-\\u{26EA}\\u{26F0}-\\u{26F5}\\u{26F7}-\\u{26FA}\\u{26FD}\\u{2702}\\u{2705}\\u{2708}-\\u{270D}\\u{270F}\\u{2712}\\u{2714}\\u{2716}\\u{271D}\\u{2721}\\u{2728}\\u{2733}-\\u{2734}\\u{2744}\\u{2747}\\u{274C}\\u{274E}\\u{2753}-\\u{2755}\\u{2757}\\u{2763}-\\u{2764}\\u{2795}-\\u{2797}\\u{27A1}\\u{27B0}\\u{27BF}\\u{2934}-\\u{2935}\\u{2B05}-\\u{2B07}\\u{2B1B}-\\u{2B1C}\\u{2B50}\\u{2B55}\\u{3030}\\u{303D}\\u{3297}\\u{3299}]/gu;\n\n/**\n * Find emojis in a string\n * @param {string} text\n * @returns {RegExpMatchArray | null}\n */\nconst findEmojis = (text) => {\n return text.match(EMOJI_REGEX);\n};\n\n/**\n * Get a preview of the emoji found\n * @param {string} text\n * @returns {string}\n */\nconst getEmojiPreview = (text) => {\n const emojis = findEmojis(text);\n if (!emojis || emojis.length === 0) return \"\";\n\n const uniqueEmojis = [...new Set(emojis)];\n const preview = uniqueEmojis.slice(0, 3).join(\" \");\n\n return uniqueEmojis.length > 3 ? `${preview} ...` : preview;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the use of emojis in code. Use icons from a component library instead.\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * Check string literals\n * @param {ESTNode} node\n */\n StringLiteral(node) {\n if (node.type !== \"StringLiteral\") return;\n\n const emojis = findEmojis(node.value);\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(node.value);\n context.report({\n node,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n },\n\n /**\n * Check template literals\n * @param {ESTNode} node\n */\n TemplateLiteral(node) {\n if (node.type !== \"TemplateLiteral\") return;\n\n // Check each quasi (template string part)\n for (const quasi of node.quasis) {\n if (quasi.type !== \"TemplateElement\") continue;\n\n const text = quasi.value.raw;\n const emojis = findEmojis(text);\n\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(text);\n context.report({\n node: quasi,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n }\n },\n\n /**\n * Check JSX text\n * @param {ESTNode} node\n */\n JSXText(node) {\n if (node.type !== \"JSXText\") return;\n\n const emojis = findEmojis(node.value);\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(node.value);\n context.report({\n node,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n },\n });\n },\n});\n\nexport const noEmojiRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-emoji\" },\n rules: { \"conorroberts/no-emoji\": rule },\n};\n"],"mappings":";;;;;;;;AAQA,MAAM,cACJ;;;;;;AAOF,MAAM,cAAc,SAAS;AAC3B,QAAO,KAAK,MAAM,YAAY;;;;;;;AAQhC,MAAM,mBAAmB,SAAS;CAChC,MAAM,SAAS,WAAW,KAAK;AAC/B,KAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO;CAE3C,MAAM,eAAe,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;CACzC,MAAM,UAAU,aAAa,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI;AAElD,QAAO,aAAa,SAAS,IAAI,GAAG,QAAQ,QAAQ;;AAGtD,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD;GAKvD,cAAc,MAAM;AAClB,QAAI,KAAK,SAAS,gBAAiB;IAEnC,MAAM,SAAS,WAAW,KAAK,MAAM;AACrC,QAAI,UAAU,OAAO,SAAS,GAAG;KAC/B,MAAM,UAAU,gBAAgB,KAAK,MAAM;AAC3C,aAAQ,OAAO;MACb;MACA,SAAS,0CAA0C,QAAQ;MAC5D,CAAC;;;GAQN,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB;AAGrC,SAAK,MAAM,SAAS,KAAK,QAAQ;AAC/B,SAAI,MAAM,SAAS,kBAAmB;KAEtC,MAAM,OAAO,MAAM,MAAM;KACzB,MAAM,SAAS,WAAW,KAAK;AAE/B,SAAI,UAAU,OAAO,SAAS,GAAG;MAC/B,MAAM,UAAU,gBAAgB,KAAK;AACrC,cAAQ,OAAO;OACb,MAAM;OACN,SAAS,0CAA0C,QAAQ;OAC5D,CAAC;;;;GASR,QAAQ,MAAM;AACZ,QAAI,KAAK,SAAS,UAAW;IAE7B,MAAM,SAAS,WAAW,KAAK,MAAM;AACrC,QAAI,UAAU,OAAO,SAAS,GAAG;KAC/B,MAAM,UAAU,gBAAgB,KAAK,MAAM;AAC3C,aAAQ,OAAO;MACb;MACA,SAAS,0CAA0C,QAAQ;MAC5D,CAAC;;;GAGP;;CAEJ,CAAC;AAEF,MAAa,cAAc;AAE3B,uBAAe;CACb,MAAM,EAAE,MAAM,yBAAyB;CACvC,OAAO,EAAE,yBAAyB,MAAM;CACzC"}
1
+ {"version":3,"file":"no-emoji.mjs","names":[],"sources":["../../src/oxlint-plugins/no-emoji.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Regex pattern to match emojis\n * Covers most common emoji ranges in Unicode\n */\nconst EMOJI_REGEX =\n /[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}\\u{1F000}-\\u{1F02F}\\u{1F0A0}-\\u{1F0FF}\\u{1F100}-\\u{1F64F}\\u{1F680}-\\u{1F6FF}\\u{1F900}-\\u{1F9FF}\\u{1FA00}-\\u{1FA6F}\\u{1FA70}-\\u{1FAFF}\\u{FE00}-\\u{FE0F}\\u{203C}\\u{2049}\\u{20E3}\\u{2139}\\u{2194}-\\u{2199}\\u{21A9}-\\u{21AA}\\u{231A}-\\u{231B}\\u{2328}\\u{23CF}\\u{23E9}-\\u{23F3}\\u{23F8}-\\u{23FA}\\u{24C2}\\u{25AA}-\\u{25AB}\\u{25B6}\\u{25C0}\\u{25FB}-\\u{25FE}\\u{2600}-\\u{2604}\\u{260E}\\u{2611}\\u{2614}-\\u{2615}\\u{2618}\\u{261D}\\u{2620}\\u{2622}-\\u{2623}\\u{2626}\\u{262A}\\u{262E}-\\u{262F}\\u{2638}-\\u{263A}\\u{2640}\\u{2642}\\u{2648}-\\u{2653}\\u{265F}-\\u{2660}\\u{2663}\\u{2665}-\\u{2666}\\u{2668}\\u{267B}\\u{267E}-\\u{267F}\\u{2692}-\\u{2697}\\u{2699}\\u{269B}-\\u{269C}\\u{26A0}-\\u{26A1}\\u{26A7}\\u{26AA}-\\u{26AB}\\u{26B0}-\\u{26B1}\\u{26BD}-\\u{26BE}\\u{26C4}-\\u{26C5}\\u{26C8}\\u{26CE}\\u{26CF}\\u{26D1}\\u{26D3}-\\u{26D4}\\u{26E9}-\\u{26EA}\\u{26F0}-\\u{26F5}\\u{26F7}-\\u{26FA}\\u{26FD}\\u{2702}\\u{2705}\\u{2708}-\\u{270D}\\u{270F}\\u{2712}\\u{2714}\\u{2716}\\u{271D}\\u{2721}\\u{2728}\\u{2733}-\\u{2734}\\u{2744}\\u{2747}\\u{274C}\\u{274E}\\u{2753}-\\u{2755}\\u{2757}\\u{2763}-\\u{2764}\\u{2795}-\\u{2797}\\u{27A1}\\u{27B0}\\u{27BF}\\u{2934}-\\u{2935}\\u{2B05}-\\u{2B07}\\u{2B1B}-\\u{2B1C}\\u{2B50}\\u{2B55}\\u{3030}\\u{303D}\\u{3297}\\u{3299}]/gu;\n\n/**\n * Find emojis in a string\n * @param {string} text\n * @returns {RegExpMatchArray | null}\n */\nconst findEmojis = (text) => {\n return text.match(EMOJI_REGEX);\n};\n\n/**\n * Get a preview of the emoji found\n * @param {string} text\n * @returns {string}\n */\nconst getEmojiPreview = (text) => {\n const emojis = findEmojis(text);\n if (!emojis || emojis.length === 0) return \"\";\n\n const uniqueEmojis = [...new Set(emojis)];\n const preview = uniqueEmojis.slice(0, 3).join(\" \");\n\n return uniqueEmojis.length > 3 ? `${preview} ...` : preview;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the use of emojis in code. Use icons from a component library instead.\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * Check string literals\n * @param {ESTNode} node\n */\n StringLiteral(node) {\n if (node.type !== \"StringLiteral\") return;\n\n const emojis = findEmojis(node.value);\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(node.value);\n context.report({\n node,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n },\n\n /**\n * Check template literals\n * @param {ESTNode} node\n */\n TemplateLiteral(node) {\n if (node.type !== \"TemplateLiteral\") return;\n\n // Check each quasi (template string part)\n for (const quasi of node.quasis) {\n if (quasi.type !== \"TemplateElement\") continue;\n\n const text = quasi.value.raw;\n const emojis = findEmojis(text);\n\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(text);\n context.report({\n node: quasi,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n }\n },\n\n /**\n * Check JSX text\n * @param {ESTNode} node\n */\n JSXText(node) {\n if (node.type !== \"JSXText\") return;\n\n const emojis = findEmojis(node.value);\n if (emojis && emojis.length > 0) {\n const preview = getEmojiPreview(node.value);\n context.report({\n node,\n message: `Emojis are not allowed in code. Found: ${preview}. Use icons from a component library instead.`,\n });\n }\n },\n });\n },\n});\n\nexport const noEmojiRule = rule;\n\n"],"mappings":";;;;;;;;AAQA,MAAM,cACJ;;;;;;AAOF,MAAM,cAAc,SAAS;AAC3B,QAAO,KAAK,MAAM,YAAY;;;;;;;AAQhC,MAAM,mBAAmB,SAAS;CAChC,MAAM,SAAS,WAAW,KAAK;AAC/B,KAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO;CAE3C,MAAM,eAAe,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;CACzC,MAAM,UAAU,aAAa,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI;AAElD,QAAO,aAAa,SAAS,IAAI,GAAG,QAAQ,QAAQ;;AAGtD,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD;GAKvD,cAAc,MAAM;AAClB,QAAI,KAAK,SAAS,gBAAiB;IAEnC,MAAM,SAAS,WAAW,KAAK,MAAM;AACrC,QAAI,UAAU,OAAO,SAAS,GAAG;KAC/B,MAAM,UAAU,gBAAgB,KAAK,MAAM;AAC3C,aAAQ,OAAO;MACb;MACA,SAAS,0CAA0C,QAAQ;MAC5D,CAAC;;;GAQN,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB;AAGrC,SAAK,MAAM,SAAS,KAAK,QAAQ;AAC/B,SAAI,MAAM,SAAS,kBAAmB;KAEtC,MAAM,OAAO,MAAM,MAAM;KACzB,MAAM,SAAS,WAAW,KAAK;AAE/B,SAAI,UAAU,OAAO,SAAS,GAAG;MAC/B,MAAM,UAAU,gBAAgB,KAAK;AACrC,cAAQ,OAAO;OACb,MAAM;OACN,SAAS,0CAA0C,QAAQ;OAC5D,CAAC;;;;GASR,QAAQ,MAAM;AACZ,QAAI,KAAK,SAAS,UAAW;IAE7B,MAAM,SAAS,WAAW,KAAK,MAAM;AACrC,QAAI,UAAU,OAAO,SAAS,GAAG;KAC/B,MAAM,UAAU,gBAAgB,KAAK,MAAM;AAC3C,aAAQ,OAAO;MACb;MACA,SAAS,0CAA0C,QAAQ;MAC5D,CAAC;;;GAGP;;CAEJ,CAAC;AAEF,MAAa,cAAc"}
@@ -1,16 +1,8 @@
1
- import * as oxlint7 from "oxlint";
1
+ import * as oxlint30 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-finally.d.ts
4
- declare const noFinallyRule: oxlint7.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-finally": oxlint7.Rule;
11
- };
12
- }
13
- type ESTNode = oxlint7.ESTree.Node;
4
+ declare const noFinallyRule: oxlint30.Rule;
5
+ type ESTNode = oxlint30.ESTree.Node;
14
6
  //#endregion
15
- export { ESTNode, _default as default, noFinallyRule };
7
+ export { ESTNode, noFinallyRule };
16
8
  //# sourceMappingURL=no-finally.d.mts.map
@@ -22,11 +22,7 @@ const rule = defineRule({
22
22
  }
23
23
  });
24
24
  const noFinallyRule = rule;
25
- var no_finally_default = {
26
- meta: { name: "conorroberts/no-finally" },
27
- rules: { "conorroberts/no-finally": rule }
28
- };
29
25
 
30
26
  //#endregion
31
- export { no_finally_default as default, noFinallyRule };
27
+ export { noFinallyRule };
32
28
  //# sourceMappingURL=no-finally.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-finally.mjs","names":[],"sources":["../../src/oxlint-plugins/no-finally.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow 'finally' blocks in try/catch/finally statements\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n TryStatement(node) {\n if (node.type !== \"TryStatement\") return;\n\n if (node.finalizer) {\n context.report({\n node: node.finalizer,\n message: \"Use of 'finally' blocks is disallowed. Handle cleanup explicitly in try/catch blocks instead.\",\n });\n }\n },\n });\n },\n});\n\nexport const noFinallyRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-finally\" },\n rules: { \"conorroberts/no-finally\": rule },\n};\n"],"mappings":";;;;AAIA,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,aAAa,MAAM;AACjB,OAAI,KAAK,SAAS,eAAgB;AAElC,OAAI,KAAK,UACP,SAAQ,OAAO;IACb,MAAM,KAAK;IACX,SAAS;IACV,CAAC;KAGP;;CAEJ,CAAC;AAEF,MAAa,gBAAgB;AAE7B,yBAAe;CACb,MAAM,EAAE,MAAM,2BAA2B;CACzC,OAAO,EAAE,2BAA2B,MAAM;CAC3C"}
1
+ {"version":3,"file":"no-finally.mjs","names":[],"sources":["../../src/oxlint-plugins/no-finally.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow 'finally' blocks in try/catch/finally statements\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n TryStatement(node) {\n if (node.type !== \"TryStatement\") return;\n\n if (node.finalizer) {\n context.report({\n node: node.finalizer,\n message: \"Use of 'finally' blocks is disallowed. Handle cleanup explicitly in try/catch blocks instead.\",\n });\n }\n },\n });\n },\n});\n\nexport const noFinallyRule = rule;\n\n"],"mappings":";;;;AAIA,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,aAAa,MAAM;AACjB,OAAI,KAAK,SAAS,eAAgB;AAElC,OAAI,KAAK,UACP,SAAQ,OAAO;IACb,MAAM,KAAK;IACX,SAAS;IACV,CAAC;KAGP;;CAEJ,CAAC;AAEF,MAAa,gBAAgB"}
@@ -1,19 +1,11 @@
1
- import * as oxlint13 from "oxlint";
1
+ import * as oxlint32 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-function-call-in-jsx.d.ts
4
- declare const noFunctionCallInJsxRule: oxlint13.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-function-call-in-jsx": oxlint13.Rule;
11
- };
12
- }
13
- type RuleContext = oxlint13.Context;
14
- type ESTNode = oxlint13.ESTree.Node;
15
- type JSXExpressionContainer = oxlint13.ESTree.JSXExpressionContainer;
16
- type CallExpression = oxlint13.ESTree.CallExpression;
4
+ declare const noFunctionCallInJsxRule: oxlint32.Rule;
5
+ type RuleContext = oxlint32.Context;
6
+ type ESTNode = oxlint32.ESTree.Node;
7
+ type JSXExpressionContainer = oxlint32.ESTree.JSXExpressionContainer;
8
+ type CallExpression = oxlint32.ESTree.CallExpression;
17
9
  //#endregion
18
- export { CallExpression, ESTNode, JSXExpressionContainer, RuleContext, _default as default, noFunctionCallInJsxRule };
10
+ export { CallExpression, ESTNode, JSXExpressionContainer, RuleContext, noFunctionCallInJsxRule };
19
11
  //# sourceMappingURL=no-function-call-in-jsx.d.mts.map
@@ -64,11 +64,7 @@ const rule = defineRule({
64
64
  }
65
65
  });
66
66
  const noFunctionCallInJsxRule = rule;
67
- var no_function_call_in_jsx_default = {
68
- meta: { name: "conorroberts/no-function-call-in-jsx" },
69
- rules: { "conorroberts/no-function-call-in-jsx": rule }
70
- };
71
67
 
72
68
  //#endregion
73
- export { no_function_call_in_jsx_default as default, noFunctionCallInJsxRule };
69
+ export { noFunctionCallInJsxRule };
74
70
  //# sourceMappingURL=no-function-call-in-jsx.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-function-call-in-jsx.mjs","names":[],"sources":["../../src/oxlint-plugins/no-function-call-in-jsx.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.JSXExpressionContainer} JSXExpressionContainer\n * @typedef {import(\"oxlint\").ESTree.CallExpression} CallExpression\n */\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {ESTNode | null | undefined} node\n * @returns {boolean}\n */\nconst isInJSXExpressionContainer = (node) => {\n const findJSXContainer = (current) => {\n if (!current) return false;\n if (current.type === \"JSXExpressionContainer\") {\n return true;\n }\n return findJSXContainer(isNode(current) ? current.parent ?? null : null);\n };\n return findJSXContainer(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {CallExpression} node\n * @returns {string}\n */\nconst getCalleeName = (node) => {\n const callee = node.callee;\n if (!callee) return \"function\";\n\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n\n if (callee.type === \"MemberExpression\") {\n const property = callee.property;\n if (property && property.type === \"Identifier\") {\n return property.name;\n }\n }\n\n return \"function\";\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow function calls within JSX expression containers\",\n recommended: false,\n },\n schema: [],\n },\n\n create(context) {\n /**\n * @param {CallExpression} node\n */\n const handleCallExpression = (node) => {\n if (node.type !== \"CallExpression\") return;\n\n if (!isInJSXExpressionContainer(node)) return;\n\n const calleeName = getCalleeName(node);\n\n context.report({\n node: node,\n message: `Avoid calling '${calleeName}()' directly in JSX. Store the result in a variable or use a component instead.`,\n });\n };\n\n return {\n CallExpression: handleCallExpression,\n };\n },\n});\n\nexport const noFunctionCallInJsxRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-function-call-in-jsx\" },\n rules: { \"conorroberts/no-function-call-in-jsx\": rule },\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,8BAA8B,SAAS;CAC3C,MAAM,oBAAoB,YAAY;AACpC,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,QAAQ,SAAS,yBACnB,QAAO;AAET,SAAO,iBAAiB,OAAO,QAAQ,GAAG,QAAQ,UAAU,OAAO,KAAK;;AAE1E,QAAO,iBAAiB,OAAO,KAAK,GAAG,KAAK,UAAU,OAAO,KAAK;;;;;;AAOpE,MAAM,iBAAiB,SAAS;CAC9B,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI,OAAO,SAAS,aAClB,QAAO,OAAO;AAGhB,KAAI,OAAO,SAAS,oBAAoB;EACtC,MAAM,WAAW,OAAO;AACxB,MAAI,YAAY,SAAS,SAAS,aAChC,QAAO,SAAS;;AAIpB,QAAO;;AAGT,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,OAAO,SAAS;;;;EAId,MAAM,wBAAwB,SAAS;AACrC,OAAI,KAAK,SAAS,iBAAkB;AAEpC,OAAI,CAAC,2BAA2B,KAAK,CAAE;GAEvC,MAAM,aAAa,cAAc,KAAK;AAEtC,WAAQ,OAAO;IACP;IACN,SAAS,kBAAkB,WAAW;IACvC,CAAC;;AAGJ,SAAO,EACL,gBAAgB,sBACjB;;CAEJ,CAAC;AAEF,MAAa,0BAA0B;AAEvC,sCAAe;CACb,MAAM,EAAE,MAAM,wCAAwC;CACtD,OAAO,EAAE,wCAAwC,MAAM;CACxD"}
1
+ {"version":3,"file":"no-function-call-in-jsx.mjs","names":[],"sources":["../../src/oxlint-plugins/no-function-call-in-jsx.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.JSXExpressionContainer} JSXExpressionContainer\n * @typedef {import(\"oxlint\").ESTree.CallExpression} CallExpression\n */\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {ESTNode | null | undefined} node\n * @returns {boolean}\n */\nconst isInJSXExpressionContainer = (node) => {\n const findJSXContainer = (current) => {\n if (!current) return false;\n if (current.type === \"JSXExpressionContainer\") {\n return true;\n }\n return findJSXContainer(isNode(current) ? current.parent ?? null : null);\n };\n return findJSXContainer(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {CallExpression} node\n * @returns {string}\n */\nconst getCalleeName = (node) => {\n const callee = node.callee;\n if (!callee) return \"function\";\n\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n\n if (callee.type === \"MemberExpression\") {\n const property = callee.property;\n if (property && property.type === \"Identifier\") {\n return property.name;\n }\n }\n\n return \"function\";\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow function calls within JSX expression containers\",\n recommended: false,\n },\n schema: [],\n },\n\n create(context) {\n /**\n * @param {CallExpression} node\n */\n const handleCallExpression = (node) => {\n if (node.type !== \"CallExpression\") return;\n\n if (!isInJSXExpressionContainer(node)) return;\n\n const calleeName = getCalleeName(node);\n\n context.report({\n node: node,\n message: `Avoid calling '${calleeName}()' directly in JSX. Store the result in a variable or use a component instead.`,\n });\n };\n\n return {\n CallExpression: handleCallExpression,\n };\n },\n});\n\nexport const noFunctionCallInJsxRule = rule;\n\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,8BAA8B,SAAS;CAC3C,MAAM,oBAAoB,YAAY;AACpC,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,QAAQ,SAAS,yBACnB,QAAO;AAET,SAAO,iBAAiB,OAAO,QAAQ,GAAG,QAAQ,UAAU,OAAO,KAAK;;AAE1E,QAAO,iBAAiB,OAAO,KAAK,GAAG,KAAK,UAAU,OAAO,KAAK;;;;;;AAOpE,MAAM,iBAAiB,SAAS;CAC9B,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI,OAAO,SAAS,aAClB,QAAO,OAAO;AAGhB,KAAI,OAAO,SAAS,oBAAoB;EACtC,MAAM,WAAW,OAAO;AACxB,MAAI,YAAY,SAAS,SAAS,aAChC,QAAO,SAAS;;AAIpB,QAAO;;AAGT,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,OAAO,SAAS;;;;EAId,MAAM,wBAAwB,SAAS;AACrC,OAAI,KAAK,SAAS,iBAAkB;AAEpC,OAAI,CAAC,2BAA2B,KAAK,CAAE;GAEvC,MAAM,aAAa,cAAc,KAAK;AAEtC,WAAQ,OAAO;IACP;IACN,SAAS,kBAAkB,WAAW;IACvC,CAAC;;AAGJ,SAAO,EACL,gBAAgB,sBACjB;;CAEJ,CAAC;AAEF,MAAa,0BAA0B"}
@@ -1,27 +1,19 @@
1
- import * as oxlint22 from "oxlint";
1
+ import * as oxlint16 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-inline-components.d.ts
4
4
  declare function isComponentName(name: unknown): name is string;
5
5
  declare function isHookName(name: unknown): name is string;
6
6
  declare function getEnclosingFunction(node: ESTNode | null | undefined): FunctionLikeNode | null;
7
7
  declare function getFunctionName(node: FunctionLikeNode): string;
8
- declare const noInlineComponentsRule: oxlint22.Rule;
9
- declare namespace _default {
10
- namespace meta {
11
- let name: string;
12
- }
13
- let rules: {
14
- "conorroberts/no-inline-components": oxlint22.Rule;
15
- };
16
- }
17
- type RuleContext = oxlint22.Context;
18
- type ESTNode = oxlint22.ESTree.Node;
19
- type ESTExpression = oxlint22.ESTree.Expression;
20
- type ESTPattern = oxlint22.ESTree.Pattern;
21
- type ReturnStatementNode = oxlint22.ESTree.ReturnStatement;
22
- type VariableDeclaratorNode = oxlint22.ESTree.VariableDeclarator;
23
- type AssignmentExpressionNode = oxlint22.ESTree.AssignmentExpression;
24
- type FunctionLikeNode = oxlint22.ESTree.Function | oxlint22.ESTree.ArrowFunctionExpression;
8
+ declare const noInlineComponentsRule: oxlint16.Rule;
9
+ type RuleContext = oxlint16.Context;
10
+ type ESTNode = oxlint16.ESTree.Node;
11
+ type ESTExpression = oxlint16.ESTree.Expression;
12
+ type ESTPattern = oxlint16.ESTree.Pattern;
13
+ type ReturnStatementNode = oxlint16.ESTree.ReturnStatement;
14
+ type VariableDeclaratorNode = oxlint16.ESTree.VariableDeclarator;
15
+ type AssignmentExpressionNode = oxlint16.ESTree.AssignmentExpression;
16
+ type FunctionLikeNode = oxlint16.ESTree.Function | oxlint16.ESTree.ArrowFunctionExpression;
25
17
  type RecordedAssignment = {
26
18
  node: ESTExpression;
27
19
  names: string[];
@@ -40,5 +32,5 @@ type FunctionContext = {
40
32
  nestedJsxChildren: NestedFunctionRecord[];
41
33
  };
42
34
  //#endregion
43
- export { AssignmentExpressionNode, ESTExpression, ESTNode, ESTPattern, FunctionContext, FunctionLikeNode, NestedFunctionRecord, RecordedAssignment, ReturnStatementNode, RuleContext, VariableDeclaratorNode, _default as default, getEnclosingFunction, getFunctionName, isComponentName, isHookName, noInlineComponentsRule };
35
+ export { AssignmentExpressionNode, ESTExpression, ESTNode, ESTPattern, FunctionContext, FunctionLikeNode, NestedFunctionRecord, RecordedAssignment, ReturnStatementNode, RuleContext, VariableDeclaratorNode, getEnclosingFunction, getFunctionName, isComponentName, isHookName, noInlineComponentsRule };
44
36
  //# sourceMappingURL=no-inline-components.d.mts.map
@@ -368,11 +368,7 @@ const rule = defineRule({
368
368
  }
369
369
  });
370
370
  const noInlineComponentsRule = rule;
371
- var no_inline_components_default = {
372
- meta: { name: "conorroberts/no-inline-components" },
373
- rules: { "conorroberts/no-inline-components": rule }
374
- };
375
371
 
376
372
  //#endregion
377
- export { no_inline_components_default as default, getEnclosingFunction, getFunctionName, isComponentName, isHookName, noInlineComponentsRule };
373
+ export { getEnclosingFunction, getFunctionName, isComponentName, isHookName, noInlineComponentsRule };
378
374
  //# sourceMappingURL=no-inline-components.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-inline-components.mjs","names":[],"sources":["../../src/oxlint-plugins/no-inline-components.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.Expression} ESTExpression\n * @typedef {import(\"oxlint\").ESTree.Pattern} ESTPattern\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.VariableDeclarator} VariableDeclaratorNode\n * @typedef {import(\"oxlint\").ESTree.AssignmentExpression} AssignmentExpressionNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} RecordedAssignment\n * @property {ESTExpression} node\n * @property {string[]} names\n */\n\n/**\n * @typedef {object} NestedFunctionRecord\n * @property {FunctionLikeNode} node\n * @property {string} name\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {FunctionContext | null} parent\n * @property {string} name\n * @property {boolean} returnsJsx\n * @property {Set<string>} jsxBindingNames\n * @property {RecordedAssignment[]} jsxAssignments\n * @property {NestedFunctionRecord[]} nestedJsxChildren\n */\n\nconst JSX_NODE_TYPES = new Set([\"JSXElement\", \"JSXFragment\"]);\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nexport const isComponentName = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nexport const isHookName = (name) => typeof name === \"string\" && name.startsWith(\"use\");\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * @param {ESTNode | null | undefined} node\n * @returns {FunctionLikeNode | null}\n */\nexport const getEnclosingFunction = (node) => {\n const findFunction = (current) => {\n if (!current) return null;\n if (isFunctionLike(current)) {\n return current;\n }\n return findFunction(isNode(current) ? current.parent ?? null : null);\n };\n return findFunction(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst isFunctionUsedAsJsxProp = (node) => {\n const checkJsxProp = (current) => {\n if (!current) return false;\n if (current.type === \"JSXAttribute\") {\n return true;\n }\n if (isFunctionLike(current)) {\n return false;\n }\n return checkJsxProp(isNode(current) ? current.parent ?? null : null);\n };\n return checkJsxProp(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst isFunctionImmediatelyInvoked = (node) => {\n const parent = isNode(node) ? node.parent ?? null : null;\n if (!parent) return false;\n\n // Check if the function is the callee of a CallExpression (i.e., it's immediately invoked)\n if (parent.type === \"CallExpression\" && parent.callee === node) {\n return true;\n }\n\n return false;\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n */\nconst expressionContainsJsx = (root) => {\n if (!root || !isNode(root)) return false;\n\n const stack = [root];\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (JSX_NODE_TYPES.has(current.type)) {\n return true;\n }\n\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n * @param {Set<string>} bindingNames\n */\nconst expressionProducesJsx = (root, bindingNames) => {\n if (!root) return false;\n if (expressionContainsJsx(root)) return true;\n\n if (!isNode(root)) return false;\n\n const type = root.type;\n\n if (type === \"Identifier\") {\n return bindingNames.has(root.name);\n }\n\n if (type === \"ConditionalExpression\") {\n return expressionProducesJsx(root.consequent, bindingNames) || expressionProducesJsx(root.alternate, bindingNames);\n }\n\n if (type === \"LogicalExpression\") {\n return expressionProducesJsx(root.left, bindingNames) || expressionProducesJsx(root.right, bindingNames);\n }\n\n if (type === \"SequenceExpression\") {\n const expressions = root.expressions ?? [];\n const last = expressions[expressions.length - 1] ?? null;\n return expressionProducesJsx(last, bindingNames);\n }\n\n if (type === \"ArrayExpression\") {\n return root.elements.some((element) => {\n if (!element) return false;\n if (element.type === \"SpreadElement\") {\n return expressionProducesJsx(element.argument, bindingNames);\n }\n return expressionProducesJsx(element, bindingNames);\n });\n }\n\n if (type === \"ParenthesizedExpression\") {\n return expressionProducesJsx(root.expression, bindingNames);\n }\n\n if (type === \"AwaitExpression\" || type === \"UnaryExpression\" || type === \"UpdateExpression\") {\n return expressionProducesJsx(root.argument, bindingNames);\n }\n\n if (\n type === \"TSAsExpression\" ||\n type === \"TSTypeAssertion\" ||\n type === \"TSNonNullExpression\" ||\n type === \"ChainExpression\"\n ) {\n return expressionProducesJsx(root.expression, bindingNames);\n }\n\n if (type === \"CallExpression\") {\n return expressionProducesJsx(root.callee, bindingNames);\n }\n\n if (type === \"MemberExpression\") {\n return expressionProducesJsx(root.object, bindingNames);\n }\n\n return false;\n};\n\n/**\n * @param {ESTPattern | null | undefined} pattern\n * @param {string[]} names\n */\nconst collectBindingNames = (pattern, names) => {\n if (!pattern || !isNode(pattern)) return;\n\n const type = pattern.type;\n\n if (type === \"Identifier\") {\n names.push(pattern.name);\n return;\n }\n\n if (type === \"ArrayPattern\") {\n for (const element of pattern.elements) {\n if (!element) continue;\n if (element.type === \"RestElement\") {\n collectBindingNames(element.argument, names);\n } else {\n collectBindingNames(element, names);\n }\n }\n return;\n }\n\n if (type === \"ObjectPattern\") {\n for (const property of pattern.properties) {\n if (!property) continue;\n if (property.type === \"Property\") {\n collectBindingNames(property.value, names);\n } else if (property.type === \"RestElement\") {\n collectBindingNames(property.argument, names);\n }\n }\n return;\n }\n\n if (type === \"AssignmentPattern\") {\n collectBindingNames(pattern.left, names);\n return;\n }\n\n if (type === \"RestElement\") {\n collectBindingNames(pattern.argument, names);\n }\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nexport const getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return parent.key && parent.key.type === \"Identifier\" ? parent.key.name : \"\";\n }\n\n // Handle functions passed as arguments to calls (e.g., useCallback, useMemo)\n if (parent.type === \"CallExpression\") {\n const callParent = parent.parent;\n if (callParent && isNode(callParent)) {\n if (callParent.type === \"VariableDeclarator\") {\n return callParent.id && callParent.id.type === \"Identifier\" ? callParent.id.name : \"\";\n }\n if (callParent.type === \"AssignmentExpression\") {\n return callParent.left && callParent.left.type === \"Identifier\" ? callParent.left.name : \"\";\n }\n }\n }\n\n return \"\";\n};\n\n/**\n * @param {string} name\n */\nconst describeFunction = (name) => (name ? `function '${name}'` : \"this function\");\n\n/**\n * @param {string} name\n */\nconst describeNested = (name) => (name ? `function '${name}'` : \"an anonymous function\");\n\n/**\n * @param {string[]} names\n * @param {string} fnName\n */\nconst createAssignmentMessage = (names, fnName) => {\n const target =\n names.length === 0\n ? \"local variables\"\n : names.length === 1\n ? `local '${names[0]}'`\n : `locals ${names.map((name) => `'${name}'`).join(\", \")}`;\n\n return `Avoid storing JSX in ${target} inside ${describeFunction(fnName)}; return the JSX directly instead.`;\n};\n\n/**\n * @param {string} childName\n * @param {string} parentName\n */\nconst createNestedFunctionMessage = (childName, parentName) =>\n `JSX-returning ${describeNested(childName)} should not be declared inside ${describeFunction(parentName)}. Extract it to module scope.`;\n\n/**\n * @param {string} name\n */\nconst createIIFEMessage = (name) =>\n `JSX-returning ${describeNested(name)} should not be declared as an immediately invoked function expression (IIFE). Extract it to a named function at module scope.`;\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow JSX-returning functions and JSX-valued assignments within other functions that also return JSX.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const parent = currentFunction();\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n parent,\n name: getFunctionName(node),\n returnsJsx: false,\n jsxBindingNames: new Set(),\n jsxAssignments: [],\n nestedJsxChildren: [],\n };\n\n functionStack.push(fnCtx);\n\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (expressionProducesJsx(node.body, fnCtx.jsxBindingNames)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n if (fnCtx.returnsJsx && isFunctionImmediatelyInvoked(fnCtx.node)) {\n context.report({\n node: fnCtx.node,\n message: createIIFEMessage(fnCtx.name),\n });\n return;\n }\n\n if (fnCtx.parent && fnCtx.returnsJsx && fnCtx.name && !isFunctionUsedAsJsxProp(fnCtx.node)) {\n fnCtx.parent.nestedJsxChildren.push({ node: fnCtx.node, name: fnCtx.name });\n }\n\n if (!fnCtx.returnsJsx) return;\n\n for (const assignment of fnCtx.jsxAssignments) {\n context.report({\n node: assignment.node,\n message: createAssignmentMessage(assignment.names, fnCtx.name),\n });\n }\n\n for (const nested of fnCtx.nestedJsxChildren) {\n context.report({\n node: nested.node,\n message: createNestedFunctionMessage(nested.name, fnCtx.name),\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument || isFunctionLike(argument)) return;\n\n if (expressionProducesJsx(argument, fnCtx.jsxBindingNames)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n /** @param {VariableDeclaratorNode} node */\n const handleVariableDeclarator = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const init = node.init;\n if (!init || isFunctionLike(init)) return;\n if (!expressionContainsJsx(init)) return;\n\n const names = [];\n collectBindingNames(node.id, names);\n for (const name of names) {\n fnCtx.jsxBindingNames.add(name);\n }\n\n fnCtx.jsxAssignments.push({ node: init, names });\n };\n\n /** @param {AssignmentExpressionNode} node */\n const handleAssignmentExpression = (node) => {\n if (node.operator !== \"=\") return;\n\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const right = node.right;\n if (!right || isFunctionLike(right)) return;\n if (!expressionContainsJsx(right)) return;\n\n const names = [];\n if (node.left && node.left.type === \"Identifier\") {\n names.push(node.left.name);\n fnCtx.jsxBindingNames.add(node.left.name);\n }\n\n fnCtx.jsxAssignments.push({ node: right, names });\n };\n\n /**\n * @param {import(\"oxlint\").ESTree.CallExpression} node\n */\n const handleCallExpression = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n // Check for array.push(<JSX>)\n if (\n node.callee &&\n node.callee.type === \"MemberExpression\" &&\n node.callee.property &&\n node.callee.property.type === \"Identifier\" &&\n node.callee.property.name === \"push\"\n ) {\n const arrayObject = node.callee.object;\n if (arrayObject && arrayObject.type === \"Identifier\") {\n const arrayName = arrayObject.name;\n\n // Check if any argument contains JSX\n const hasJsxArgument = node.arguments.some((arg) => {\n if (!arg || arg.type === \"SpreadElement\") return false;\n return expressionContainsJsx(arg);\n });\n\n if (hasJsxArgument) {\n fnCtx.jsxBindingNames.add(arrayName);\n fnCtx.jsxAssignments.push({ node: node, names: [arrayName] });\n }\n }\n }\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n VariableDeclarator(node) {\n if (node.type === \"VariableDeclarator\") handleVariableDeclarator(node);\n },\n AssignmentExpression(node) {\n if (node.type === \"AssignmentExpression\") handleAssignmentExpression(node);\n },\n CallExpression(node) {\n if (node.type === \"CallExpression\") handleCallExpression(node);\n },\n });\n },\n});\n\nexport const noInlineComponentsRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-inline-components\" },\n rules: { \"conorroberts/no-inline-components\": rule },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,iBAAiB,IAAI,IAAI,CAAC,cAAc,cAAc,CAAC;AAC7D,MAAM,sBAAsB,IAAI,IAAI;CAAC;CAAuB;CAAsB;CAA0B,CAAC;;;;;AAM7G,MAAa,mBAAmB,SAAS,OAAO,SAAS,YAAY,SAAS,KAAK,KAAK;;;;;AAMxF,MAAa,cAAc,SAAS,OAAO,SAAS,YAAY,KAAK,WAAW,MAAM;;;;;AAMtF,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,kBAAkB,SAAS,OAAO,KAAK,IAAI,oBAAoB,IAAI,KAAK,KAAK;;;;;AAMnF,MAAa,wBAAwB,SAAS;CAC5C,MAAM,gBAAgB,YAAY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wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAElE,mBAAmB,MAAM;AACvB,QAAI,KAAK,SAAS,qBAAsB,0BAAyB,KAAK;;GAExE,qBAAqB,MAAM;AACzB,QAAI,KAAK,SAAS,uBAAwB,4BAA2B,KAAK;;GAE5E,eAAe,MAAM;AACnB,QAAI,KAAK,SAAS,iBAAkB,sBAAqB,KAAK;;GAEjE;;CAEJ,CAAC;AAEF,MAAa,yBAAyB;AAEtC,mCAAe;CACb,MAAM,EAAE,MAAM,qCAAqC;CACnD,OAAO,EAAE,qCAAqC,MAAM;CACrD"}
1
+ {"version":3,"file":"no-inline-components.mjs","names":[],"sources":["../../src/oxlint-plugins/no-inline-components.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.Expression} ESTExpression\n * @typedef {import(\"oxlint\").ESTree.Pattern} ESTPattern\n * @typedef {import(\"oxlint\").ESTree.ReturnStatement} ReturnStatementNode\n * @typedef {import(\"oxlint\").ESTree.VariableDeclarator} VariableDeclaratorNode\n * @typedef {import(\"oxlint\").ESTree.AssignmentExpression} AssignmentExpressionNode\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\n/**\n * @typedef {object} RecordedAssignment\n * @property {ESTExpression} node\n * @property {string[]} names\n */\n\n/**\n * @typedef {object} NestedFunctionRecord\n * @property {FunctionLikeNode} node\n * @property {string} name\n */\n\n/**\n * @typedef {object} FunctionContext\n * @property {FunctionLikeNode} node\n * @property {FunctionContext | null} parent\n * @property {string} name\n * @property {boolean} returnsJsx\n * @property {Set<string>} jsxBindingNames\n * @property {RecordedAssignment[]} jsxAssignments\n * @property {NestedFunctionRecord[]} nestedJsxChildren\n */\n\nconst JSX_NODE_TYPES = new Set([\"JSXElement\", \"JSXFragment\"]);\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nexport const isComponentName = (name) => typeof name === \"string\" && /^[A-Z]/.test(name);\n\n/**\n * @param {unknown} name\n * @returns {name is string}\n */\nexport const isHookName = (name) => typeof name === \"string\" && name.startsWith(\"use\");\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * @param {ESTNode | null | undefined} node\n * @returns {FunctionLikeNode | null}\n */\nexport const getEnclosingFunction = (node) => {\n const findFunction = (current) => {\n if (!current) return null;\n if (isFunctionLike(current)) {\n return current;\n }\n return findFunction(isNode(current) ? current.parent ?? null : null);\n };\n return findFunction(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst isFunctionUsedAsJsxProp = (node) => {\n const checkJsxProp = (current) => {\n if (!current) return false;\n if (current.type === \"JSXAttribute\") {\n return true;\n }\n if (isFunctionLike(current)) {\n return false;\n }\n return checkJsxProp(isNode(current) ? current.parent ?? null : null);\n };\n return checkJsxProp(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nconst isFunctionImmediatelyInvoked = (node) => {\n const parent = isNode(node) ? node.parent ?? null : null;\n if (!parent) return false;\n\n // Check if the function is the callee of a CallExpression (i.e., it's immediately invoked)\n if (parent.type === \"CallExpression\" && parent.callee === node) {\n return true;\n }\n\n return false;\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n */\nconst expressionContainsJsx = (root) => {\n if (!root || !isNode(root)) return false;\n\n const stack = [root];\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (JSX_NODE_TYPES.has(current.type)) {\n return true;\n }\n\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\n/**\n * @param {ESTExpression | null | undefined} root\n * @param {Set<string>} bindingNames\n */\nconst expressionProducesJsx = (root, bindingNames) => {\n if (!root) return false;\n if (expressionContainsJsx(root)) return true;\n\n if (!isNode(root)) return false;\n\n const type = root.type;\n\n if (type === \"Identifier\") {\n return bindingNames.has(root.name);\n }\n\n if (type === \"ConditionalExpression\") {\n return expressionProducesJsx(root.consequent, bindingNames) || expressionProducesJsx(root.alternate, bindingNames);\n }\n\n if (type === \"LogicalExpression\") {\n return expressionProducesJsx(root.left, bindingNames) || expressionProducesJsx(root.right, bindingNames);\n }\n\n if (type === \"SequenceExpression\") {\n const expressions = root.expressions ?? [];\n const last = expressions[expressions.length - 1] ?? null;\n return expressionProducesJsx(last, bindingNames);\n }\n\n if (type === \"ArrayExpression\") {\n return root.elements.some((element) => {\n if (!element) return false;\n if (element.type === \"SpreadElement\") {\n return expressionProducesJsx(element.argument, bindingNames);\n }\n return expressionProducesJsx(element, bindingNames);\n });\n }\n\n if (type === \"ParenthesizedExpression\") {\n return expressionProducesJsx(root.expression, bindingNames);\n }\n\n if (type === \"AwaitExpression\" || type === \"UnaryExpression\" || type === \"UpdateExpression\") {\n return expressionProducesJsx(root.argument, bindingNames);\n }\n\n if (\n type === \"TSAsExpression\" ||\n type === \"TSTypeAssertion\" ||\n type === \"TSNonNullExpression\" ||\n type === \"ChainExpression\"\n ) {\n return expressionProducesJsx(root.expression, bindingNames);\n }\n\n if (type === \"CallExpression\") {\n return expressionProducesJsx(root.callee, bindingNames);\n }\n\n if (type === \"MemberExpression\") {\n return expressionProducesJsx(root.object, bindingNames);\n }\n\n return false;\n};\n\n/**\n * @param {ESTPattern | null | undefined} pattern\n * @param {string[]} names\n */\nconst collectBindingNames = (pattern, names) => {\n if (!pattern || !isNode(pattern)) return;\n\n const type = pattern.type;\n\n if (type === \"Identifier\") {\n names.push(pattern.name);\n return;\n }\n\n if (type === \"ArrayPattern\") {\n for (const element of pattern.elements) {\n if (!element) continue;\n if (element.type === \"RestElement\") {\n collectBindingNames(element.argument, names);\n } else {\n collectBindingNames(element, names);\n }\n }\n return;\n }\n\n if (type === \"ObjectPattern\") {\n for (const property of pattern.properties) {\n if (!property) continue;\n if (property.type === \"Property\") {\n collectBindingNames(property.value, names);\n } else if (property.type === \"RestElement\") {\n collectBindingNames(property.argument, names);\n }\n }\n return;\n }\n\n if (type === \"AssignmentPattern\") {\n collectBindingNames(pattern.left, names);\n return;\n }\n\n if (type === \"RestElement\") {\n collectBindingNames(pattern.argument, names);\n }\n};\n\n/**\n * @param {FunctionLikeNode} node\n */\nexport const getFunctionName = (node) => {\n if (node.type === \"FunctionDeclaration\" && node.id && node.id.type === \"Identifier\") {\n return node.id.name;\n }\n\n if ((node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") && node.id) {\n if (node.id.type === \"Identifier\") return node.id.name;\n }\n\n const parent = node.parent;\n if (!parent || !isNode(parent)) return \"\";\n\n if (parent.type === \"VariableDeclarator\") {\n return parent.id && parent.id.type === \"Identifier\" ? parent.id.name : \"\";\n }\n\n if (parent.type === \"AssignmentExpression\") {\n return parent.left && parent.left.type === \"Identifier\" ? parent.left.name : \"\";\n }\n\n if (parent.type === \"Property\" || parent.type === \"MethodDefinition\") {\n return parent.key && parent.key.type === \"Identifier\" ? parent.key.name : \"\";\n }\n\n // Handle functions passed as arguments to calls (e.g., useCallback, useMemo)\n if (parent.type === \"CallExpression\") {\n const callParent = parent.parent;\n if (callParent && isNode(callParent)) {\n if (callParent.type === \"VariableDeclarator\") {\n return callParent.id && callParent.id.type === \"Identifier\" ? callParent.id.name : \"\";\n }\n if (callParent.type === \"AssignmentExpression\") {\n return callParent.left && callParent.left.type === \"Identifier\" ? callParent.left.name : \"\";\n }\n }\n }\n\n return \"\";\n};\n\n/**\n * @param {string} name\n */\nconst describeFunction = (name) => (name ? `function '${name}'` : \"this function\");\n\n/**\n * @param {string} name\n */\nconst describeNested = (name) => (name ? `function '${name}'` : \"an anonymous function\");\n\n/**\n * @param {string[]} names\n * @param {string} fnName\n */\nconst createAssignmentMessage = (names, fnName) => {\n const target =\n names.length === 0\n ? \"local variables\"\n : names.length === 1\n ? `local '${names[0]}'`\n : `locals ${names.map((name) => `'${name}'`).join(\", \")}`;\n\n return `Avoid storing JSX in ${target} inside ${describeFunction(fnName)}; return the JSX directly instead.`;\n};\n\n/**\n * @param {string} childName\n * @param {string} parentName\n */\nconst createNestedFunctionMessage = (childName, parentName) =>\n `JSX-returning ${describeNested(childName)} should not be declared inside ${describeFunction(parentName)}. Extract it to module scope.`;\n\n/**\n * @param {string} name\n */\nconst createIIFEMessage = (name) =>\n `JSX-returning ${describeNested(name)} should not be declared as an immediately invoked function expression (IIFE). Extract it to a named function at module scope.`;\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow JSX-returning functions and JSX-valued assignments within other functions that also return JSX.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n /** @type {FunctionContext[]} */\n const functionStack = [];\n\n const currentFunction = () => functionStack[functionStack.length - 1] ?? null;\n\n /**\n * @param {FunctionLikeNode} node\n */\n const enterFunction = (node) => {\n const parent = currentFunction();\n /** @type {FunctionContext} */\n const fnCtx = {\n node,\n parent,\n name: getFunctionName(node),\n returnsJsx: false,\n jsxBindingNames: new Set(),\n jsxAssignments: [],\n nestedJsxChildren: [],\n };\n\n functionStack.push(fnCtx);\n\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n if (expressionProducesJsx(node.body, fnCtx.jsxBindingNames)) {\n fnCtx.returnsJsx = true;\n }\n }\n };\n\n const exitFunction = () => {\n const fnCtx = functionStack.pop();\n if (!fnCtx) return;\n\n if (fnCtx.returnsJsx && isFunctionImmediatelyInvoked(fnCtx.node)) {\n context.report({\n node: fnCtx.node,\n message: createIIFEMessage(fnCtx.name),\n });\n return;\n }\n\n if (fnCtx.parent && fnCtx.returnsJsx && fnCtx.name && !isFunctionUsedAsJsxProp(fnCtx.node)) {\n fnCtx.parent.nestedJsxChildren.push({ node: fnCtx.node, name: fnCtx.name });\n }\n\n if (!fnCtx.returnsJsx) return;\n\n for (const assignment of fnCtx.jsxAssignments) {\n context.report({\n node: assignment.node,\n message: createAssignmentMessage(assignment.names, fnCtx.name),\n });\n }\n\n for (const nested of fnCtx.nestedJsxChildren) {\n context.report({\n node: nested.node,\n message: createNestedFunctionMessage(nested.name, fnCtx.name),\n });\n }\n };\n\n /** @param {ReturnStatementNode} node */\n const handleReturnStatement = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const argument = node.argument;\n if (!argument || isFunctionLike(argument)) return;\n\n if (expressionProducesJsx(argument, fnCtx.jsxBindingNames)) {\n fnCtx.returnsJsx = true;\n }\n };\n\n /** @param {VariableDeclaratorNode} node */\n const handleVariableDeclarator = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const init = node.init;\n if (!init || isFunctionLike(init)) return;\n if (!expressionContainsJsx(init)) return;\n\n const names = [];\n collectBindingNames(node.id, names);\n for (const name of names) {\n fnCtx.jsxBindingNames.add(name);\n }\n\n fnCtx.jsxAssignments.push({ node: init, names });\n };\n\n /** @param {AssignmentExpressionNode} node */\n const handleAssignmentExpression = (node) => {\n if (node.operator !== \"=\") return;\n\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n const right = node.right;\n if (!right || isFunctionLike(right)) return;\n if (!expressionContainsJsx(right)) return;\n\n const names = [];\n if (node.left && node.left.type === \"Identifier\") {\n names.push(node.left.name);\n fnCtx.jsxBindingNames.add(node.left.name);\n }\n\n fnCtx.jsxAssignments.push({ node: right, names });\n };\n\n /**\n * @param {import(\"oxlint\").ESTree.CallExpression} node\n */\n const handleCallExpression = (node) => {\n const fnCtx = currentFunction();\n if (!fnCtx) return;\n\n // Check for array.push(<JSX>)\n if (\n node.callee &&\n node.callee.type === \"MemberExpression\" &&\n node.callee.property &&\n node.callee.property.type === \"Identifier\" &&\n node.callee.property.name === \"push\"\n ) {\n const arrayObject = node.callee.object;\n if (arrayObject && arrayObject.type === \"Identifier\") {\n const arrayName = arrayObject.name;\n\n // Check if any argument contains JSX\n const hasJsxArgument = node.arguments.some((arg) => {\n if (!arg || arg.type === \"SpreadElement\") return false;\n return expressionContainsJsx(arg);\n });\n\n if (hasJsxArgument) {\n fnCtx.jsxBindingNames.add(arrayName);\n fnCtx.jsxAssignments.push({ node: node, names: [arrayName] });\n }\n }\n }\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionDeclaration:exit\": exitFunction,\n FunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"FunctionExpression:exit\": exitFunction,\n ArrowFunctionExpression(node) {\n if (isFunctionLike(node)) enterFunction(node);\n },\n \"ArrowFunctionExpression:exit\": exitFunction,\n ReturnStatement(node) {\n if (node.type === \"ReturnStatement\") handleReturnStatement(node);\n },\n VariableDeclarator(node) {\n if (node.type === \"VariableDeclarator\") handleVariableDeclarator(node);\n },\n AssignmentExpression(node) {\n if (node.type === \"AssignmentExpression\") handleAssignmentExpression(node);\n },\n CallExpression(node) {\n if (node.type === \"CallExpression\") handleCallExpression(node);\n },\n });\n },\n});\n\nexport const noInlineComponentsRule = rule;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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AO;AAChC,QAAI,eAAe,YAAY,SAAS,cAAc;KACpD,MAAM,YAAY,YAAY;AAQ9B,SALuB,KAAK,UAAU,MAAM,QAAQ;AAClD,UAAI,CAAC,OAAO,IAAI,SAAS,gBAAiB,QAAO;AACjD,aAAO,sBAAsB,IAAI;OACjC,EAEkB;AAClB,YAAM,gBAAgB,IAAI,UAAU;AACpC,YAAM,eAAe,KAAK;OAAQ;OAAM,OAAO,CAAC,UAAU;OAAE,CAAC;;;;;AAMrE,SAAyD;GACvD,oBAAoB,MAAM;AACxB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,4BAA4B;GAC5B,mBAAmB,MAAM;AACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,2BAA2B;GAC3B,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,gCAAgC;GAChC,gBAAgB,MAAM;AACpB,QAAI,KAAK,SAAS,kBAAmB,uBAAsB,KAAK;;GAElE,mBAAmB,MAAM;AACvB,QAAI,KAAK,SAAS,qBAAsB,0BAAyB,KAAK;;GAExE,qBAAqB,MAAM;AACzB,QAAI,KAAK,SAAS,uBAAwB,4BAA2B,KAAK;;GAE5E,eAAe,MAAM;AACnB,QAAI,KAAK,SAAS,iBAAkB,sBAAqB,KAAK;;GAEjE;;CAEJ,CAAC;AAEF,MAAa,yBAAyB"}
@@ -1,16 +1,8 @@
1
- import * as oxlint4 from "oxlint";
1
+ import * as oxlint37 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-react-namespace.d.ts
4
- declare const noReactNamespaceRule: oxlint4.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-react-namespace": oxlint4.Rule;
11
- };
12
- }
13
- type ESTNode = oxlint4.ESTree.Node;
4
+ declare const noReactNamespaceRule: oxlint37.Rule;
5
+ type ESTNode = oxlint37.ESTree.Node;
14
6
  //#endregion
15
- export { ESTNode, _default as default, noReactNamespaceRule };
7
+ export { ESTNode, noReactNamespaceRule };
16
8
  //# sourceMappingURL=no-react-namespace.d.mts.map
@@ -65,11 +65,7 @@ const rule = defineRule({
65
65
  }
66
66
  });
67
67
  const noReactNamespaceRule = rule;
68
- var no_react_namespace_default = {
69
- meta: { name: "conorroberts/no-react-namespace" },
70
- rules: { "conorroberts/no-react-namespace": rule }
71
- };
72
68
 
73
69
  //#endregion
74
- export { no_react_namespace_default as default, noReactNamespaceRule };
70
+ export { noReactNamespaceRule };
75
71
  //# sourceMappingURL=no-react-namespace.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-react-namespace.mjs","names":[],"sources":["../../src/oxlint-plugins/no-react-namespace.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Check if a MemberExpression is accessing the React namespace\n * @param {ESTNode} node\n * @returns {boolean}\n */\nconst isReactNamespaceAccess = (node) => {\n if (node.type !== \"MemberExpression\") return false;\n\n const object = node.object;\n if (!object || object.type !== \"Identifier\" || object.name !== \"React\") {\n return false;\n }\n\n return true;\n};\n\n/**\n * Check if this is a type annotation context (TypeScript)\n * @param {ESTNode} node\n * @returns {boolean}\n */\nconst isTypeContext = (node) => {\n const checkParent = (current) => {\n if (!current) return false;\n\n // Type annotation contexts where React namespace is allowed\n const typeContextTypes = new Set([\n \"TSTypeReference\",\n \"TSTypeAnnotation\",\n \"TSTypeParameterInstantiation\",\n \"TSInterfaceHeritage\",\n \"TSTypeQuery\",\n \"TSTypeAliasDeclaration\",\n \"TSInterfaceDeclaration\",\n \"TSTypeLiteral\",\n \"TSPropertySignature\",\n \"TSIndexSignature\",\n \"TSMethodSignature\",\n \"TSCallSignatureDeclaration\",\n \"TSConstructSignatureDeclaration\",\n \"TSExpressionWithTypeArguments\",\n ]);\n\n if (typeContextTypes.has(current.type)) {\n return true;\n }\n\n // Stop at statement or expression boundaries\n if (\n current.type === \"ExpressionStatement\" ||\n current.type === \"VariableDeclarator\" ||\n current.type === \"CallExpression\" ||\n current.type === \"ReturnStatement\"\n ) {\n return false;\n }\n\n return checkParent(current.parent);\n };\n\n return checkParent(node.parent);\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow using the React namespace for accessing React APIs. Use destructured imports instead (e.g., import { useState } from 'react').\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n MemberExpression(node) {\n if (node.type !== \"MemberExpression\") return;\n\n if (!isReactNamespaceAccess(node)) return;\n\n // Allow React namespace in type annotations\n if (isTypeContext(node)) return;\n\n const propertyName = node.property && node.property.type === \"Identifier\" ? node.property.name : \"property\";\n\n context.report({\n node,\n message: `Avoid using 'React.${propertyName}'. Import '${propertyName}' directly from 'react' instead (e.g., import { ${propertyName} } from 'react').`,\n });\n },\n });\n },\n});\n\nexport const noReactNamespaceRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-react-namespace\" },\n rules: { \"conorroberts/no-react-namespace\": rule },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,0BAA0B,SAAS;AACvC,KAAI,KAAK,SAAS,mBAAoB,QAAO;CAE7C,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,UAAU,OAAO,SAAS,gBAAgB,OAAO,SAAS,QAC7D,QAAO;AAGT,QAAO;;;;;;;AAQT,MAAM,iBAAiB,SAAS;CAC9B,MAAM,eAAe,YAAY;AAC/B,MAAI,CAAC,QAAS,QAAO;AAoBrB,MAjByB,IAAI,IAAI;GAC/B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,CAEmB,IAAI,QAAQ,KAAK,CACpC,QAAO;AAIT,MACE,QAAQ,SAAS,yBACjB,QAAQ,SAAS,wBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,kBAEjB,QAAO;AAGT,SAAO,YAAY,QAAQ,OAAO;;AAGpC,QAAO,YAAY,KAAK,OAAO;;AAGjC,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aACE;GACF,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,iBAAiB,MAAM;AACrB,OAAI,KAAK,SAAS,mBAAoB;AAEtC,OAAI,CAAC,uBAAuB,KAAK,CAAE;AAGnC,OAAI,cAAc,KAAK,CAAE;GAEzB,MAAM,eAAe,KAAK,YAAY,KAAK,SAAS,SAAS,eAAe,KAAK,SAAS,OAAO;AAEjG,WAAQ,OAAO;IACb;IACA,SAAS,sBAAsB,aAAa,aAAa,aAAa,kDAAkD,aAAa;IACtI,CAAC;KAEL;;CAEJ,CAAC;AAEF,MAAa,uBAAuB;AAEpC,iCAAe;CACb,MAAM,EAAE,MAAM,mCAAmC;CACjD,OAAO,EAAE,mCAAmC,MAAM;CACnD"}
1
+ {"version":3,"file":"no-react-namespace.mjs","names":[],"sources":["../../src/oxlint-plugins/no-react-namespace.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Check if a MemberExpression is accessing the React namespace\n * @param {ESTNode} node\n * @returns {boolean}\n */\nconst isReactNamespaceAccess = (node) => {\n if (node.type !== \"MemberExpression\") return false;\n\n const object = node.object;\n if (!object || object.type !== \"Identifier\" || object.name !== \"React\") {\n return false;\n }\n\n return true;\n};\n\n/**\n * Check if this is a type annotation context (TypeScript)\n * @param {ESTNode} node\n * @returns {boolean}\n */\nconst isTypeContext = (node) => {\n const checkParent = (current) => {\n if (!current) return false;\n\n // Type annotation contexts where React namespace is allowed\n const typeContextTypes = new Set([\n \"TSTypeReference\",\n \"TSTypeAnnotation\",\n \"TSTypeParameterInstantiation\",\n \"TSInterfaceHeritage\",\n \"TSTypeQuery\",\n \"TSTypeAliasDeclaration\",\n \"TSInterfaceDeclaration\",\n \"TSTypeLiteral\",\n \"TSPropertySignature\",\n \"TSIndexSignature\",\n \"TSMethodSignature\",\n \"TSCallSignatureDeclaration\",\n \"TSConstructSignatureDeclaration\",\n \"TSExpressionWithTypeArguments\",\n ]);\n\n if (typeContextTypes.has(current.type)) {\n return true;\n }\n\n // Stop at statement or expression boundaries\n if (\n current.type === \"ExpressionStatement\" ||\n current.type === \"VariableDeclarator\" ||\n current.type === \"CallExpression\" ||\n current.type === \"ReturnStatement\"\n ) {\n return false;\n }\n\n return checkParent(current.parent);\n };\n\n return checkParent(node.parent);\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow using the React namespace for accessing React APIs. Use destructured imports instead (e.g., import { useState } from 'react').\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n MemberExpression(node) {\n if (node.type !== \"MemberExpression\") return;\n\n if (!isReactNamespaceAccess(node)) return;\n\n // Allow React namespace in type annotations\n if (isTypeContext(node)) return;\n\n const propertyName = node.property && node.property.type === \"Identifier\" ? node.property.name : \"property\";\n\n context.report({\n node,\n message: `Avoid using 'React.${propertyName}'. Import '${propertyName}' directly from 'react' instead (e.g., import { ${propertyName} } from 'react').`,\n });\n },\n });\n },\n});\n\nexport const noReactNamespaceRule = rule;\n\n"],"mappings":";;;;;;;;;AASA,MAAM,0BAA0B,SAAS;AACvC,KAAI,KAAK,SAAS,mBAAoB,QAAO;CAE7C,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,UAAU,OAAO,SAAS,gBAAgB,OAAO,SAAS,QAC7D,QAAO;AAGT,QAAO;;;;;;;AAQT,MAAM,iBAAiB,SAAS;CAC9B,MAAM,eAAe,YAAY;AAC/B,MAAI,CAAC,QAAS,QAAO;AAoBrB,MAjByB,IAAI,IAAI;GAC/B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,CAEmB,IAAI,QAAQ,KAAK,CACpC,QAAO;AAIT,MACE,QAAQ,SAAS,yBACjB,QAAQ,SAAS,wBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,kBAEjB,QAAO;AAGT,SAAO,YAAY,QAAQ,OAAO;;AAGpC,QAAO,YAAY,KAAK,OAAO;;AAGjC,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aACE;GACF,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,iBAAiB,MAAM;AACrB,OAAI,KAAK,SAAS,mBAAoB;AAEtC,OAAI,CAAC,uBAAuB,KAAK,CAAE;AAGnC,OAAI,cAAc,KAAK,CAAE;GAEzB,MAAM,eAAe,KAAK,YAAY,KAAK,SAAS,SAAS,eAAe,KAAK,SAAS,OAAO;AAEjG,WAAQ,OAAO;IACb;IACA,SAAS,sBAAsB,aAAa,aAAa,aAAa,kDAAkD,aAAa;IACtI,CAAC;KAEL;;CAEJ,CAAC;AAEF,MAAa,uBAAuB"}
@@ -1,15 +1,9 @@
1
- import * as oxlint2 from "oxlint";
1
+ import * as oxlint26 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-switch-plugin.d.ts
4
- declare namespace _default {
5
- namespace meta {
6
- let name: string;
7
- }
8
- let rules: {
9
- "conorroberts/no-switch": oxlint2.Rule;
10
- };
11
- }
12
- type ESTNode = oxlint2.ESTree.Node;
4
+ /** @typedef {import("oxlint").ESTree.Node} ESTNode */
5
+ declare const noSwitchRule: oxlint26.Rule;
6
+ type ESTNode = oxlint26.ESTree.Node;
13
7
  //#endregion
14
- export { ESTNode, _default as default };
8
+ export { ESTNode, noSwitchRule };
15
9
  //# sourceMappingURL=no-switch-plugin.d.mts.map
@@ -21,11 +21,7 @@ const noSwitchRule = defineRule({
21
21
  } };
22
22
  }
23
23
  });
24
- var no_switch_plugin_default = {
25
- meta: { name: "conorroberts/no-switch-plugin" },
26
- rules: { "conorroberts/no-switch": noSwitchRule }
27
- };
28
24
 
29
25
  //#endregion
30
- export { no_switch_plugin_default as default };
26
+ export { noSwitchRule };
31
27
  //# sourceMappingURL=no-switch-plugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-switch-plugin.mjs","names":[],"sources":["../../src/oxlint-plugins/no-switch-plugin.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nconst noSwitchRule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow switch/case statements\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n SwitchStatement(node) {\n if (node.type !== \"SwitchStatement\") return;\n\n context.report({\n node,\n message: \"Use of switch/case is disallowed. Use object map or if/else instead.\",\n });\n },\n });\n },\n});\n\nexport default {\n meta: {\n name: \"conorroberts/no-switch-plugin\",\n },\n rules: {\n \"conorroberts/no-switch\": noSwitchRule,\n },\n};\n"],"mappings":";;;;AAIA,MAAM,eAAe,WAAW;CAC9B,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,gBAAgB,MAAM;AACpB,OAAI,KAAK,SAAS,kBAAmB;AAErC,WAAQ,OAAO;IACb;IACA,SAAS;IACV,CAAC;KAEL;;CAEJ,CAAC;AAEF,+BAAe;CACb,MAAM,EACJ,MAAM,iCACP;CACD,OAAO,EACL,0BAA0B,cAC3B;CACF"}
1
+ {"version":3,"file":"no-switch-plugin.mjs","names":[],"sources":["../../src/oxlint-plugins/no-switch-plugin.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nexport const noSwitchRule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow switch/case statements\",\n recommended: true,\n },\n schema: [],\n },\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} node\n */\n SwitchStatement(node) {\n if (node.type !== \"SwitchStatement\") return;\n\n context.report({\n node,\n message: \"Use of switch/case is disallowed. Use object map or if/else instead.\",\n });\n },\n });\n },\n});\n"],"mappings":";;;;AAIA,MAAa,eAAe,WAAW;CACrC,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CACD,WAAW,SAAS;AAClB,SAAyD,EAIvD,gBAAgB,MAAM;AACpB,OAAI,KAAK,SAAS,kBAAmB;AAErC,WAAQ,OAAO;IACb;IACA,SAAS;IACV,CAAC;KAEL;;CAEJ,CAAC"}
@@ -1,16 +1,8 @@
1
- import * as oxlint10 from "oxlint";
1
+ import * as oxlint0 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-top-level-let.d.ts
4
- declare const noTopLevelLetRule: oxlint10.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-top-level-let": oxlint10.Rule;
11
- };
12
- }
13
- type ESTNode = oxlint10.ESTree.Node;
4
+ declare const noTopLevelLetRule: oxlint0.Rule;
5
+ type ESTNode = oxlint0.ESTree.Node;
14
6
  //#endregion
15
- export { ESTNode, _default as default, noTopLevelLetRule };
7
+ export { ESTNode, noTopLevelLetRule };
16
8
  //# sourceMappingURL=no-top-level-let.d.mts.map
@@ -56,11 +56,7 @@ const rule = defineRule({
56
56
  }
57
57
  });
58
58
  const noTopLevelLetRule = rule;
59
- var no_top_level_let_default = {
60
- meta: { name: "conorroberts/no-top-level-let" },
61
- rules: { "conorroberts/no-top-level-let": rule }
62
- };
63
59
 
64
60
  //#endregion
65
- export { no_top_level_let_default as default, noTopLevelLetRule };
61
+ export { noTopLevelLetRule };
66
62
  //# sourceMappingURL=no-top-level-let.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-top-level-let.mjs","names":[],"sources":["../../src/oxlint-plugins/no-top-level-let.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Get the enclosing function node for a given node\n * @param {ESTNode} node\n * @returns {ESTNode | null}\n */\nconst getEnclosingFunction = (node) => {\n const findFunction = (current) => {\n if (!current) return null;\n if (\n current.type === \"FunctionDeclaration\" ||\n current.type === \"FunctionExpression\" ||\n current.type === \"ArrowFunctionExpression\"\n ) {\n return current;\n }\n return findFunction(current.parent);\n };\n return findFunction(node.parent);\n};\n\n/**\n * Check if a node is inside a loop\n * @param {ESTNode} node\n * @param {ESTNode} stopAt - Stop searching when we reach this node\n * @returns {boolean}\n */\nconst isInsideLoop = (node, stopAt) => {\n const checkLoop = (current) => {\n if (!current || current === stopAt) return false;\n if (\n current.type === \"ForStatement\" ||\n current.type === \"ForInStatement\" ||\n current.type === \"ForOfStatement\" ||\n current.type === \"WhileStatement\" ||\n current.type === \"DoWhileStatement\"\n ) {\n return true;\n }\n return checkLoop(current.parent);\n };\n return checkLoop(node.parent);\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow top-level `let` declarations inside functions to prevent conditional reassignment.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} rawNode\n */\n VariableDeclaration(rawNode) {\n if (rawNode.type !== \"VariableDeclaration\") return;\n const node = rawNode;\n\n if (node.kind !== \"let\") return;\n\n const fn = getEnclosingFunction(node);\n if (\n !fn ||\n (fn.type !== \"FunctionDeclaration\" &&\n fn.type !== \"FunctionExpression\" &&\n fn.type !== \"ArrowFunctionExpression\")\n ) {\n return;\n }\n\n const parent = node.parent;\n if (!parent || parent.type !== \"BlockStatement\" || parent.parent !== fn) return;\n\n // Allow let declarations inside loops\n if (isInsideLoop(node, fn)) return;\n\n context.report({\n node,\n message:\n \"Avoid using `let` at the top level of functions; prefer `const` with extracted functions to avoid conditional reassignment. Extract conditional logic into a separate function that returns the appropriate value.\",\n });\n },\n });\n },\n});\n\nexport const noTopLevelLetRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-top-level-let\" },\n rules: { \"conorroberts/no-top-level-let\": rule },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,wBAAwB,SAAS;CACrC,MAAM,gBAAgB,YAAY;AAChC,MAAI,CAAC,QAAS,QAAO;AACrB,MACE,QAAQ,SAAS,yBACjB,QAAQ,SAAS,wBACjB,QAAQ,SAAS,0BAEjB,QAAO;AAET,SAAO,aAAa,QAAQ,OAAO;;AAErC,QAAO,aAAa,KAAK,OAAO;;;;;;;;AASlC,MAAM,gBAAgB,MAAM,WAAW;CACrC,MAAM,aAAa,YAAY;AAC7B,MAAI,CAAC,WAAW,YAAY,OAAQ,QAAO;AAC3C,MACE,QAAQ,SAAS,kBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,mBAEjB,QAAO;AAET,SAAO,UAAU,QAAQ,OAAO;;AAElC,QAAO,UAAU,KAAK,OAAO;;AAG/B,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,WAAW,SAAS;AAClB,SAAyD,EAIvD,oBAAoB,SAAS;AAC3B,OAAI,QAAQ,SAAS,sBAAuB;GAC5C,MAAM,OAAO;AAEb,OAAI,KAAK,SAAS,MAAO;GAEzB,MAAM,KAAK,qBAAqB,KAAK;AACrC,OACE,CAAC,MACA,GAAG,SAAS,yBACX,GAAG,SAAS,wBACZ,GAAG,SAAS,0BAEd;GAGF,MAAM,SAAS,KAAK;AACpB,OAAI,CAAC,UAAU,OAAO,SAAS,oBAAoB,OAAO,WAAW,GAAI;AAGzE,OAAI,aAAa,MAAM,GAAG,CAAE;AAE5B,WAAQ,OAAO;IACb;IACA,SACE;IACH,CAAC;KAEL;;CAEJ,CAAC;AAEF,MAAa,oBAAoB;AAEjC,+BAAe;CACb,MAAM,EAAE,MAAM,iCAAiC;CAC/C,OAAO,EAAE,iCAAiC,MAAM;CACjD"}
1
+ {"version":3,"file":"no-top-level-let.mjs","names":[],"sources":["../../src/oxlint-plugins/no-top-level-let.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\n/**\n * Get the enclosing function node for a given node\n * @param {ESTNode} node\n * @returns {ESTNode | null}\n */\nconst getEnclosingFunction = (node) => {\n const findFunction = (current) => {\n if (!current) return null;\n if (\n current.type === \"FunctionDeclaration\" ||\n current.type === \"FunctionExpression\" ||\n current.type === \"ArrowFunctionExpression\"\n ) {\n return current;\n }\n return findFunction(current.parent);\n };\n return findFunction(node.parent);\n};\n\n/**\n * Check if a node is inside a loop\n * @param {ESTNode} node\n * @param {ESTNode} stopAt - Stop searching when we reach this node\n * @returns {boolean}\n */\nconst isInsideLoop = (node, stopAt) => {\n const checkLoop = (current) => {\n if (!current || current === stopAt) return false;\n if (\n current.type === \"ForStatement\" ||\n current.type === \"ForInStatement\" ||\n current.type === \"ForOfStatement\" ||\n current.type === \"WhileStatement\" ||\n current.type === \"DoWhileStatement\"\n ) {\n return true;\n }\n return checkLoop(current.parent);\n };\n return checkLoop(node.parent);\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow top-level `let` declarations inside functions to prevent conditional reassignment.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} rawNode\n */\n VariableDeclaration(rawNode) {\n if (rawNode.type !== \"VariableDeclaration\") return;\n const node = rawNode;\n\n if (node.kind !== \"let\") return;\n\n const fn = getEnclosingFunction(node);\n if (\n !fn ||\n (fn.type !== \"FunctionDeclaration\" &&\n fn.type !== \"FunctionExpression\" &&\n fn.type !== \"ArrowFunctionExpression\")\n ) {\n return;\n }\n\n const parent = node.parent;\n if (!parent || parent.type !== \"BlockStatement\" || parent.parent !== fn) return;\n\n // Allow let declarations inside loops\n if (isInsideLoop(node, fn)) return;\n\n context.report({\n node,\n message:\n \"Avoid using `let` at the top level of functions; prefer `const` with extracted functions to avoid conditional reassignment. Extract conditional logic into a separate function that returns the appropriate value.\",\n });\n },\n });\n },\n});\n\nexport const noTopLevelLetRule = rule;\n\n"],"mappings":";;;;;;;;;AASA,MAAM,wBAAwB,SAAS;CACrC,MAAM,gBAAgB,YAAY;AAChC,MAAI,CAAC,QAAS,QAAO;AACrB,MACE,QAAQ,SAAS,yBACjB,QAAQ,SAAS,wBACjB,QAAQ,SAAS,0BAEjB,QAAO;AAET,SAAO,aAAa,QAAQ,OAAO;;AAErC,QAAO,aAAa,KAAK,OAAO;;;;;;;;AASlC,MAAM,gBAAgB,MAAM,WAAW;CACrC,MAAM,aAAa,YAAY;AAC7B,MAAI,CAAC,WAAW,YAAY,OAAQ,QAAO;AAC3C,MACE,QAAQ,SAAS,kBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,mBAEjB,QAAO;AAET,SAAO,UAAU,QAAQ,OAAO;;AAElC,QAAO,UAAU,KAAK,OAAO;;AAG/B,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,WAAW,SAAS;AAClB,SAAyD,EAIvD,oBAAoB,SAAS;AAC3B,OAAI,QAAQ,SAAS,sBAAuB;GAC5C,MAAM,OAAO;AAEb,OAAI,KAAK,SAAS,MAAO;GAEzB,MAAM,KAAK,qBAAqB,KAAK;AACrC,OACE,CAAC,MACA,GAAG,SAAS,yBACX,GAAG,SAAS,wBACZ,GAAG,SAAS,0BAEd;GAGF,MAAM,SAAS,KAAK;AACpB,OAAI,CAAC,UAAU,OAAO,SAAS,oBAAoB,OAAO,WAAW,GAAI;AAGzE,OAAI,aAAa,MAAM,GAAG,CAAE;AAE5B,WAAQ,OAAO;IACb;IACA,SACE;IACH,CAAC;KAEL;;CAEJ,CAAC;AAEF,MAAa,oBAAoB"}
@@ -1,16 +1,8 @@
1
- import * as oxlint0 from "oxlint";
1
+ import * as oxlint8 from "oxlint";
2
2
 
3
3
  //#region src/oxlint-plugins/no-type-cast.d.ts
4
- declare const noTypeCastRule: oxlint0.Rule;
5
- declare namespace _default {
6
- namespace meta {
7
- let name: string;
8
- }
9
- let rules: {
10
- "conorroberts/no-type-cast": oxlint0.Rule;
11
- };
12
- }
13
- type ESTNode = oxlint0.ESTree.Node;
4
+ declare const noTypeCastRule: oxlint8.Rule;
5
+ type ESTNode = oxlint8.ESTree.Node;
14
6
  //#endregion
15
- export { ESTNode, _default as default, noTypeCastRule };
7
+ export { ESTNode, noTypeCastRule };
16
8
  //# sourceMappingURL=no-type-cast.d.mts.map
@@ -39,11 +39,7 @@ const rule = defineRule({
39
39
  }
40
40
  });
41
41
  const noTypeCastRule = rule;
42
- var no_type_cast_default = {
43
- meta: { name: "conorroberts/no-type-cast" },
44
- rules: { "conorroberts/no-type-cast": rule }
45
- };
46
42
 
47
43
  //#endregion
48
- export { no_type_cast_default as default, noTypeCastRule };
44
+ export { noTypeCastRule };
49
45
  //# sourceMappingURL=no-type-cast.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"no-type-cast.mjs","names":[],"sources":["../../src/oxlint-plugins/no-type-cast.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow TypeScript type assertions (`as` and angle-bracket syntax) to prevent unsafe type casting.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} rawNode\n */\n TSAsExpression(rawNode) {\n if (rawNode.type !== \"TSAsExpression\") return;\n\n // Allow \"as const\" assertions\n if (\n rawNode.typeAnnotation.type === \"TSTypeReference\" &&\n rawNode.typeAnnotation.typeName.type === \"Identifier\" &&\n rawNode.typeAnnotation.typeName.name === \"const\"\n ) {\n return;\n }\n\n context.report({\n node: rawNode,\n message:\n \"Type casting with `as` is not permitted. Use runtime validation with valibot or refactor to avoid type casting.\",\n });\n },\n\n /**\n * @param {ESTNode} rawNode\n */\n TSTypeAssertion(rawNode) {\n if (rawNode.type !== \"TSTypeAssertion\") return;\n\n context.report({\n node: rawNode,\n message:\n \"Type casting with angle brackets `<Type>` is not permitted. Use runtime validation with valibot or refactor to avoid type casting.\",\n });\n },\n\n /**\n * @param {ESTNode} rawNode\n */\n TSNonNullExpression(rawNode) {\n if (rawNode.type !== \"TSNonNullExpression\") return;\n\n context.report({\n node: rawNode,\n message:\n \"Non-null assertion operator `!` is not permitted. Handle null/undefined cases explicitly or use optional chaining.\",\n });\n },\n });\n },\n});\n\nexport const noTypeCastRule = rule;\n\nexport default {\n meta: { name: \"conorroberts/no-type-cast\" },\n rules: { \"conorroberts/no-type-cast\": rule },\n};\n"],"mappings":";;;;AAIA,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aACE;GACF,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,WAAW,SAAS;AAClB,SAAyD;GAIvD,eAAe,SAAS;AACtB,QAAI,QAAQ,SAAS,iBAAkB;AAGvC,QACE,QAAQ,eAAe,SAAS,qBAChC,QAAQ,eAAe,SAAS,SAAS,gBACzC,QAAQ,eAAe,SAAS,SAAS,QAEzC;AAGF,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAMJ,gBAAgB,SAAS;AACvB,QAAI,QAAQ,SAAS,kBAAmB;AAExC,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAMJ,oBAAoB,SAAS;AAC3B,QAAI,QAAQ,SAAS,sBAAuB;AAE5C,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAEL;;CAEJ,CAAC;AAEF,MAAa,iBAAiB;AAE9B,2BAAe;CACb,MAAM,EAAE,MAAM,6BAA6B;CAC3C,OAAO,EAAE,6BAA6B,MAAM;CAC7C"}
1
+ {"version":3,"file":"no-type-cast.mjs","names":[],"sources":["../../src/oxlint-plugins/no-type-cast.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/** @typedef {import(\"oxlint\").ESTree.Node} ESTNode */\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow TypeScript type assertions (`as` and angle-bracket syntax) to prevent unsafe type casting.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n /**\n * @param {ESTNode} rawNode\n */\n TSAsExpression(rawNode) {\n if (rawNode.type !== \"TSAsExpression\") return;\n\n // Allow \"as const\" assertions\n if (\n rawNode.typeAnnotation.type === \"TSTypeReference\" &&\n rawNode.typeAnnotation.typeName.type === \"Identifier\" &&\n rawNode.typeAnnotation.typeName.name === \"const\"\n ) {\n return;\n }\n\n context.report({\n node: rawNode,\n message:\n \"Type casting with `as` is not permitted. Use runtime validation with valibot or refactor to avoid type casting.\",\n });\n },\n\n /**\n * @param {ESTNode} rawNode\n */\n TSTypeAssertion(rawNode) {\n if (rawNode.type !== \"TSTypeAssertion\") return;\n\n context.report({\n node: rawNode,\n message:\n \"Type casting with angle brackets `<Type>` is not permitted. Use runtime validation with valibot or refactor to avoid type casting.\",\n });\n },\n\n /**\n * @param {ESTNode} rawNode\n */\n TSNonNullExpression(rawNode) {\n if (rawNode.type !== \"TSNonNullExpression\") return;\n\n context.report({\n node: rawNode,\n message:\n \"Non-null assertion operator `!` is not permitted. Handle null/undefined cases explicitly or use optional chaining.\",\n });\n },\n });\n },\n});\n\nexport const noTypeCastRule = rule;\n\n"],"mappings":";;;;AAIA,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aACE;GACF,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,WAAW,SAAS;AAClB,SAAyD;GAIvD,eAAe,SAAS;AACtB,QAAI,QAAQ,SAAS,iBAAkB;AAGvC,QACE,QAAQ,eAAe,SAAS,qBAChC,QAAQ,eAAe,SAAS,SAAS,gBACzC,QAAQ,eAAe,SAAS,SAAS,QAEzC;AAGF,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAMJ,gBAAgB,SAAS;AACvB,QAAI,QAAQ,SAAS,kBAAmB;AAExC,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAMJ,oBAAoB,SAAS;AAC3B,QAAI,QAAQ,SAAS,sBAAuB;AAE5C,YAAQ,OAAO;KACb,MAAM;KACN,SACE;KACH,CAAC;;GAEL;;CAEJ,CAAC;AAEF,MAAa,iBAAiB"}
@@ -0,0 +1,11 @@
1
+ import * as oxlint10 from "oxlint";
2
+
3
+ //#region src/oxlint-plugins/pretty-props.d.ts
4
+ declare const prettyPropsRule: oxlint10.Rule;
5
+ type RuleContext = oxlint10.Context;
6
+ type ESTNode = oxlint10.ESTree.Node;
7
+ type ESTExpression = oxlint10.ESTree.Expression;
8
+ type FunctionLikeNode = oxlint10.ESTree.Function | oxlint10.ESTree.ArrowFunctionExpression;
9
+ //#endregion
10
+ export { ESTExpression, ESTNode, FunctionLikeNode, RuleContext, prettyPropsRule };
11
+ //# sourceMappingURL=pretty-props.d.mts.map
@@ -0,0 +1,127 @@
1
+ import { defineRule } from "oxlint";
2
+
3
+ //#region src/oxlint-plugins/pretty-props.js
4
+ /**
5
+ * @typedef {import("oxlint").Context} RuleContext
6
+ * @typedef {import("oxlint").ESTree.Node} ESTNode
7
+ * @typedef {import("oxlint").ESTree.Expression} ESTExpression
8
+ * @typedef {import("oxlint").ESTree.Function | import("oxlint").ESTree.ArrowFunctionExpression} FunctionLikeNode
9
+ */
10
+ const JSX_NODE_TYPES = new Set(["JSXElement", "JSXFragment"]);
11
+ const FUNCTION_NODE_TYPES = new Set([
12
+ "FunctionDeclaration",
13
+ "FunctionExpression",
14
+ "ArrowFunctionExpression"
15
+ ]);
16
+ /**
17
+ * @param {unknown} node
18
+ * @returns {node is ESTNode & { type: string }}
19
+ */
20
+ const isNode = (node) => Boolean(node && typeof node === "object" && "type" in node);
21
+ /**
22
+ * @param {unknown} node
23
+ * @returns {node is FunctionLikeNode}
24
+ */
25
+ const isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);
26
+ /**
27
+ * Check if an expression contains JSX
28
+ * @param {ESTExpression | null | undefined} root
29
+ */
30
+ const expressionContainsJsx = (root) => {
31
+ if (!root || !isNode(root)) return false;
32
+ const stack = [root];
33
+ while (stack.length > 0) {
34
+ const current = stack.pop();
35
+ if (!current || !isNode(current)) continue;
36
+ if (JSX_NODE_TYPES.has(current.type)) return true;
37
+ if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) continue;
38
+ for (const key of Object.keys(current)) {
39
+ if (key === "parent") continue;
40
+ const value = current[key];
41
+ if (!value) continue;
42
+ if (Array.isArray(value)) {
43
+ for (const element of value) if (isNode(element)) stack.push(element);
44
+ } else if (isNode(value)) stack.push(value);
45
+ }
46
+ }
47
+ return false;
48
+ };
49
+ /**
50
+ * Check if a function returns JSX
51
+ * @param {FunctionLikeNode} node
52
+ */
53
+ const functionReturnsJsx = (node) => {
54
+ if (node.type === "ArrowFunctionExpression" && node.body && node.body.type !== "BlockStatement") return expressionContainsJsx(node.body);
55
+ const body = node.body;
56
+ if (!body || body.type !== "BlockStatement") return false;
57
+ const stack = [body];
58
+ while (stack.length > 0) {
59
+ const current = stack.pop();
60
+ if (!current || !isNode(current)) continue;
61
+ if (current.type === "ReturnStatement") {
62
+ const argument = current.argument;
63
+ if (argument && expressionContainsJsx(argument)) return true;
64
+ }
65
+ if (FUNCTION_NODE_TYPES.has(current.type) && current !== body) continue;
66
+ for (const key of Object.keys(current)) {
67
+ if (key === "parent") continue;
68
+ const value = current[key];
69
+ if (!value) continue;
70
+ if (Array.isArray(value)) {
71
+ for (const element of value) if (isNode(element)) stack.push(element);
72
+ } else if (isNode(value)) stack.push(value);
73
+ }
74
+ }
75
+ return false;
76
+ };
77
+ const rule = defineRule({
78
+ meta: {
79
+ type: "problem",
80
+ docs: {
81
+ description: "Enforce consistent props parameter naming and disallow destructuring in component parameters.",
82
+ recommended: false
83
+ },
84
+ schema: []
85
+ },
86
+ createOnce(context) {
87
+ /**
88
+ * @param {FunctionLikeNode} node
89
+ */
90
+ const checkFunction = (node) => {
91
+ if (!functionReturnsJsx(node)) return;
92
+ const params = node.params;
93
+ if (!params || params.length === 0) return;
94
+ const firstParam = params[0];
95
+ if (!firstParam || !isNode(firstParam)) return;
96
+ if (firstParam.type === "ObjectPattern" || firstParam.type === "ArrayPattern") {
97
+ context.report({
98
+ node: firstParam,
99
+ message: "Props should not be destructured in the component parameter. Use 'props' instead and destructure inside the component body."
100
+ });
101
+ return;
102
+ }
103
+ if (firstParam.type === "Identifier") {
104
+ if (firstParam.name !== "props") context.report({
105
+ node: firstParam,
106
+ message: `Props parameter should be named 'props', not '${firstParam.name}'.`
107
+ });
108
+ }
109
+ };
110
+ return {
111
+ FunctionDeclaration(node) {
112
+ if (isFunctionLike(node)) checkFunction(node);
113
+ },
114
+ FunctionExpression(node) {
115
+ if (isFunctionLike(node)) checkFunction(node);
116
+ },
117
+ ArrowFunctionExpression(node) {
118
+ if (isFunctionLike(node)) checkFunction(node);
119
+ }
120
+ };
121
+ }
122
+ });
123
+ const prettyPropsRule = rule;
124
+
125
+ //#endregion
126
+ export { prettyPropsRule };
127
+ //# sourceMappingURL=pretty-props.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretty-props.mjs","names":[],"sources":["../../src/oxlint-plugins/pretty-props.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.Expression} ESTExpression\n * @typedef {import(\"oxlint\").ESTree.Function | import(\"oxlint\").ESTree.ArrowFunctionExpression} FunctionLikeNode\n */\n\nconst JSX_NODE_TYPES = new Set([\"JSXElement\", \"JSXFragment\"]);\nconst FUNCTION_NODE_TYPES = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {unknown} node\n * @returns {node is FunctionLikeNode}\n */\nconst isFunctionLike = (node) => isNode(node) && FUNCTION_NODE_TYPES.has(node.type);\n\n/**\n * Check if an expression contains JSX\n * @param {ESTExpression | null | undefined} root\n */\nconst expressionContainsJsx = (root) => {\n if (!root || !isNode(root)) return false;\n\n const stack = [root];\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (JSX_NODE_TYPES.has(current.type)) {\n return true;\n }\n\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== root) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\n/**\n * Check if a function returns JSX\n * @param {FunctionLikeNode} node\n */\nconst functionReturnsJsx = (node) => {\n // Check arrow functions with expression body\n if (node.type === \"ArrowFunctionExpression\" && node.body && node.body.type !== \"BlockStatement\") {\n return expressionContainsJsx(node.body);\n }\n\n // Check for return statements in function body\n const body = node.body;\n if (!body || body.type !== \"BlockStatement\") return false;\n\n const stack = [body];\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || !isNode(current)) continue;\n\n if (current.type === \"ReturnStatement\") {\n const argument = current.argument;\n if (argument && expressionContainsJsx(argument)) {\n return true;\n }\n }\n\n // Don't traverse into nested functions\n if (FUNCTION_NODE_TYPES.has(current.type) && current !== body) {\n continue;\n }\n\n for (const key of Object.keys(current)) {\n if (key === \"parent\") continue;\n\n const value = current[key];\n if (!value) continue;\n\n if (Array.isArray(value)) {\n for (const element of value) {\n if (isNode(element)) {\n stack.push(element);\n }\n }\n } else if (isNode(value)) {\n stack.push(value);\n }\n }\n }\n\n return false;\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Enforce consistent props parameter naming and disallow destructuring in component parameters.\",\n recommended: false,\n },\n schema: [],\n },\n\n createOnce(context) {\n /**\n * @param {FunctionLikeNode} node\n */\n const checkFunction = (node) => {\n // Only check functions that return JSX (React components)\n if (!functionReturnsJsx(node)) {\n return;\n }\n\n const params = node.params;\n if (!params || params.length === 0) {\n return;\n }\n\n const firstParam = params[0];\n if (!firstParam || !isNode(firstParam)) {\n return;\n }\n\n // Check if the first parameter is destructured\n if (firstParam.type === \"ObjectPattern\" || firstParam.type === \"ArrayPattern\") {\n context.report({\n node: firstParam,\n message:\n \"Props should not be destructured in the component parameter. Use 'props' instead and destructure inside the component body.\",\n });\n return;\n }\n\n // Check if the first parameter is an Identifier and is named 'props'\n if (firstParam.type === \"Identifier\") {\n if (firstParam.name !== \"props\") {\n context.report({\n node: firstParam,\n message: `Props parameter should be named 'props', not '${firstParam.name}'.`,\n });\n }\n }\n };\n\n return /** @type {import(\"oxlint\").VisitorWithHooks} */ ({\n FunctionDeclaration(node) {\n if (isFunctionLike(node)) checkFunction(node);\n },\n FunctionExpression(node) {\n if (isFunctionLike(node)) checkFunction(node);\n },\n ArrowFunctionExpression(node) {\n if (isFunctionLike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ACvB,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAE/C,wBAAwB,MAAM;AAC5B,QAAI,eAAe,KAAK,CAAE,eAAc,KAAK;;GAEhD;;CAEJ,CAAC;AAEF,MAAa,kBAAkB"}
package/package.json CHANGED
@@ -86,11 +86,11 @@
86
86
  "@types/node": "25.0.1",
87
87
  "@types/react": "19.2.7",
88
88
  "react": "19.2.3",
89
- "tsdown": "0.17.2",
89
+ "tsdown": "0.18.2",
90
90
  "typescript": "5.9.3",
91
91
  "vitest": "4.0.15"
92
92
  },
93
- "version": "0.0.55",
93
+ "version": "0.0.57",
94
94
  "scripts": {
95
95
  "dev": "tsdown --watch",
96
96
  "build": "tsc --noEmit && tsdown",