eslint-plugin-lit icon indicating copy to clipboard operation
eslint-plugin-lit copied to clipboard

feat: add a rule to ensure attribute is set to false when type is not serializable

Open jpradelle opened this issue 1 year ago • 0 comments

I think it would be great to have a rule to forbid usage of attribute for a property if type is not natively convertible or if no converter is defined. Native convertible types are String, Number, Boolean, Object, Array : https://lit.dev/docs/components/properties/#conversion-type

This would be no warning

@property() foo;
@property({type: String) foo;
@property({type: Boolean) foo;
@property({type: Number) foo;
@property({type: Array) foo;
@property({type: Object) foo;
@property({type: Foo, converter: {fromAttribute: ..., toAttribute: ...}) foo;
@property({type: Foo, attribute: false) foo;

And this would be warning

@property({type: Function) foo;
@property({type: Foo) foo;

jpradelle avatar Jul 23 '24 10:07 jpradelle