-
-
Notifications
You must be signed in to change notification settings - Fork 435
SVG elements ignored with tagname-lowercase rule
#1795
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,27 @@ describe(`Rules: ${ruleId}`, () => { | |
| const messages = HTMLHint.verify(code, ruleOptions) | ||
| expect(messages.length).toBe(0) | ||
| }) | ||
|
|
||
| it('Known SVG elements should be ignored with no config', () => { | ||
| const code = | ||
| '<svg><animateMotion /><linearGradient /><foreignObject /><textPath /></svg>' | ||
| const messages = HTMLHint.verify(code, ruleOptions) | ||
| expect(messages.length).toBe(0) | ||
| }) | ||
|
|
||
| it('Known SVG elements should be ignored with a config override', () => { | ||
| const code = '<svg><feGaussianBlur /><radialGradient /></svg>' | ||
| ruleOptions[ruleId] = ['customTag'] | ||
| const messages = HTMLHint.verify(code, ruleOptions) | ||
| expect(messages.length).toBe(0) | ||
| ruleOptions[ruleId] = true | ||
| }) | ||
|
|
||
| it('Set to array list should not result in an error', () => { | ||
| const code = '<CustomComponent /><AnotherCamelCase />' | ||
| ruleOptions[ruleId] = ['CustomComponent', 'AnotherCamelCase'] | ||
| const messages = HTMLHint.verify(code, ruleOptions) | ||
| expect(messages.length).toBe(0) | ||
| ruleOptions[ruleId] = true | ||
| }) | ||
|
Comment on lines
+48
to
+54
|
||
| }) | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,14 +14,20 @@ Level: <Badge text="Error" variant="danger" /> | |||||||
|
|
||||||||
| - `true`: enable rule | ||||||||
| - `false`: disable rule | ||||||||
| - `['clipPath', 'data-Test']`: Ignore some tagname name | ||||||||
| - `['clipPath', 'data-Test']`: enable rule except for the given tag names. All SVG camelCase elements are included, for example `linearGradient`, `foreignObject` | ||||||||
|
||||||||
| - `['clipPath', 'data-Test']`: enable rule except for the given tag names. All SVG camelCase elements are included, for example `linearGradient`, `foreignObject` | |
| - `['clipPath', 'data-Test']`: enable rule except for the given tag names. All SVG camelCase elements are included, for example `linearGradient`, `foreignObject`. The array can include literal tag names as strings, `RegExp` objects, or string-based regex patterns such as `'/^svg[A-Z]/'` or `'/^data-/i'`, for example: | |
| - `['clipPath', /data-[A-Z]\w+/, '/^my-/i']` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
testAgainstStringOrRegExpfunction is duplicated fromattr-lowercase.ts(lines 77-114). This creates code duplication and increases maintenance burden. Consider extracting this function to a shared utility module to avoid duplication and ensure consistency across both rules.