Skip to content
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

feat: add svelte/no-trailing-spaces rule #240

Merged
merged 3 commits into from
Aug 24, 2022
Merged

Conversation

ota-meshi
Copy link
Member

This PR adds svelte/no-trailing-spaces rule that extends no-trailing-spaces rule.
close #233

@changeset-bot
Copy link

changeset-bot bot commented Aug 23, 2022

🦋 Changeset detected

Latest commit: 6e6e173

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 23, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@JounQin
Copy link
Collaborator

JounQin commented Aug 23, 2022

I'm not quite sure to understand why the built-in no-trailing-spaces rules does not work with this?

We should have already marked this following as comments? Then why ignoreComments: true does not work as expected?

<!-- @component
  InlineButton - A button that blends in with paragraph  
  styles, but is interactive.
-->

@ota-meshi
Copy link
Member Author

ota-meshi commented Aug 23, 2022

svelte-eslint-parser does not treat HTML comments as comment tokens. This is done in order to prevent false positives in ESLint's rules for processing comments (prefix behaves on the assumption that it is 2 characters, but there are actually 4 characters in HTML comments). If we treat HTML comments as comment tokens, auto-fix will break your source code.

@JounQin
Copy link
Collaborator

JounQin commented Aug 23, 2022

In eslint-mdx@v1, we are replacing HTML comments into JSX comments with same length of * tokens:

<!-- old -->
<!-- comment -->

<!-- new -->
{/** comment **}

I don't know if it is a good approach, but it works perfect in eslint-mdx@v1

@ota-meshi
Copy link
Member Author

I didn't come up with that hack. It might be worth trying, but it might be difficult as it involves breaking changes.

@JounQin
Copy link
Collaborator

JounQin commented Aug 23, 2022

Can we add some TODO comments to remind us?

@ota-meshi
Copy link
Member Author

It might make more sense to open an issue in the svelte-eslint-parser repository since it's a change in svelte-eslint-parser.

@JounQin
Copy link
Collaborator

JounQin commented Aug 23, 2022

@ota-meshi just raised sveltejs/svelte-eslint-parser#202

@ota-meshi ota-meshi merged commit e56fbdb into main Aug 24, 2022
@ota-meshi ota-meshi deleted the no-trailing-spaces branch August 24, 2022 08:55
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.

no-trailing-spaces "ignoreComments: true" displays error in html comments
2 participants