UNPKG

react-scripts

Version:
38 lines (28 loc) 789 B
/** * @fileoverview Enforce html element has lang prop. * @author Ethan Cohen */ // ---------------------------------------------------------------------------- // Rule Definition // ---------------------------------------------------------------------------- import { elementType, getProp, getPropValue } from 'jsx-ast-utils'; const errorMessage = '<html> elements must have the lang prop.'; module.exports = context => ({ JSXOpeningElement: node => { const type = elementType(node); if (type && type !== 'html') { return; } const lang = getPropValue(getProp(node.attributes, 'lang')); if (lang) { return; } context.report({ node, message: errorMessage, }); }, }); module.exports.schema = [ { type: 'object' }, ];