-
Notifications
You must be signed in to change notification settings - Fork 61
Not recognising infinity as valid keyword #247
Comments
Hi, can you provide more codes about
|
const circleFadeDelay = keyframes`
0%,
39%,
100% {
opacity: 0;
}
40% {
opacity: 1;
}
`;
const circleFadeDelayRule = css`
${circleFadeDelay} 1.2s infinite ease-in-out both;
`;
const Circle = props => {
const CirclePrimitive = styled.div`
${ ... }
animation: ${circleFadeDelayRule};
${ ... }
`;
return <CirclePrimitive />;
}; The issue here is that stylelint cannot recognize infinite in css template string. I try with another setup in which const circleFadeDelayRule = css`
animation: ${circleFadeDelay} 1.2s infinite ease-in-out both;
`;
const Circle = props => {
const CirclePrimitive = styled.div`
${ ... }
${circleFadeDelayRule};
${ ... }
`;
return <CirclePrimitive />;
}; which works fine. Does this mean that styled component / (stylelint loader) cannot recognize css template string without style attribute? |
Is there a way for style lint to know that this is an interpolation? const something = 'background'
const Button = styled.div`
// Tell the processor that "something" is a property
${/* sc-prop */ something}: papayawhip;
` suggested in the doc The code is from react-boilerplate.
|
I tried |
I think yes. This processor will extract css from source files and send to postcss to parse. Without style attribute, it will throw an error because the extracted content is not completed css rule. Similar issues are #221, #222. Personally, I have a tendency to treat it as a feature need to be implemented in stylelint processor. But it is not easy.
It is due to stylelint uses |
Thank you. |
@emilgoldsmith @mxstbr Because the processor will extract everything from css helper and try to parse. The current website doc gives a not very good sample. Any ideas about the tradeoff between highlighting css helper and linting? |
Running into the same issue due to keyframe animation changes in Styled Components 4.0. My workaround is to convert the tagged template literal to the tag function equivalent. Much less readable, but at least it gets stylelint to stop complaining: const fadeIn = keyframes`...`
// EQUIVALENT TO: css`${fadeIn} 0.2s linear;`
const animationRule = css(
(['', ' 0.2s linear;'] as any) as TemplateStringsArray,
fadeIn
)
const StyledDiv = styled.div`
animation: ${animationRule}
` |
Environment
npx envinfo --system --binaries --npmPackages stylelint,styled-components,stylelint-processor-styled-components,stylelint-config-styled-components,stylelint-config-recommended --markdown --clipboard
System:
Binaries:
npmPackages:
.stylelintrc
Reproduction
https://www.webpackbin.com/bins/-KeeZCr0xKfutOfOujxN
https://codesandbox.io/s/rkmNRByE4
Steps to reproduce
Expected Behavior
lint success
Actual Behavior
The text was updated successfully, but these errors were encountered: