Skip to content

feat: add svelte/no-restricted-html-elements rule #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 10, 2023

Conversation

baseballyama
Copy link
Member

close: #436

@changeset-bot
Copy link

changeset-bot bot commented Jun 4, 2023

🦋 Changeset detected

Latest commit: e4a872c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

{
"svelte/no-restricted-html-elements": [
"error",
["h1", "h2", "h3", "h4", "h5", "h6"]
Copy link
Member

@ota-meshi ota-meshi Jun 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer flattening over using nested arrays here.
What do you think about flattening?

  "svelte/no-restricted-html-elements": [
    "error",
    "h1", "h2", "h3", "h4", "h5", "h6"
  ]

( I think your good idea about using an array for the "elements" field. We can use the same message for multiple forbidden elements. )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to update this. I updated!

meta: {
docs: {
description: "disallow specific HTML elements",
category: "Extension Rules",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think the better category for this rule is Stylistic Issues among the categories we currently have, but we may need to create a new category 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I misunderstood the meaning of Extension Rules.
Just now I changed the category.
Should we refactor categories in the next major version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we need to run pnpm run update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refactor categories in the next major version?

We can always make changes if we have ideas for categorization that make it easier for users to understand 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it a bit, but I think Stylistic Issues is fine for now.

"svelte/no-restricted-html-elements": [
"error",
{
"elements": "h1", "h2", "h3", "h4", "h5", "h6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"elements": "h1", "h2", "h3", "h4", "h5", "h6",
"elements": ["h1", "h2", "h3", "h4", "h5", "h6"],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@ota-meshi ota-meshi merged commit 16d6816 into sveltejs:main Jun 10, 2023
@baseballyama baseballyama deleted the feat/436 branch June 10, 2023 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disallow certain HTML elements from being used
2 participants