question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Way to support or ignore CSS-in-JS logic

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wfortincommented, Jan 18, 2021

I know it’s not officially supported but still works in most of the cases we need it fortunately.

0reactions
AndyOGocommented, Jan 18, 2021

No worries. You can learn it, there are plenty of free online resources for handling ASTs. You are welcome to provide a PR.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found