Way to support or ignore CSS-in-JS logic
See original GitHub issueI would like to be able to suppress errors when using CSS-in-JS logic.
Example:
export const MyButton = styled.button`
font-size: ${({inherit}) => (inherit ? 'inherit' : tokens.fontMedium)};
`
With this ruleset:
"scale-unlimited/declaration-strict-value": "font-size"
I get the error:
Expected variable, function or keyword for "=>" of "font-size" scale-unlimited/declaration-strict-value
Extracting to a named function works:
const getFontSize = ({inherit}) => (inherit ? 'inherit' : tokens.fontMedium)
export const MyButton = styled.button`
font-size: ${getFontSize};
`
Would it be possible to ignore or allow any inline JS logic sections in CSS-in-JS styles? If this could be included with “ignoreFunctions: true” that would be great!
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Support full syntax in function rules and values #682 - GitHub
I'm using react-jss@10.0.0 and can't figure out how to make @global and dynamic values work together (I'm not sure this is the right...
Read more >Why We're Breaking Up with CSS-in-JS - DEV Community
Then, we'll do a deep dive into the performance issues that CSS-in-JS caused at Spot and how you can avoid them.
Read more >cssinjs/Lobby - Gitter
Hi guys! I have some error only in Safari. Warning: Prop 'className' did not match. Server: "jss-sectionTitle-123" Client: "jss-sectionTitle-122"
Read more >The Differing Perspectives on CSS-in-JS
I use it with Sass so we have access to mixins and variables that help consistency, but I could see how it could...
Read more >@ant-design/cssinjs - npm
It's a subset of Emotion with design token logic wrapper. Please feel free to use emotion directly if you want to find a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know it’s not officially supported but still works in most of the cases we need it fortunately.
No worries. You can learn it, there are plenty of free online resources for handling ASTs. You are welcome to provide a PR.