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
Migrate to PostCSS 8 #4942
Comments
Out of curiosity I just bumped PostCSS to see what happen. 52 errors from TypeScript, mostly about missing imports. Probably because of new TypeScript types structure in PostCSS. Jest hanged (it was running, but no progress was made) with this message:
And this was it's status at that moment:
Almost every test has this warning:
It's because every of 205 rules we have is a PostCSS plugin. |
I've migrated my postcss-sorting to PostCSS 8 and it was easy (didn't use new API, though). I use following syntaxes in tests and no issues:
Maybe it won't be so hard to migrate stylelint. But then we could have strange issues because of different PostCSS versions in syntaxes and stylelint itself. |
I forked postcss-html and postcss-syntax to be part of stylelint organization, so we could update them and release under |
* master: (46 commits) Update CHANGELOG.md Add ignoreAtRules to property-no-unknown (#4965) Bump eslint from 7.11.0 to 7.12.1 (#5017) Bump typescript from 4.0.3 to 4.0.5 (#5016) Bump lint-staged from 10.4.0 to 10.5.1 (#5014) Bump remark-cli from 8.0.1 to 9.0.0 (#4996) Bump jest-circus from 26.5.3 to 26.6.1 (#5009) Bump got from 11.7.0 to 11.8.0 (#5007) Bump jest from 26.5.3 to 26.6.1 (#5008) Refactor formatter tests (#4988) Fix `isStandardSyntaxDeclaration.test.js` that use callbacks (#4972) Update CHANGELOG.md Add "comment-pattern" rule (#4962) Update CHANGELOG.md Show the pattern in "*-pattern" rule messages (#4975) Enable ESLint `no-shadow` and add disable comments (#4986) Report disables in the same manner as lints (#4973) Update dependencies (#4982) Fix some tests that use callbacks (#4970) Use own vendor utility instead of PostCSS (#4942) (#4963) ...
what is the status of this work ? |
I believe you could continue to use stylelint as you would before. Even if you use it as a PostCSS plugin. Because PostCSS 8 support plugins made for PostCSS 7. |
Is this true? It seems to me that most of the plugin updates are following documentation recommendation to use |
@niksy postcss 8 still supports the |
I wrote down some issues we have with custom syntaxes and what to do about that in PostCSS repository postcss/postcss#1498 |
In my experience, it's better to stick with either |
Oh! Great that you've created this tool, I could use it to test cssnano plugins! I've found that extracting the full performance potential from the visitor API was quite tricky, because in some cases the visitor API calls the same plugin multiple times. |
We've got the ball rolling on the I've added a checklist to the top post for the update to PostCSS 8. There's a Draft PR, and associated branch, for this work. There are 6 failing tests. Most seem to be around a change in parser behaviour for custom property sets. I suggest we pick these up in 3 separate pull requests:
Once we've patched up the failing tests and TypeScript errors, we can migrate the built-in rules to the visitor API to remove the deprecation warnings. Lastly, we'll need to investigate the impact of this change on the execution order. Please shout out if you'd like to pick up one of the failing tests pull requests, or start looking at the TypeScript errors. Remember to branch off |
Before migrating a rule to visitor API we would need to change how we run rules. Currently we going around PostCSS and call rule function directly. It will not work anymore, because now PostCSS plugin returns an object, and not a function. We need to use PostCSS API to call plugins now. E. g.: await postcss([plugin(pluginOptions)]).process(root, {
from: result.from,
}); |
The last failing test we need to fix is: FAIL lib/__tests__/disableRanges.test.js
● Less // disable next-line comment (with multi-line description)
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 3
Object {
- "description": "Long-winded description",
- "end": 5,
- "start": 5,
+ "description": undefined,
+ "end": 39,
+ "start": 39,
"strictEnd": true,
"strictStart": true,
}
1000 |
1001 | delete actualMutable.comment;
> 1002 | expect(actualMutable).toEqual(expected);
| ^
1003 | }
1004 |
1005 | function testDisableRanges(source, options) {
at expectDisableRange (lib/__tests__/disableRanges.test.js:1002:24)
at expectDisableRanges (lib/__tests__/disableRanges.test.js:993:4)
at Object.<anonymous> (lib/__tests__/disableRanges.test.js:968:2) For this test: it('Less // disable next-line comment (with multi-line description)', async () => {
const result = await testDisableRangesLess(
`a {
// stylelint-disable-next-line declaration-no-important
// --
// Long-winded description
color: pink !important;
}`,
);
expectDisableRanges(result, {
all: [],
'declaration-no-important': [
{
start: 5,
end: 5,
strictStart: true,
strictEnd: true,
description: 'Long-winded description',
},
],
});
}); It's the workaround we added to merge adjacent double slash comments into one.
@jathak do you have any ideas? I think you worked on this workaround at the time. |
I think we can, if anyone fancies it, pick up the TypeScript errors while we look into this last failing test? |
This would fix: CVE-2021-23368
|
That's correct. The Draft PR has no PostCSS@7 within its tree. |
As our rules and plugins are rule functions, is there a way we can adapt them I'm not very familiar with the engine as I've been more focused on the rules since the beginning of the project. So, if anyone fancies picking up this migration to PostCSS 8, please go ahead as I don't think I'll have time myself. |
If it's possible and we do this we need to find a way how to support rules and plugins, which use visitor API. |
Yep. I figured we could get the existing rules and plugins working first and then look into the visitor API. I think it's OK if we release without support for the visitor API. We can update our rule and plugin docs to say that the stylelint rule function will be placed within the PostCSS Better to get something secure out-the-door than try to support of a type of stylelint rule or plugin that's yet to be written. Of course, if there's a way of doing both then that would be great. But I think we should prioritise the former over the latter for now. |
I'll be fixing type issues and then try to continue migration to PostCSS 8. I've already started doing some work in a new branch, which is branched out from |
Closed by #5304 |
For anyone following this issue, there's still lots to do before we can release |
@jeddy3 any plans for an interim 13.x release just to fix the vulnerabilities and deprecation warnings? |
A 13.x release isn't possible because we had to make breaking changes, including removing the bundled syntaxes e.g. the incompatible CSS-in-JS syntax, to make the migration to PostCSS@8 possible. There is also a vulnerability in another dependency that is now ESM-only, so we need to migrate to ESM to fix all vulnerabilities. The best thing everyone can do is help us work through the remaining issues so that we release |
PostCSS v7 was released with back-port of ReDoS fix. So stylelint users on current version of stylelint should see warning go away after running |
Steps:
Release notes.
Migration guide.
Before we migrate we need all our dependencies be on PostCSS 8.
dependencies
are ready:@stylelint/postcss-css-in-js
— [WIP] Upgrade to PostCSS 8 postcss-css-in-js#74 (removed)@stylelint/postcss-markdown
(removed)autoprefixer
postcss
postcss-html
— https://github.com/stylelint/postcss-html/pull/1. (removed)postcss-less
postcss-media-query-parser
— it doesn't use PostCSS.postcss-resolve-nested-selector
— doesn't depend on PostCSS.postcss-safe-parser
postcss-sass
postcss-scss
postcss-selector-parser
— doesn't have PostCSS as peer or regular dependency.postcss-syntax
— https://github.com/stylelint/postcss-syntax/pull/2. (removed)postcss-value-parser
— doesn't depend on PostCSS.sugarss
devDependencies
are ready:postcss-import
Update won't be easy. We need to update custom syntaxes:
@stylelint/postcss-css-in-js
,@stylelint/postcss-markdown
. And we probably need to move into stylelint organization and updatepostcss-html
andpostcss-syntax
.After all that we can start updating stylelint itself.
The text was updated successfully, but these errors were encountered: