Skip to content

Conversation

mikededo
Copy link
Contributor

@mikededo mikededo commented Nov 15, 2024

Adds a new Svelte 5 specific rule that ensure special elements are used with
svelte: prefix. This rule will help on migrating from Svelte 4, as such
elements were supported without the prefix in Svelte 4.

Adds a new rule that recommends not using raw special elements and fixes to
using the svelte: prefix. Raw special elements are deprecated from v5 on.

Closes #913

Copy link

changeset-bot bot commented Nov 15, 2024

🦋 Changeset detected

Latest commit: b0ee149

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

@mikededo
Copy link
Contributor Author

Hey @ota-meshi, would it be possible to have this rule have different test outputs for each svelte version? As fixes only apply to Svelte 5

@ota-meshi ota-meshi force-pushed the feat/add-no-invalid-html-elements branch from b95c268 to 71abe97 Compare November 27, 2024 07:42
@ota-meshi
Copy link
Member

You can exclude tests for each package version you are testing by placing a _requirements.json in your test fixtures directory and listing the versions your tests require.
However, I don't think you need to do this if your tests pass.

@mikededo
Copy link
Contributor Author

The rule should only be tested in Svelte 5, meaning tests for earlier versions should not produce errors related to Svelte 5 behavior.

@mikededo mikededo force-pushed the feat/add-no-invalid-html-elements branch from 851cbef to 0ef42f3 Compare November 27, 2024 10:47
@mikededo mikededo requested a review from ota-meshi November 27, 2024 10:59
@mikededo mikededo force-pushed the feat/add-no-invalid-html-elements branch from a624263 to bc20978 Compare November 27, 2024 11:02
@mikededo mikededo force-pushed the feat/add-no-invalid-html-elements branch from a77b03e to 1be1e99 Compare November 27, 2024 11:08
@ota-meshi ota-meshi changed the title feat: add rule no-invalid-html-elements feat: add rule no-deprecated-raw-special-elements Nov 27, 2024
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 5da98c9 into sveltejs:main Nov 27, 2024
20 checks passed
ota-meshi pushed a commit that referenced this pull request Nov 28, 2024
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases ## eslint-plugin-svelte@3.0.0-next.1 ### Minor Changes - [#918](#918) [`5da98c9`](5da98c9) Thanks [@mikededo](https://github.com/mikededo)! - Added new `no-deprecated-raw-special-elements` rule - [#836](#836) [`3fa90aa`](3fa90aa) Thanks [@renovate](https://github.com/apps/renovate)! - feat: support for typescript-eslint v8 to `svelte/indent` rule Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@baseballyama
Copy link
Member

@mikededo

The rule is named "no-deprecated-raw-special-elements" but where is it stated that these elements are actually "deprecated"? For example, using <head> in a Svelte component is almost certainly incorrect even in Svelte 4. I believe this rule remains valid in Svelte4 also.

@mikededo
Copy link
Contributor Author

@baseballyama would it make more sense to replace the deprecated for invalid?

@baseballyama
Copy link
Member

@mikededo

Whether it’s invalid or not depends on how users use it (although in almost all cases, it would indeed be invalid😅). A name like no-raw-special-elements might be more appropriate. Additionally, while the documentation states that this is specific to Svelte 5, I believe this rule could also be applied to Svelte 3 and 4.

@mikededo
Copy link
Contributor Author

@baseballyama True. It was not valid in previous versions but contrary to Svelte 5, the elements did work.

I can work on updating it.

@baseballyama
Copy link
Member

Thank you so much!

@mikededo
Copy link
Contributor Author

@baseballyama fixed in #1015!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants