-
Notifications
You must be signed in to change notification settings - Fork 840
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
[tech debt] Lint Emotion CSS-in-JS #6839
Conversation
- see https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-15.md - this removal of Prettier conflicts will save us a lot of setup for CSS-in-JS
- to Sass overrides only - we'll need a separate set of rules for CSS-in-JS later - see https://github.com/stylelint/stylelint/blob/main/docs/user-guide/rules.md#deprecated
- @see https://github.com/hudochenkov/postcss-styled-syntax + set up rule overrides as necessary to handle JS-specific issues
- in favor of simply typing `--fix` manually, or calling `yarn llint-fix` - remove lint-sass-fix entirely since we're moving away from sass
- use `mathWithUnits` and border width var instead
- use obj keys so that Emotion correctly generates the expected classNames - use conditionals in array, not in CSS generation - use separate fn for SR styles that take a custom arg
- matches Sass
Our various JS utils generally include trailing `;`s and don't need extra `;`s after them + lint a few extra trailing `}`s which stylelint also catches
- new stylelint default in v15 uses commas (complex) instead of chained `:not()`s - disable for Sass - wasn't previously linted
- valid usage in this case, but in general we should lint for it
- `except` isn't handling JS interpolation well, so change it to `ignore` instead
- Sass will be going away soon and is irrelevant - CSS-in-JS has one deprecation warning (extra semicolons), but it's pretty dang useful, so I think we should not warn on it
@elastic/eui-team Would super appreciate a review on this whenever any of y'all have a sec! It's a lot of lines but most of it is either just I'll be doing more Emotion work this week after this so being able to auto-lint that work would be 💯 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6839/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I was able to run all the commands locally, intentionally broke a file, fixed it as expected. Looked through the commits as suggested. Very helpful!
- I'm sure this will come up in the future otherwise
Thanks Trevor! I realized that the |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6839/ |
Summary
closes #6477
I strongly recommend following along by commit, but here's the TL;DR:
stylelint
to v15block-no-empty
false positive that was otherwise cropping up frequently*.style.ts
etc files now caught by our linter//
comments in CSS-in-JS - we must use CSS-allowed/* */
comments only. The parser will error otherwiseQA
yarn lint
passes*.styles.ts
file and break linting on purpose (e.g. add a semicolon to the end of a${logicalCSS()};
line)yarn lint-css-in-js
and confirm it flags the new erroryarn lint-fix
and confirm it auto-fixes the errorGeneral checklist
[ ] A changelog entry exists and is marked appropriatelyN/A, should be dev-only / not have any user-facing changes