@transferwise/eslint-plugin
Version:
TransferWise ESLint plugin
44 lines (37 loc) • 985 B
JavaScript
/**
* @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',
});
}
},
};
},
};