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
Fix CSS-in-JS problems #4574
Comments
As of |
Probably related: #4800 |
Hey |
Is there any work ongoing on the forked parser? (https://github.com/stylelint/postcss-css-in-js) |
For context, the issues with the existing syntax are:
Thanks to @hudochenkov, we now have a Summary of the plan for
A lot has already been done for @slapbox If you, or anyone else, would like to help us get
Once @hudochenkov's reference syntax is ready, we can start encouraging the community to work on syntaxes for their CSS-in-JS library of choice. |
@hudochenkov So I'm migrating to stylelint 14 and all my styles are in .js files (using the Material-ui 4 JSS syntax). Using the customSyntax |
Same issue here. I only get it worked from the command line. I use styled-components in one of my projects and the code is not highlighted on error in vscode. It seems like the vscode extension can't see the rules in my config file. I also combine stylelint with prettier by using the stylelint-prettier plugin. I followed steps as described here with my own setup: package.json {
"scripts": {
// other scripts omitted for brevity
"lint:style": "npx stylelint \"**/*.{css,jsx,js}\"",
},
"dependencies": {
// other deps omitted for brevity
"styled-components": "^5.3.0",
},
"devDependencies": {
// other deps omitted for brevity
"@stylelint/postcss-css-in-js": "^0.37.2",
"postcss": "^8.4.5",
"postcss-syntax": "^0.36.2",
"stylelint": "^14.2.0",
"stylelint-a11y": "^1.2.3",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "^24.0.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-high-performance-animation": "^1.5.1",
"stylelint-no-unsupported-browser-features": "^5.0.2",
"stylelint-order": "^5.0.0",
"stylelint-prettier": "^2.0.0",
},
} .stylelintrc.js module.exports = {
plugins: [
'stylelint-a11y',
'stylelint-config-rational-order/plugin',
'stylelint-high-performance-animation',
'stylelint-no-unsupported-browser-features',
'stylelint-order',
'stylelint-prettier',
],
extends: [
'stylelint-config-standard',
'stylelint-config-recommended',
'stylelint-config-rational-order',
'stylelint-a11y/recommended',
'stylelint-prettier/recommended',
'stylelint-config-styled-components',
],
overrides: [
{
files: ['**/*.{js,jsx}'],
customSyntax: '@stylelint/postcss-css-in-js',
},
], Here's also my vscode settings: {
// other settings omitted for brevity
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.format.enable": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.formatDocument": true,
"source.fixAll": true
},
} Did someone find a solution for that? Any help would be appreciated. |
@Lornz- I did. // package.json
"devDependencies": {
"@babel/core": "7.16.0", // Do not update babel v7.16.5 or higher (https://github.com/stylelint/postcss-css-in-js/issues/247)
"@babel/parser": "7.16.0",
"postcss-jsx": "~0.36.0", // Do not use stylelint/postcss-css-in-js with decorators (https://github.com/stylelint/postcss-css-in-js/issues/236)
"postcss-scss": "~4.0.0",
"postcss-syntax": "~0.36.0",
"stylelint": "~14.2.0",
"stylelint-config-prettier": "~9.0.0",
"stylelint-config-recess-order": "~3.0.0",
"stylelint-config-recommended": "~6.0.0"
} // .stylelintrc.json
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-recess-order",
"stylelint-config-prettier"
],
"ignoreFiles": ["node_modules/**", "dist/**"],
"overrides": [
{
"files": ["**/*.scss"],
"customSyntax": "postcss-scss"
},
{
"files": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
"customSyntax": "postcss-jsx"
}
]
} // .vscode/settings.json
{
"css.validate": false,
"scss.validate": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"stylelint.validate": ["css", "scss", "typescript", "typescriptreact"] // 👈 Use stylelint for validation
} |
Closing as the We'll also be deprecating our forked CSS-in-JS package, in favour of leaner custom syntaxes. Please consider writing a custom syntax specific to your CSS-in-JS library of choice and addressing there any of the bugs above that are applicable. |
We have a bunch of CSS-in-JS related problems. I've gathered them here:
css
in nameTemplate literal interpolations:
We recently forked the parser we use for CSS-in-JS into the stylelint organisation. We can fix all the above issues by patching and maintaining this fork.
These issues are, along with the glob issues and the one for disable comments, our most pressing ones right now. They all prevent people from using stylelint completely.
If you can help us fix our fork of the parser, please add a comment below!
The text was updated successfully, but these errors were encountered: