UNPKG

ember-introjs

Version:
43 lines (34 loc) 1.15 kB
'use strict'; const ember = require('../utils/ember'); //------------------------------------------------------------------------------ // Ember Data - Be explicit with Ember data attribute types //------------------------------------------------------------------------------ module.exports = { meta: { docs: { description: 'Prevents usage of empty attributes in ember data models', category: 'Best Practices', recommended: false }, fixable: null, // or "code" or "whitespace" }, create(context) { const message = 'Supply proper attribute type'; const filePath = context.getFilename(); const report = function (node) { context.report(node, message); }; return { CallExpression(node) { if (!ember.isDSModel(node, filePath)) return; const allProperties = ember.getModuleProperties(node); const isDSAttr = allProperties.filter(property => ember.isModule(property.value, 'attr', 'DS')); isDSAttr.forEach((attr) => { if (!attr.value.arguments.length) { report(attr.value); } }); }, }; } };