-
Notifications
You must be signed in to change notification settings - Fork 672
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
[enhancement]. using trim() on colors definitions and references to prevent incorrect spaces from causing unresolved #1435
Comments
Since the styled component syntax has to support both color aliases and native arguments, I don't think it's realistic to check for errors, so at least reduce the number of such hard-to-find errors |
To clarify, you want e.g. |
Alternatively, a solution I think I'd prefer, we could throw on such an error. if (process.env.NODE_ENV !== 'production') {
if (color in theme.colors && color !== color.trim()) {
throw new Error("serious message")
}
} |
Mostly it can't be a typo in the config |
'red' is a native variable, Perhaps not an appropriate example Not a native variable, but reference, Extra spaces are easier to find in the front, harder in the back Sometimes formatting plugins such as prettier to insert incorrect spaces when the code you are currently writing is not completely closed, so it is not uncommon I think adding a trim() is one of the easiest ways to implement it, it doesn't avoid errors 100% of the time, but at least 95% of the time it's possible Imagine when your component has more than 200 lines of code or more, with 3-4 sx blocs, it is hard to find a small space that causes an element not to render correctly eg:
|
🚀 Issue was released in |
Otherwise it is very difficult to find such bugs
The text was updated successfully, but these errors were encountered: