Skip to content

New Rule: invalid-attribute #821

Open
@paoloricciuti

Description

@paoloricciuti

Motivation

In the past (and apparently i'm not alone ) i had the need to prevent certain types of attributes to be used. It could be the need to prevent an onclick attribute like i asked months ago (well now it would actually be the opposite ironically) or something more general for some specific reasons i think having a way to specify a list of invalid attributes could be a good rule to have.

Description

The user can provide through rule options a list of invalid attributes/regex. Every component using such attribute will be reported.

Examples

Given a configuration like this

{
    "rules": {
        "svelte/invalid-attribute": ["error", ["title"]]
    }
}
<!-- ✗ BAD -->
<Foo title=""/>
<Foo {title}/>
<Foo bind:title/>
<Foo title={somevar}/>

we probably can also error on props named that way for in-repo components.

Additional comments

I got a very barebone version of this already and if interested i can work on it and submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions