UNPKG

@raycast/eslint-plugin

Version:

ESLint plugin designed to help Raycast's extensions authors follow best practices

31 lines (30 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createRule = void 0; exports.isActionComponent = isActionComponent; exports.isTextField = isTextField; const utils_1 = require("@typescript-eslint/utils"); exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/raycast/eslint-plugin/blob/main/docs/rules/${name}.md`); function isActionComponent(node) { if (node.type === utils_1.AST_NODE_TYPES.JSXIdentifier) { return node.name === "Action"; } if (node.type === utils_1.AST_NODE_TYPES.JSXMemberExpression) { if (node.object.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.object.name === "Action") { return true; } return (node.object.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.object.name === "ActionPanel" && node.property.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.property.name === "Submenu"); } return false; } function isTextField(node) { return (node.type === utils_1.AST_NODE_TYPES.JSXMemberExpression && node.object.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.object.name === "Form" && node.property.type === utils_1.AST_NODE_TYPES.JSXIdentifier && (node.property.name === "TextField" || node.property.name === "TextArea")); }