From f351692b438c76f02296987a9d96dafaf28732a5 Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Fri, 27 Dec 2024 15:30:18 +0900 Subject: [PATCH 1/4] no-heading-inside-button --- docs/rules/no-heading-inside-button.md | 1 + packages/eslint-plugin/lib/rules/index.js | 2 + .../lib/rules/no-heading-inside-button.js | 45 ++++++++ .../rules/no-heading-inside-button.test.js | 101 ++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 docs/rules/no-heading-inside-button.md create mode 100644 packages/eslint-plugin/lib/rules/no-heading-inside-button.js create mode 100644 packages/eslint-plugin/tests/rules/no-heading-inside-button.test.js diff --git a/docs/rules/no-heading-inside-button.md b/docs/rules/no-heading-inside-button.md new file mode 100644 index 00000000..77d7650c --- /dev/null +++ b/docs/rules/no-heading-inside-button.md @@ -0,0 +1 @@ +# no-heading-inside-button diff --git a/packages/eslint-plugin/lib/rules/index.js b/packages/eslint-plugin/lib/rules/index.js index 03787eae..d54a406f 100644 --- a/packages/eslint-plugin/lib/rules/index.js +++ b/packages/eslint-plugin/lib/rules/index.js @@ -40,6 +40,7 @@ const sortAttrs = require("./sort-attrs"); const preferHttps = require("./prefer-https"); const requireInputLabel = require("./require-input-label"); const requireFormMethod = require("./require-form-method"); +const noHeadingInsideButton = require("./no-heading-inside-button"); module.exports = { "require-lang": requireLang, @@ -78,6 +79,7 @@ module.exports = { "no-trailing-spaces": noTrailingSpaces, "no-restricted-attr-values": noRestrictedAttrValues, "no-script-style-type": noScriptStyleType, + "no-heading-inside-button": noHeadingInsideButton, lowercase: lowercase, "require-open-graph-protocol": requireOpenGraphProtocol, "require-form-method": requireFormMethod, diff --git a/packages/eslint-plugin/lib/rules/no-heading-inside-button.js b/packages/eslint-plugin/lib/rules/no-heading-inside-button.js new file mode 100644 index 00000000..0595acbd --- /dev/null +++ b/packages/eslint-plugin/lib/rules/no-heading-inside-button.js @@ -0,0 +1,45 @@ +/** + * @typedef { import("../types").RuleModule } RuleModule + */ + +const { RULE_CATEGORY } = require("../constants"); +const { findAttr } = require("./utils/node"); +const { createVisitors } = require("./utils/visitors"); +const MESSAGE_IDS = { + UNEXPECTED: "unexpected", +}; + +/** + * @type {RuleModule} + */ +module.exports = { + meta: { + type: "code", + + docs: { + description: "Disallows the use of heading elements inside