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

Fix false negatives for babel decorators #161

Closed
wants to merge 3 commits into from
Closed

Conversation

abdonrd
Copy link

@abdonrd abdonrd commented May 10, 2021

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

Closes stylelint/stylelint#4761

Is there anything in the PR that needs further explanation?

All info here: stylelint/stylelint#4761 (comment)

@43081j
Copy link

43081j commented May 10, 2021

fwiw the code should let you override it via a babel config, but it doesn't seem to work...

i think this is because of it using an old plugin name. if you update this to be @babel/plugin-proposal-decorators, it works fine and lets you override it via babel config. can you change that too in this PR?

@abdonrd
Copy link
Author

abdonrd commented May 10, 2021

Thanks again @43081j! Seems working locally for me!

@abdonrd
Copy link
Author

abdonrd commented May 10, 2021

Friendly ping to previous committers like @hudochenkov, @jeddy3 and @bartlangelaan to feel a little more confident to be able to merge and release this!

(in fact, I don't know if I can release a new version after merge the PR)

@abdonrd abdonrd changed the title Allow babel decoratorsBeforeExport Fix false negatives for babel decorators May 10, 2021
extract.js Outdated
@@ -94,7 +94,7 @@ const plugins = [
'jsx',
'typescript',
'objectRestSpread',
['decorators', { decoratorsBeforeExport: false }],
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
Copy link
Author

@abdonrd abdonrd May 11, 2021

Choose a reason for hiding this comment

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

Suggested change
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
['decorators', { decoratorsBeforeExport: true }],

@43081j testing one more time...

Seems like this doesn't work:
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],

But it works with:
['decorators', { decoratorsBeforeExport: true }],

Copy link

@43081j 43081j May 11, 2021

Choose a reason for hiding this comment

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

really? i did try it locally and it worked fine, though i altered the file in node_modules directly. i had to install the plugin, though. maybe thats what you were missing? ideally i think we should check which is the correct one going forward according to babel

Copy link
Author

Choose a reason for hiding this comment

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

I also just edit the node_modules/@stylelint/postcss-css-in-js/extract.js directly.
I did not install any dependencies. We should?

Copy link

Choose a reason for hiding this comment

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

we really should be using what babel recommend and that seems to be the @babel/plugin-proposal-decorators plugin, so i personally would take this opportunity to update to that. but yeah that means we should probably require it as a peer dependency, or tell consumers if they want to use decorators they should install it.

one for the stylelint maintainers to decide i think. separately the parser shouldn't be eating up the babel errors either, so people are aware they're missing the dependency

@melink14
Copy link

Is there a path forward for this? From what I can tell, even if I install @babel/plugin-proposal-decorators it won't do anything until this change is in?

@abdonrd
Copy link
Author

abdonrd commented Jun 29, 2021

Is there a path forward for this? From what I can tell, even if I install @babel/plugin-proposal-decorators it won't do anything until this change is in?

I'm waiting an answer from the Stylelint Team (@hudochenkov, @jeddy3 or @bartlangelaan).

@hudochenkov
Copy link
Member

Can we have a test for this change?

@abdonrd
Copy link
Author

abdonrd commented Jul 7, 2021

Can we have a test for this change?

Sorry, I'm not familiar with it. Can you help me with this? Thanks in advance!

pastelsky pushed a commit to pastelsky/postcss-css-in-js that referenced this pull request Aug 26, 2021
@puku0x
Copy link

puku0x commented Dec 1, 2021

@abdonrd I realized my PR #237 is trying to solve the same problem about decorators.

@@ -94,7 +94,7 @@ const plugins = [
'jsx',
'typescript',
'objectRestSpread',
['decorators', { decoratorsBeforeExport: false }],
['decorators', { decoratorsBeforeExport: true }],
Copy link

Choose a reason for hiding this comment

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

I'm afraid, this doesn't help in my case.

@hudochenkov
Copy link
Member

Superseded by https://github.com/stylelint/postcss-css-in-js/issues/236 and released in 0.38.0.

@hudochenkov hudochenkov closed this May 3, 2022
@hudochenkov hudochenkov deleted the abdonrd-patch-1 branch May 3, 2022 08:04
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.

Fix false negatives for decorators
5 participants