diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b1cbc24c9..eb21dc1d51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,10 +20,12 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [readme] Some grammar fixes ([#3186][] @JJ) * [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper) * [Docs] [`display-name`]: improve examples ([#3189][] @golopot) +* [Refactor] [`no-invalid-html-attribute`]: sort HTML_ELEMENTS and messages ([#3182][] @Primajin) [#3190]: https://github.com/yannickcr/eslint-plugin-react/pull/3190 [#3189]: https://github.com/yannickcr/eslint-plugin-react/pull/3189 [#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186 +[#3182]: https://github.com/yannickcr/eslint-plugin-react/pull/3182 [#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174 [#3169]: https://github.com/yannickcr/eslint-plugin-react/pull/3169 [#3167]: https://github.com/yannickcr/eslint-plugin-react/pull/3167 diff --git a/lib/rules/no-invalid-html-attribute.js b/lib/rules/no-invalid-html-attribute.js index cdba56a66d..274f2586da 100644 --- a/lib/rules/no-invalid-html-attribute.js +++ b/lib/rules/no-invalid-html-attribute.js @@ -70,147 +70,147 @@ const VALID_PAIR_VALUES = new Map([ * @type {Set} */ const HTML_ELEMENTS = new Set([ - 'html', - 'base', - 'head', - 'link', - 'meta', - 'style', - 'title', - 'body', + 'a', + 'abbr', + 'acronym', 'address', + 'applet', + 'area', 'article', 'aside', - 'footer', - 'header', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'main', - 'nav', - 'section', - 'blockquote', - 'dd', - 'div', - 'dl', - 'dt', - 'figcaption', - 'figure', - 'hr', - 'li', - 'ol', - 'p', - 'pre', - 'ul', - 'a', - 'abbr', + 'audio', 'b', + 'base', + 'basefont', 'bdi', 'bdo', + 'bgsound', + 'big', + 'blink', + 'blockquote', + 'body', 'br', + 'button', + 'canvas', + 'caption', + 'center', 'cite', 'code', + 'col', + 'colgroup', + 'content', 'data', + 'datalist', + 'dd', + 'del', + 'details', 'dfn', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', 'em', + 'embed', + 'fieldset', + 'figcaption', + 'figure', + 'font', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hgroup', + 'hr', + 'html', 'i', + 'iframe', + 'image', + 'img', + 'input', + 'ins', 'kbd', + 'keygen', + 'label', + 'legend', + 'li', + 'link', + 'main', + 'map', 'mark', + 'marquee', + 'math', + 'menu', + 'menuitem', + 'meta', + 'meter', + 'nav', + 'nobr', + 'noembed', + 'noframes', + 'noscript', + 'object', + 'ol', + 'optgroup', + 'option', + 'output', + 'p', + 'param', + 'picture', + 'plaintext', + 'portal', + 'pre', + 'progress', 'q', + 'rb', 'rp', 'rt', + 'rtc', 'ruby', 's', 'samp', + 'script', + 'section', + 'select', + 'shadow', + 'slot', 'small', + 'source', + 'spacer', 'span', + 'strike', 'strong', + 'style', 'sub', + 'summary', 'sup', - 'time', - 'u', - 'var', - 'wbr', - 'area', - 'audio', - 'img', - 'map', - 'track', - 'video', - 'embed', - 'iframe', - 'object', - 'param', - 'picture', - 'portal', - 'source', 'svg', - 'math', - 'canvas', - 'noscript', - 'script', - 'del', - 'ins', - 'caption', - 'col', - 'colgroup', 'table', 'tbody', 'td', + 'template', + 'textarea', 'tfoot', 'th', 'thead', + 'time', + 'title', 'tr', - 'button', - 'datalist', - 'fieldset', - 'form', - 'input', - 'label', - 'legend', - 'meter', - 'optgroup', - 'option', - 'output', - 'progress', - 'select', - 'textarea', - 'details', - 'dialog', - 'menu', - 'summary', - 'slot', - 'template', - 'acronym', - 'applet', - 'basefont', - 'bgsound', - 'big', - 'blink', - 'center', - 'content', - 'dir', - 'font', - 'frame', - 'frameset', - 'hgroup', - 'image', - 'keygen', - 'marquee', - 'menuitem', - 'nobr', - 'noembed', - 'noframes', - 'plaintext', - 'rb', - 'rtc', - 'shadow', - 'spacer', - 'strike', + 'track', 'tt', + 'u', + 'ul', + 'var', + 'video', + 'wbr', 'xmp', ]); @@ -222,16 +222,16 @@ const COMPONENT_ATTRIBUTE_MAP = new Map(); COMPONENT_ATTRIBUTE_MAP.set('rel', new Set(['link', 'a', 'area', 'form'])); const messages = { - onlyStrings: '“{{attributeName}}” attribute only supports strings.', - noEmpty: 'An empty “{{attributeName}}” attribute is meaningless.', + emptyIsMeaningless: 'An empty “{{attributeName}}” attribute is meaningless.', neverValid: '“{{reportingValue}}” is never a valid “{{attributeName}}” attribute value.', - notValidFor: '“{{reportingValue}}” is not a valid “{{attributeName}}” attribute value for <{{elementName}}>.', - spaceDelimited: '”{{attributeName}}“ attribute values should be space delimited.', + noEmpty: 'An empty “{{attributeName}}” attribute is meaningless.', noMethod: 'The ”{{attributeName}}“ attribute cannot be a method.', - onlyMeaningfulFor: 'The ”{{attributeName}}“ attribute only has meaning on the tags: {{tagNames}}', - emptyIsMeaningless: 'An empty “{{attributeName}}” attribute is meaningless.', notAlone: '“{{reportingValue}}” must be directly followed by “{{missingValue}}”.', notPaired: '“{{reportingValue}}” can not be directly followed by “{{secondValue}}” without “{{missingValue}}”.', + notValidFor: '“{{reportingValue}}” is not a valid “{{attributeName}}” attribute value for <{{elementName}}>.', + onlyMeaningfulFor: 'The ”{{attributeName}}“ attribute only has meaning on the tags: {{tagNames}}', + onlyStrings: '“{{attributeName}}” attribute only supports strings.', + spaceDelimited: '”{{attributeName}}“ attribute values should be space delimited.', }; function splitIntoRangedParts(node, regex) {