UNPKG

eslint-plugin-ng-module-sort

Version:

Sort Angular and NestJS module imports, declarations, exports, controls, etc.

28 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getKnownProperties = exports.getPropertiesOfDecorator = exports.ruleCreator = void 0; const utils_1 = require("@typescript-eslint/utils"); const constants_1 = require("./constants"); exports.ruleCreator = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/ducktordanny/eslint-plugin-ng-module-sort#${name}`); function getPropertiesOfDecorator(node, extras, argIndex = 0) { var _a, _b; const callExp = node === null || node === void 0 ? void 0 : node.expression; const decoratorName = (_a = callExp === null || callExp === void 0 ? void 0 : callExp.callee) === null || _a === void 0 ? void 0 : _a.name; if (![...constants_1.DECORATORS, ...extras].some((dec) => dec === decoratorName)) return; const arg = (_b = callExp === null || callExp === void 0 ? void 0 : callExp.arguments) === null || _b === void 0 ? void 0 : _b[argIndex]; if (!arg || (arg === null || arg === void 0 ? void 0 : arg.type) !== 'ObjectExpression') return; const properties = arg === null || arg === void 0 ? void 0 : arg.properties; return properties; } exports.getPropertiesOfDecorator = getPropertiesOfDecorator; function getKnownProperties(properties, extras) { return properties === null || properties === void 0 ? void 0 : properties.filter((prop) => { var _a; const keyName = (_a = prop.key) === null || _a === void 0 ? void 0 : _a.name; return [...constants_1.MODULE_PROPERTIES, ...extras].some((mProp) => mProp === keyName); }); } exports.getKnownProperties = getKnownProperties; //# sourceMappingURL=utils.js.map