Sha256: 7a9372a9e0e8f4784d7cd5653ea6b7bf70d50c7da7b08bb344996709a8f52744
Contents?: true
Size: 1.33 KB
Versions: 43
Compression:
Stored size: 1.33 KB
Contents
/** * @fileoverview Enforce ES5 or ES6 class for React Components * @author Dan Hamilton */ 'use strict'; const Components = require('../util/Components'); const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ module.exports = { meta: { docs: { description: 'Enforce ES5 or ES6 class for React Components', category: 'Stylistic Issues', recommended: false, url: docsUrl('prefer-es6-class') }, schema: [{ enum: ['always', 'never'] }] }, create: Components.detect((context, components, utils) => { const configuration = context.options[0] || 'always'; return { ObjectExpression: function(node) { if (utils.isES5Component(node) && configuration === 'always') { context.report({ node: node, message: 'Component should use es6 class instead of createClass' }); } }, ClassDeclaration: function(node) { if (utils.isES6Component(node) && configuration === 'never') { context.report({ node: node, message: 'Component should use createClass instead of es6 class' }); } } }; }) };
Version data entries
43 entries across 43 versions & 1 rubygems