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

Add svelte/no-constant-condition rule #613

Open
AlexRMU opened this issue Nov 12, 2023 · 2 comments
Open

Add svelte/no-constant-condition rule #613

AlexRMU opened this issue Nov 12, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@AlexRMU
Copy link

AlexRMU commented Nov 12, 2023

Description

You need to take all the rules from eslint and try to adapt them to the markup.

if (2) { // no-constant-condition
    "foo";
} else if (3) { // no-constant-condition
    "bar";
} else if (3) { // no-constant-condition no-dupe-else-if
    "baz";
}
{#if 2}
    <div>foo</div>
{:else if 3}
    <div>bar</div>
{:else if 3} <!-- svelte/no-dupe-else-if-blocks -->
    <div>baz</div>
{/if}

Perhaps you need to try to convert the markup to (pseudo) regular js and, in addition to the rules of the svelte, apply the rules for js to it (including other plugins and future ts support in the markup).

@AlexRMU AlexRMU added the enhancement New feature or request label Nov 12, 2023
@ota-meshi
Copy link
Member

Thank you for posting this issue.
Since template logic blocks are different from JavaScript, I think we need to create rules like svelte/no-constant-condition separately.
If you think there is a rule we need, please post rule proposal in an new issue.

@ota-meshi
Copy link
Member

ota-meshi commented Nov 13, 2023

Perhaps you need to try to convert the markup to (pseudo) regular js and, in addition to the rules of the svelte, apply the rules for js to it (including other plugins and future ts support in the markup).

If you want to try out the idea of linting from pseudo JavaScript code, please create your own new plugin and try it out, as the mechanism is different from eslint-plugin-svelte.

@ota-meshi ota-meshi changed the title Copy the rules from eslint for markup Add svelte/no-constant-condition rule Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants