eslint-plugin-gamut
Version:
Shared eslint plugin for Gamut applications
27 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkArrowFuncBodyTypesAndReturnThemeVars = exports.isNamedVariableTheme = void 0;
const utils_1 = require("@typescript-eslint/utils");
const isNamedVariableTheme = (arrowExpression) => {
const argObject = arrowExpression.params[0];
if (argObject?.type !== utils_1.AST_NODE_TYPES.ObjectPattern)
return false;
const argumentVariable = argObject.properties[0].value;
if (argumentVariable?.type !== utils_1.AST_NODE_TYPES.Identifier)
return false;
const namedArgumentVariable = argumentVariable.name;
return namedArgumentVariable === 'theme';
};
exports.isNamedVariableTheme = isNamedVariableTheme;
const checkArrowFuncBodyTypesAndReturnThemeVars = (arrowFuncExpression) => {
if (arrowFuncExpression.body.type !== utils_1.AST_NODE_TYPES.MemberExpression ||
arrowFuncExpression.body.object.type !== utils_1.AST_NODE_TYPES.MemberExpression ||
arrowFuncExpression.body.property.type !== utils_1.AST_NODE_TYPES.Identifier ||
arrowFuncExpression.body.object.property.type !== utils_1.AST_NODE_TYPES.Identifier)
return false;
const themeValueKey = arrowFuncExpression.body.property.name;
const themeCategory = arrowFuncExpression.body.object.property.name;
return { themeValueKey, themeCategory };
};
exports.checkArrowFuncBodyTypesAndReturnThemeVars = checkArrowFuncBodyTypesAndReturnThemeVars;
//# sourceMappingURL=utils.js.map