eslint-plugin-sonarjs
Version:
SonarJS rules for ESLint
31 lines (30 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.decorate = void 0;
const helpers_1 = require("../helpers");
const meta_1 = require("./meta");
function decorate(rule) {
return (0, helpers_1.interceptReport)({
...rule,
meta: (0, helpers_1.generateMeta)(meta_1.meta, rule.meta),
}, reportExempting(isDecoratedSetterWithAngularInput));
}
exports.decorate = decorate;
function reportExempting(exemptionCondition) {
return (context, reportDescriptor) => {
if ('node' in reportDescriptor) {
const def = reportDescriptor['node'];
if (!exemptionCondition(def)) {
context.report(reportDescriptor);
}
}
};
}
function isDecoratedSetterWithAngularInput(def) {
const { kind, decorators } = def;
return (kind === 'set' &&
decorators !== undefined &&
decorators.some(decorator => decorator.expression.type === 'CallExpression' &&
decorator.expression.callee.type === 'Identifier' &&
decorator.expression.callee.name === 'Input'));
}