Skip to content

Disable particular rules for template expressions #257

Closed
@marekdedic

Description

@marekdedic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions