You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Technically HTML tags and their attributes are case insensitive [1]. But React types generally prevent usage of the uppercase/mixed case version of the tags and attributes as it conflicts with other established conventions (eg: treating tags with the first letter uppercase as a component in JSX). The typings for React also error out for uppercased attributes.
However, data-attributes are special in this regard; From what I can see data-testId is considered to be valid attribute even by react (though it's automatically lowercase by the browser) (TS enabled react sandbox). Right now the lint rule creates a false positive for this and I am not sure if that should be the case.
The text was updated successfully, but these errors were encountered:
for tags, not generally - jsx explicitly prevents it.
For attributes, there's a bunch of patterns - some are case sensitive, some case-insensitive. data-testId is a perfectly valid attribute - because it works, even if the browser normalizes it.
Right, but what I meant to say was that: the lint rule throws an error for it.
The relevant code due to which it throws an error (the regex doesn't have A-Z)
data-testId is a perfectly valid attribute - because it works, even if the browser normalizes it.
Given this, I would think that it's a bug and should be fixed.
HJain13
changed the title
[no-unknown-property] Should data attributes be treated as case insensitive
[no-unknown-property] data-* attributes should be allowed to have uppercase letters as well
Sep 5, 2022
Technically HTML tags and their attributes are case insensitive [1]. But React types generally prevent usage of the uppercase/mixed case version of the tags and attributes as it conflicts with other established conventions (eg: treating tags with the first letter uppercase as a component in JSX). The typings for React also error out for uppercased attributes.
However, data-attributes are special in this regard; From what I can see
data-testId
is considered to be valid attribute even by react (though it's automatically lowercase by the browser) (TS enabled react sandbox). Right now the lint rule creates a false positive for this and I am not sure if that should be the case.The text was updated successfully, but these errors were encountered: