UNPKG

@transferwise/eslint-plugin

Version:
44 lines (37 loc) 985 B
/** * @fileoverview Ensures forms have a method attribute * @author conorcussell */ //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { docs: { description: 'Ensures forms have a method attribute', category: 'HTML', recommended: false, }, fixable: null, schema: [], }, create(context) { return { JSXOpeningElement(node) { const nodeType = node.name.name; if (nodeType !== 'form') { return; } const methodAttribute = node.attributes.find( (attribute) => attribute.name.name === 'method', ); if (!methodAttribute || !methodAttribute.value) { context.report({ node, message: '<form> elements must have a method attribute', }); } }, }; }, };