Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

fix loading babel options for @babel/plugin-proposal-decorators #237

Merged
merged 3 commits into from
May 3, 2022
Merged

fix loading babel options for @babel/plugin-proposal-decorators #237

merged 3 commits into from
May 3, 2022

Conversation

puku0x
Copy link

@puku0x puku0x commented Nov 28, 2021

Which issue, if any, is this issue related to?

Fixes #236

Is there anything in the PR that needs further explanation?

This PR solves the problem when @stylelint/postcss-css-in-js is used with .babelrc which has @babel/plugin-proposal-decorators that results the following error.

Error: Cannot use the decorators and decorators-legacy plugin together

Note the error is not displayed on the console because extract.js ignores errors during pursing the babel options.

@puku0x

This comment has been minimized.

@puku0x puku0x marked this pull request as draft November 30, 2021 09:00
@puku0x puku0x marked this pull request as ready for review November 30, 2021 13:24
@puku0x

This comment has been minimized.

@puku0x

This comment has been minimized.

@puku0x
Copy link
Author

puku0x commented Nov 30, 2021

#240 fixes CI

);

if (index > -1) {
opts.parserOpts.plugins.splice(index, 1);
Copy link
Author

@puku0x puku0x Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the decorators plugin to make loadBabelOpts() respect user's .babelrc.

['decorators', { decoratorsBeforeExport: false }],

@puku0x
Copy link
Author

puku0x commented Dec 2, 2021

CI fixed💪

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@puku0x Thanks for creating the PR! Could you please add a test case for the change?

@puku0x
Copy link
Author

puku0x commented Dec 2, 2021

I'll add a test case for the fix.

@puku0x
Copy link
Author

puku0x commented Dec 2, 2021

Test case added.

package.json Outdated
@@ -74,6 +74,7 @@
"@babel/core": ">=7.15.5"
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.16.4",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This babel plugin is needed for the test I added because it loads @babel/plugin-proposal-decorators from the generated .babelrc.

@puku0x
Copy link
Author

puku0x commented Dec 2, 2021

I confirmed the tests failed without the fix.

image

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@puku0x Thank you so much! LGTM 👍🏼

@ybiquitous
Copy link
Member

@abdonrd Could you please review this pull request if you have time?

@puku0x
Copy link
Author

puku0x commented May 3, 2022

I rebased this branch to master but it seems 0.37.7 does not solve for the decorators issue without this fix.

@hudochenkov hudochenkov merged commit 9579653 into stylelint:master May 3, 2022
@hudochenkov
Copy link
Member

  • Fixed: silent fail if @babel/plugin-proposal-decorators is in user's Babel configuration (#237)

@puku0x puku0x deleted the fix-babel-plugin-decorators branch May 3, 2022 08:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Error: Cannot use the decorators and decorators-legacy plugin together
3 participants