New rule for the react
and next
domains for noStringImageSrcPaths
#7605
jakeleventhal
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In cases where you are referencing the public folder via a path, it is often preferably to allow TS to validate your paths.
Assume a public folder like this:
If your code looks like this:
and then you rename the
home/
folder tonew-home
, it is very easy to forget and find all references to the public folder via import string pathsInstead, you can rely on TS to help you out here by importing the file directly like so:
With this approach, if you rename the folder, your code will not silently fail since the import will be to an invalid path.
This proposal is to ban the usage of strings as the src if they are referencing non-url paths (i.e. public folder paths).
Beta Was this translation helpful? Give feedback.
All reactions