UNPKG

eslint-plugin-ember

Version:
42 lines (38 loc) 1.29 kB
const ERROR_MESSAGE = 'Using `...attributes` with `class` attribute is not allowed. Use `...attributes` alone to allow class merging.'; /** @type {import('eslint').Rule.RuleModule} */ module.exports = { meta: { type: 'suggestion', docs: { description: 'disallow splattributes with class attribute', category: 'Best Practices', recommended: false, url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-splattributes-with-class.md', templateMode: 'both', }, fixable: null, schema: [], messages: {}, originallyFrom: { name: 'ember-template-lint', rule: 'lib/rules/no-splattributes-with-class.js', docs: 'docs/rule/no-splattributes-with-class.md', tests: 'test/unit/rules/no-splattributes-with-class-test.js', }, }, create(context) { return { GlimmerElementNode(node) { const hasSplattributes = node.attributes.some((attr) => attr.name === '...attributes'); const classAttribute = node.attributes.find((attr) => attr.name === 'class'); if (hasSplattributes && classAttribute) { context.report({ node: classAttribute, message: ERROR_MESSAGE, }); } }, }; }, };