-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
💅 lint/a11y/useAltText asks for alt when using object spread #3977
Comments
Duplicate of #3660 |
@ematipico is there any interest in a flag in biome that says "if an alt tag is present in the component props it doesn't error and it is up to the developer to manage dynamic props". tbh that is what I thought the default behavior would be. |
Facing the same issue, while I specifically add a fallback text when the component alt prop is empty or nullish; |
Sure, I don't see a particular issue with that, however I want to clearly understand a couple of real use cases, so we can document properly the new option. |
There's a veeeery old discussion in the old Rome Tools repository. This is a pattern that is usually used in component libraries. |
No particular reason in terms of functionality I am using, I use it mainly for style preference. When you create a rest prop variable, it always has to be at the end, so I always use the spread operator at the end as well. It's also a piece of uninteresting code, so when you read a component from left to right you want the most important props mentioned first. I can see a use-case where people use the spread-operator for overwriting default values I guess. Let's say the rest prop variable contains an alt attribute, but you also specify a custom alt text before the spread operator, the spread operator can override the manually set prop. |
Ok I see. I think we can simply check if |
That would be lovely, maybe nice to reopen this issue until this is implemented? Easier to keep track of when this has been resolved |
If others accept, we can accept a PR for that. |
Some rules use the same logic, this means we should change it for all of them. I agree with the change, however:
I would close this issue, and open a new issue that explains the work to do. |
i will fix this, it sounds like not very hard. |
Environment information
Rule name
lint/a11y/useAltText
Playground link
https://biomejs.dev/playground/?code=YwBvAG4AcwB0ACAAZgBsAGEAZwAgAD0AIAB0AHIAdQBlADsACgAKAGMAbwBuAHMAdAAgAHQAZQBzAHQAIAA9ACAAKAApACAAPQA%2BACAAewAKACAAIAByAGUAdAB1AHIAbgAgADwAaQBtAGcACgAgACAAIAAgAGEAbAB0AD0AIgBhAGwAdAAgAHQAYQBnACIACgAgACAAIAAgAHMAcgBjAD0AIgAiAAoAIAAgACAAIAB7AC4ALgAuACgAZgBsAGEAZwAgACYAJgAgAHsACgAgACAAIAAgACAAIAByAGUAZgBlAHIAcgBlAHIAUABvAGwAaQBjAHkAOgAgACcAbgBvAC0AcgBlAGYAZQByAHIAZQByACcALAAKACAAIAAgACAAfQApAH0ACgAgACAALwA%2BAAoAfQA%3D
Expected result
Should not show an error as the alt tag is included
Code of Conduct
The text was updated successfully, but these errors were encountered: