ember-template-lint
Version:
Linter for Ember or Handlebars templates.
28 lines (23 loc) • 783 B
JavaScript
;
const Rule = require('./_base');
module.exports = class NoClassBindings extends Rule {
visitor() {
function check(node) {
let isAttrNode = node.type === 'AttrNode';
let specifiedKey = isAttrNode ? node.name : node.key;
let argumentName = isAttrNode ? node.name : `@${node.key}`;
if (argumentName === '@classBinding' || argumentName === '@classNameBindings') {
this.log({
message: `Passing the \`${specifiedKey}\` property as an argument within templates is not allowed.`,
line: node.loc && node.loc.start.line,
column: node.loc && node.loc.start.column,
source: this.sourceForNode(node),
});
}
}
return {
AttrNode: check,
HashPair: check,
};
}
};