Skip to content

Disable particular rules for template expressions #257

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

Closed
marekdedic opened this issue Sep 22, 2022 · 3 comments · Fixed by #261
Closed

Disable particular rules for template expressions #257

marekdedic opened this issue Sep 22, 2022 · 3 comments · Fixed by #261
Labels
bug Something isn't working

Comments

@marekdedic
Copy link
Contributor

Description

Hi,
I'd like to disable some rules for template expressions only - typically rules about typescript. Example:

<button onClick={() => {clicked += 1}}>Increment</button> // HERE

<script lang="ts">
function fn() { // HERE
    return 3;
}
</script>

With my current configuration, I get the error Missing return type on function (@typescript-eslint/explicit-function-return-type) on the two lines marked by comments. This is problematic, because I can't use TS in template expressions and therefore I can't add a return type annotation to the first line of my snippet. However, I would still like to have the rule turned on for the second case, where it correctly reports that I forgot to add the return type annotation.

Currently, I found no way of doing this other than manually ignoring all the "false positives" or getting rid of any non-trivial template expressions - I would like to have a way to say to eslint that the rule @typescript-eslint/explicit-function-return-type should be turned off for all template expressions, however it should still check <script /> blocks.

@marekdedic marekdedic added the enhancement New feature or request label Sep 22, 2022
@ota-meshi
Copy link
Member

Thank you for posting this issue.
But, I think we've already provided a way to ignore template warnings.

https://ota-meshi.github.io/eslint-plugin-svelte/user-guide/#settings-svelte

@marekdedic
Copy link
Contributor Author

Hi,
thanks for the reply and the pointer - I read the docs but thought this would ignore warnings in all svelte code, not just teplate expressions - maybe I'll submit a PR to make it more obvious :)

However, this does not work for me :( See the repro, run npm run lint:ts:eslint - I would expect one error, but I get two. Is this an issue on my side?

@ota-meshi
Copy link
Member

It seems there was a bug. I will fix that.

@ota-meshi ota-meshi added bug Something isn't working and removed enhancement New feature or request labels Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants