From 6f1cc067d25484112a384eabd3fd8d93965b0dfa Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 4 Jun 2023 21:30:43 +0900 Subject: [PATCH 1/9] implement rule --- README.md | 1 + docs/rules.md | 9 +- docs/rules/no-restricted-html-elements.md | 102 ++++++++++++++++++ src/rules/no-restricted-html-elements.ts | 68 ++++++++++++ src/utils/rules.ts | 2 + .../src/rules/no-restricted-html-elements.ts | 16 +++ 6 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 docs/rules/no-restricted-html-elements.md create mode 100644 src/rules/no-restricted-html-elements.ts create mode 100644 tests/src/rules/no-restricted-html-elements.ts diff --git a/README.md b/README.md index a5661af1c..c1afaddf7 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,7 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | Rule ID | Description | | |:--------|:------------|:---| | [svelte/no-inner-declarations](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: | +| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | (no description) | | | [svelte/no-trailing-spaces](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental diff --git a/docs/rules.md b/docs/rules.md index ef85cb467..d9d1b4a3b 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -92,10 +92,11 @@ These rules relate to style guidelines, and are therefore quite subjective: These rules extend the rules provided by ESLint itself, or other plugins to work well in Svelte: -| Rule ID | Description | | -| :--------------------------------------------------------------- | :------------------------------------------------------------ | :------- | -| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | -| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | +| Rule ID | Description | | +| :--------------------------------------------------------------------------- | :------------------------------------------------------------ | :------- | +| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | +| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | (no description) | | +| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental diff --git a/docs/rules/no-restricted-html-elements.md b/docs/rules/no-restricted-html-elements.md new file mode 100644 index 000000000..934a6619b --- /dev/null +++ b/docs/rules/no-restricted-html-elements.md @@ -0,0 +1,102 @@ +--- +pageClass: "rule-details" +sidebarDepth: 0 +title: "svelte/no-restricted-html-elements" +description: "" +--- + +# svelte/no-restricted-html-elements + +> This rule reports to usage of resticted HTML elements. + +- :exclamation: **_This rule has not been released yet._** + +## :book: Rule Details + +This rule reports to usage of resticted HTML elements. + + + + + +```svelte + + + +
+

Hi!

+
+ + +

foo

+ +
+

bar

+
+``` + +
+ +--- + + + + + +```svelte + + + +
+

Hi!

+
+ + +foo + +
+ bar +
+``` + +
+ +## :wrench: Options + +This rule takes a list of strings, where each string is an HTML element name to be restricted: + +```json +{ + "svelte/no-restricted-html-elements": [ + "error", + ["h1", "h2", "h3", "h4", "h5", "h6"] + ] +} +``` + +Alternatively, the rule also accepts objects. + +```json +{ + "svelte/no-restricted-html-elements": [ + "error", + { + "elements": ["h1", "h2", "h3", "h4", "h5", "h6"], + "message": "Prefer use of our custom component" + }, + { + "elements": ["marquee"], + "message": "Do not use deprecated HTML tags" + } + ] +} +``` + +## :mag: Implementation + +- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/src/rules/no-restricted-html-elements.ts) +- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/tests/src/rules/no-restricted-html-elements.ts) diff --git a/src/rules/no-restricted-html-elements.ts b/src/rules/no-restricted-html-elements.ts new file mode 100644 index 000000000..acae49fdb --- /dev/null +++ b/src/rules/no-restricted-html-elements.ts @@ -0,0 +1,68 @@ +import { createRule } from "../utils" + +export default createRule("no-restricted-html-elements", { + meta: { + docs: { + description: "disallow specific HTML elements", + category: "Extension Rules", + recommended: false, + }, + schema: { + type: "array", + items: { + oneOf: [ + { + type: "array", + items: { + type: ["string"], + }, + uniqueItems: true, + minItems: 1, + }, + { + type: "object", + properties: { + elements: { + type: "array", + items: { + type: ["string"], + }, + uniqueItems: true, + minItems: 1, + }, + message: { type: "string", minLength: 1 }, + }, + additionalProperties: false, + }, + ], + }, + uniqueItems: true, + minItems: 0, + }, + messages: {}, + type: "suggestion", + }, + create(context) { + return { + SvelteElement(node) { + if (node.kind !== "html") return + const { name } = node + if (name.type !== "SvelteName") return + for (const option of context.options) { + const message = + option.message || + `Unexpected use of forbidden HTML element ${name.name}.` + const elements = option.elements || option + for (const element of elements) { + if (element === name.name) { + context.report({ + message, + node: node.startTag, + }) + } + } + } + }, + } + }, +}) diff --git a/src/utils/rules.ts b/src/utils/rules.ts index 7dac11750..3e4141f65 100644 --- a/src/utils/rules.ts +++ b/src/utils/rules.ts @@ -34,6 +34,7 @@ import noObjectInTextMustaches from "../rules/no-object-in-text-mustaches" import noReactiveFunctions from "../rules/no-reactive-functions" import noReactiveLiterals from "../rules/no-reactive-literals" import noReactiveReassign from "../rules/no-reactive-reassign" +import noRestrictedHtmlElements from "../rules/no-restricted-html-elements" import noShorthandStylePropertyOverrides from "../rules/no-shorthand-style-property-overrides" import noSpacesAroundEqualSignsInAttribute from "../rules/no-spaces-around-equal-signs-in-attribute" import noStoreAsync from "../rules/no-store-async" @@ -93,6 +94,7 @@ export const rules = [ noReactiveFunctions, noReactiveLiterals, noReactiveReassign, + noRestrictedHtmlElements, noShorthandStylePropertyOverrides, noSpacesAroundEqualSignsInAttribute, noStoreAsync, diff --git a/tests/src/rules/no-restricted-html-elements.ts b/tests/src/rules/no-restricted-html-elements.ts new file mode 100644 index 000000000..d27517d22 --- /dev/null +++ b/tests/src/rules/no-restricted-html-elements.ts @@ -0,0 +1,16 @@ +import { RuleTester } from "eslint" +import rule from "../../../src/rules/no-restricted-html-elements" +import { loadTestCases } from "../../utils/utils" + +const tester = new RuleTester({ + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + }, +}) + +tester.run( + "no-restricted-html-elements", + rule as any, + loadTestCases("no-restricted-html-elements"), +) From 966237c34d2dd829f996a979326a5c309fc86ee0 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 4 Jun 2023 21:40:02 +0900 Subject: [PATCH 2/9] add test --- .../invalid/array-config.json | 3 ++ .../invalid/array-errors.yaml | 24 ++++++++++ .../invalid/array-input.svelte | 6 +++ .../invalid/object-config.json | 12 +++++ .../invalid/object-errors.yaml | 48 +++++++++++++++++++ .../invalid/object-input.svelte | 28 +++++++++++ .../valid/array-config.json | 3 ++ .../valid/array-input.svelte | 23 +++++++++ .../valid/object-config.json | 12 +++++ .../valid/object-input.svelte | 23 +++++++++ 10 files changed, 182 insertions(+) create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/array-errors.yaml create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/array-input.svelte create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/object-config.json create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/object-errors.yaml create mode 100644 tests/fixtures/rules/no-restricted-html-elements/invalid/object-input.svelte create mode 100644 tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json create mode 100644 tests/fixtures/rules/no-restricted-html-elements/valid/array-input.svelte create mode 100644 tests/fixtures/rules/no-restricted-html-elements/valid/object-config.json create mode 100644 tests/fixtures/rules/no-restricted-html-elements/valid/object-input.svelte diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json new file mode 100644 index 000000000..6a90b2b2b --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json @@ -0,0 +1,3 @@ +{ + "options": [["h1", "h2", "h3", "h4", "h5", "h6"]] +} diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/array-errors.yaml b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-errors.yaml new file mode 100644 index 000000000..4242fd1f1 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-errors.yaml @@ -0,0 +1,24 @@ +- message: Unexpected use of forbidden HTML element h1. + line: 1 + column: 1 + suggestions: null +- message: Unexpected use of forbidden HTML element h2. + line: 2 + column: 1 + suggestions: null +- message: Unexpected use of forbidden HTML element h3. + line: 3 + column: 1 + suggestions: null +- message: Unexpected use of forbidden HTML element h4. + line: 4 + column: 1 + suggestions: null +- message: Unexpected use of forbidden HTML element h5. + line: 5 + column: 1 + suggestions: null +- message: Unexpected use of forbidden HTML element h6. + line: 6 + column: 1 + suggestions: null diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/array-input.svelte b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-input.svelte new file mode 100644 index 000000000..2caff83b1 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-input.svelte @@ -0,0 +1,6 @@ +

Main Title - H1

+

Subtitle - H2

+

Subsection Title - H3

+

Sub-Subsection Title - H4

+
Minor Title - H5
+
Minor Subtitle - H6
diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/object-config.json b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-config.json new file mode 100644 index 000000000..9f76c45b7 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-config.json @@ -0,0 +1,12 @@ +{ + "options": [ + { + "elements": ["h1", "h2", "h3", "h4", "h5", "h6"], + "message": "Prefer use of our custom component" + }, + { + "elements": ["marquee"], + "message": "Do not use deprecated HTML tags" + } + ] +} diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/object-errors.yaml b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-errors.yaml new file mode 100644 index 000000000..418419380 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-errors.yaml @@ -0,0 +1,48 @@ +- message: Prefer use of our custom component + line: 1 + column: 1 + suggestions: null +- message: Prefer use of our custom component + line: 2 + column: 1 + suggestions: null +- message: Prefer use of our custom component + line: 3 + column: 1 + suggestions: null +- message: Prefer use of our custom component + line: 4 + column: 1 + suggestions: null +- message: Prefer use of our custom component + line: 5 + column: 1 + suggestions: null +- message: Prefer use of our custom component + line: 6 + column: 1 + suggestions: null +- message: Do not use deprecated HTML tags + line: 8 + column: 1 + suggestions: null +- message: Do not use deprecated HTML tags + line: 10 + column: 1 + suggestions: null +- message: Do not use deprecated HTML tags + line: 12 + column: 1 + suggestions: null +- message: Do not use deprecated HTML tags + line: 19 + column: 3 + suggestions: null +- message: Do not use deprecated HTML tags + line: 23 + column: 3 + suggestions: null +- message: Prefer use of our custom component + line: 27 + column: 3 + suggestions: null diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/object-input.svelte b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-input.svelte new file mode 100644 index 000000000..414fc87b0 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/object-input.svelte @@ -0,0 +1,28 @@ +

Main Title - H1

+

Subtitle - H2

+

Subsection Title - H3

+

Sub-Subsection Title - H4

+
Minor Title - H5
+
Minor Subtitle - H6
+ +This text will scroll from right to left + +This text will scroll from bottom to top + + + This text will bounce + + +
+ This text will scroll from right to left +
+ +
+
Minor Subtitle - H6
+
diff --git a/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json b/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json new file mode 100644 index 000000000..6a90b2b2b --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json @@ -0,0 +1,3 @@ +{ + "options": [["h1", "h2", "h3", "h4", "h5", "h6"]] +} diff --git a/tests/fixtures/rules/no-restricted-html-elements/valid/array-input.svelte b/tests/fixtures/rules/no-restricted-html-elements/valid/array-input.svelte new file mode 100644 index 000000000..29d43d502 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/valid/array-input.svelte @@ -0,0 +1,23 @@ +
This is a title
+
This is a subtitle
+

This is a paragraph. Some sample text goes here.

+
    +
  • This is
  • +
  • a list item
  • +
+ + + + + + + + + +
Table Cell 1Table Cell 2
Table Cell 3Table Cell 4
+This is a hyperlink to example.com +
+
+
+ +
diff --git a/tests/fixtures/rules/no-restricted-html-elements/valid/object-config.json b/tests/fixtures/rules/no-restricted-html-elements/valid/object-config.json new file mode 100644 index 000000000..9f76c45b7 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/valid/object-config.json @@ -0,0 +1,12 @@ +{ + "options": [ + { + "elements": ["h1", "h2", "h3", "h4", "h5", "h6"], + "message": "Prefer use of our custom component" + }, + { + "elements": ["marquee"], + "message": "Do not use deprecated HTML tags" + } + ] +} diff --git a/tests/fixtures/rules/no-restricted-html-elements/valid/object-input.svelte b/tests/fixtures/rules/no-restricted-html-elements/valid/object-input.svelte new file mode 100644 index 000000000..29d43d502 --- /dev/null +++ b/tests/fixtures/rules/no-restricted-html-elements/valid/object-input.svelte @@ -0,0 +1,23 @@ +
This is a title
+
This is a subtitle
+

This is a paragraph. Some sample text goes here.

+
    +
  • This is
  • +
  • a list item
  • +
+ + + + + + + + + +
Table Cell 1Table Cell 2
Table Cell 3Table Cell 4
+This is a hyperlink to example.com +
+
+
+ +
From 65c1381df6834f9d7c30a44e36ce9475af526201 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 4 Jun 2023 21:41:43 +0900 Subject: [PATCH 3/9] add changeset --- .changeset/wise-flies-lay.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wise-flies-lay.md diff --git a/.changeset/wise-flies-lay.md b/.changeset/wise-flies-lay.md new file mode 100644 index 000000000..a5360b7b7 --- /dev/null +++ b/.changeset/wise-flies-lay.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-svelte": minor +--- + +feat: add `no-restricted-html-elements` rule From a8d4bbbd2ce924d9018522d34fc74812bc4c5737 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 4 Jun 2023 21:45:06 +0900 Subject: [PATCH 4/9] update config --- src/rules/no-restricted-html-elements.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rules/no-restricted-html-elements.ts b/src/rules/no-restricted-html-elements.ts index acae49fdb..07586834c 100644 --- a/src/rules/no-restricted-html-elements.ts +++ b/src/rules/no-restricted-html-elements.ts @@ -33,11 +33,12 @@ export default createRule("no-restricted-html-elements", { message: { type: "string", minLength: 1 }, }, additionalProperties: false, + minItems: 1, }, ], }, uniqueItems: true, - minItems: 0, + minItems: 1, }, messages: {}, type: "suggestion", From 56b8cc995c350ab99def6207c7faeca8a05e003d Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 4 Jun 2023 21:49:10 +0900 Subject: [PATCH 5/9] run update command --- README.md | 2 +- docs/rules.md | 2 +- docs/rules/no-restricted-html-elements.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c1afaddf7..9da2874ac 100644 --- a/README.md +++ b/README.md @@ -382,7 +382,7 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | Rule ID | Description | | |:--------|:------------|:---| | [svelte/no-inner-declarations](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: | -| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | (no description) | | +| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | disallow specific HTML elements | | | [svelte/no-trailing-spaces](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental diff --git a/docs/rules.md b/docs/rules.md index d9d1b4a3b..91906dc1f 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -95,7 +95,7 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | Rule ID | Description | | | :--------------------------------------------------------------------------- | :------------------------------------------------------------ | :------- | | [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | -| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | (no description) | | +| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | disallow specific HTML elements | | | [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental diff --git a/docs/rules/no-restricted-html-elements.md b/docs/rules/no-restricted-html-elements.md index 934a6619b..ad80f70c3 100644 --- a/docs/rules/no-restricted-html-elements.md +++ b/docs/rules/no-restricted-html-elements.md @@ -2,12 +2,12 @@ pageClass: "rule-details" sidebarDepth: 0 title: "svelte/no-restricted-html-elements" -description: "" +description: "disallow specific HTML elements" --- # svelte/no-restricted-html-elements -> This rule reports to usage of resticted HTML elements. +> disallow specific HTML elements - :exclamation: **_This rule has not been released yet._** From cf80a29d0e12ff5c98fe0504eebe9be5e329dee0 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 10 Jun 2023 11:53:00 +0900 Subject: [PATCH 6/9] flatten config --- docs/rules/no-restricted-html-elements.md | 11 ++++++++--- src/rules/no-restricted-html-elements.ts | 11 ++--------- .../invalid/array-config.json | 2 +- .../valid/array-config.json | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/rules/no-restricted-html-elements.md b/docs/rules/no-restricted-html-elements.md index ad80f70c3..04a789e20 100644 --- a/docs/rules/no-restricted-html-elements.md +++ b/docs/rules/no-restricted-html-elements.md @@ -21,7 +21,7 @@ This rule reports to usage of resticted HTML elements. ```svelte @@ -73,7 +73,12 @@ This rule takes a list of strings, where each string is an HTML element name to { "svelte/no-restricted-html-elements": [ "error", - ["h1", "h2", "h3", "h4", "h5", "h6"] + "h1", + "h2", + "h3", + "h4", + "h5", + "h6" ] } ``` @@ -85,7 +90,7 @@ Alternatively, the rule also accepts objects. "svelte/no-restricted-html-elements": [ "error", { - "elements": ["h1", "h2", "h3", "h4", "h5", "h6"], + "elements": "h1", "h2", "h3", "h4", "h5", "h6", "message": "Prefer use of our custom component" }, { diff --git a/src/rules/no-restricted-html-elements.ts b/src/rules/no-restricted-html-elements.ts index 07586834c..272854f64 100644 --- a/src/rules/no-restricted-html-elements.ts +++ b/src/rules/no-restricted-html-elements.ts @@ -11,14 +11,7 @@ export default createRule("no-restricted-html-elements", { type: "array", items: { oneOf: [ - { - type: "array", - items: { - type: ["string"], - }, - uniqueItems: true, - minItems: 1, - }, + { type: "string" }, { type: "object", properties: { @@ -53,7 +46,7 @@ export default createRule("no-restricted-html-elements", { const message = option.message || `Unexpected use of forbidden HTML element ${name.name}.` - const elements = option.elements || option + const elements = option.elements || [option] for (const element of elements) { if (element === name.name) { context.report({ diff --git a/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json index 6a90b2b2b..e5e624770 100644 --- a/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json +++ b/tests/fixtures/rules/no-restricted-html-elements/invalid/array-config.json @@ -1,3 +1,3 @@ { - "options": [["h1", "h2", "h3", "h4", "h5", "h6"]] + "options": ["h1", "h2", "h3", "h4", "h5", "h6"] } diff --git a/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json b/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json index 6a90b2b2b..e5e624770 100644 --- a/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json +++ b/tests/fixtures/rules/no-restricted-html-elements/valid/array-config.json @@ -1,3 +1,3 @@ { - "options": [["h1", "h2", "h3", "h4", "h5", "h6"]] + "options": ["h1", "h2", "h3", "h4", "h5", "h6"] } From 12f38f7a335ac2abe3ebccae68238372ffab3b61 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 10 Jun 2023 12:04:47 +0900 Subject: [PATCH 7/9] change category --- src/rules/no-restricted-html-elements.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rules/no-restricted-html-elements.ts b/src/rules/no-restricted-html-elements.ts index 272854f64..979333012 100644 --- a/src/rules/no-restricted-html-elements.ts +++ b/src/rules/no-restricted-html-elements.ts @@ -4,8 +4,9 @@ export default createRule("no-restricted-html-elements", { meta: { docs: { description: "disallow specific HTML elements", - category: "Extension Rules", + category: "Stylistic Issues", recommended: false, + conflictWithPrettier: false, }, schema: { type: "array", From 721a53282689953fb0d709a0e853634b01afd302 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 10 Jun 2023 12:13:55 +0900 Subject: [PATCH 8/9] run update cmd --- README.md | 2 +- docs/rules.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9da2874ac..f512560a2 100644 --- a/README.md +++ b/README.md @@ -367,6 +367,7 @@ These rules relate to style guidelines, and are therefore quite subjective: | [svelte/max-attributes-per-line](https://sveltejs.github.io/eslint-plugin-svelte/rules/max-attributes-per-line/) | enforce the maximum number of attributes per line | :wrench: | | [svelte/mustache-spacing](https://sveltejs.github.io/eslint-plugin-svelte/rules/mustache-spacing/) | enforce unified spacing in mustache | :wrench: | | [svelte/no-extra-reactive-curlies](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-extra-reactive-curlies/) | disallow wrapping single reactive statements in curly braces | :bulb: | +| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | disallow specific HTML elements | | | [svelte/no-spaces-around-equal-signs-in-attribute](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-spaces-around-equal-signs-in-attribute/) | disallow spaces around equal signs in attribute | :wrench: | | [svelte/prefer-class-directive](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-class-directive/) | require class directives instead of ternary expressions | :wrench: | | [svelte/prefer-style-directive](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-style-directive/) | require style directives instead of style attribute | :wrench: | @@ -382,7 +383,6 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | Rule ID | Description | | |:--------|:------------|:---| | [svelte/no-inner-declarations](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: | -| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | disallow specific HTML elements | | | [svelte/no-trailing-spaces](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental diff --git a/docs/rules.md b/docs/rules.md index 91906dc1f..644183301 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -80,6 +80,7 @@ These rules relate to style guidelines, and are therefore quite subjective: | [svelte/max-attributes-per-line](./rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: | | [svelte/mustache-spacing](./rules/mustache-spacing.md) | enforce unified spacing in mustache | :wrench: | | [svelte/no-extra-reactive-curlies](./rules/no-extra-reactive-curlies.md) | disallow wrapping single reactive statements in curly braces | :bulb: | +| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | disallow specific HTML elements | | | [svelte/no-spaces-around-equal-signs-in-attribute](./rules/no-spaces-around-equal-signs-in-attribute.md) | disallow spaces around equal signs in attribute | :wrench: | | [svelte/prefer-class-directive](./rules/prefer-class-directive.md) | require class directives instead of ternary expressions | :wrench: | | [svelte/prefer-style-directive](./rules/prefer-style-directive.md) | require style directives instead of style attribute | :wrench: | @@ -92,11 +93,10 @@ These rules relate to style guidelines, and are therefore quite subjective: These rules extend the rules provided by ESLint itself, or other plugins to work well in Svelte: -| Rule ID | Description | | -| :--------------------------------------------------------------------------- | :------------------------------------------------------------ | :------- | -| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | -| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | disallow specific HTML elements | | -| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | +| Rule ID | Description | | +| :--------------------------------------------------------------- | :------------------------------------------------------------ | :------- | +| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | +| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | ## Experimental From e4a872c9bc9a4e7d713de9ae596964941a08728f Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 10 Jun 2023 12:18:54 +0900 Subject: [PATCH 9/9] commit forgot file --- docs/rules/no-restricted-html-elements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-restricted-html-elements.md b/docs/rules/no-restricted-html-elements.md index 04a789e20..b7cac878b 100644 --- a/docs/rules/no-restricted-html-elements.md +++ b/docs/rules/no-restricted-html-elements.md @@ -90,7 +90,7 @@ Alternatively, the rule also accepts objects. "svelte/no-restricted-html-elements": [ "error", { - "elements": "h1", "h2", "h3", "h4", "h5", "h6", + "elements": ["h1", "h2", "h3", "h4", "h5", "h6"], "message": "Prefer use of our custom component" }, {