eslint-plugin-ng-module-sort
Version:
Sort Angular and NestJS module imports, declarations, exports, controls, etc.
26 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ruleCreator = void 0;
exports.getPropertiesOfDecorator = getPropertiesOfDecorator;
exports.getKnownProperties = getKnownProperties;
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) {
const callExp = node?.expression;
const decoratorName = callExp?.callee?.name;
if (![...constants_1.DECORATORS, ...extras].some((dec) => dec === decoratorName))
return;
const arg = callExp?.arguments?.[argIndex];
if (!arg || arg?.type !== 'ObjectExpression')
return;
const properties = arg?.properties;
return properties;
}
function getKnownProperties(properties, extras) {
return properties?.filter((prop) => {
const keyName = prop.key?.name;
return [...constants_1.MODULE_PROPERTIES, ...extras].some((mProp) => mProp === keyName);
});
}
//# sourceMappingURL=utils.js.map