Skip to content
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

no-uninstalled-addons: support satisfies operator and default reexport #139

Merged

Conversation

hjoelh
Copy link
Contributor

@hjoelh hjoelh commented Aug 8, 2023

Issue: #

What Changed

no-uninstalled-addons now works with 2 additional export ways

(as shown in the docs)

const config: StorybookConfig = {
...
};

export default config;

&

export default {
  addons: [
	...
  ],
} satisfies StorybookConfig;

Checklist

Check the ones applicable to your change:

  • Ran yarn update-all
  • Tests are updated
  • Documentation is updated

Change Type

Indicate the type of change your pull request is:

  • maintenance
  • documentation
  • patch
  • minor
  • major

@hjoelh hjoelh force-pushed the additional-'no-uninstalled-addons'-support branch from 5844b07 to 783542f Compare August 9, 2023 09:00
@kasperpeulen kasperpeulen self-assigned this Aug 15, 2023
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

Hey @hjoelh thank you so much for your contribution! I added a comment for you to check out

}
},
ExportDefaultDeclaration: function (node) {
if (isIdentifier(node.declaration)) {
Copy link
Member

Choose a reason for hiding this comment

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

We have a getMetaObjectExpression utility function that analyzes a default export node and gives a valid meta object, and that supports all the notations, alongside their TS variants:

  • default export {}
  • const meta; export default meta;

I'm so sorry that you spent time in this without knowing it! But could you replace the implementation with something like this (and keep the tests):

import { getMetaObjectExpression } from '../utils'
// ...
      ExportDefaultDeclaration: function (node) {
        const meta = getMetaObjectExpression(node, context)
        if (!meta) {
          return null
        }

        const addonsProp = meta.properties.find(
          (prop): prop is TSESTree.Property =>
            isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons'
        )

        if (addonsProp && addonsProp.value && isArrayExpression(addonsProp.value)) {
          reportUninstalledAddons(addonsProp.value)
        }
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @yannbf! No worries at all, I'm not too familiar with ASTs and eslint plugins - thats a nice util 💯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bump @yannbf 🙏

@yannbf yannbf added the patch Increment the patch version when merged label Aug 15, 2023
@hjoelh hjoelh requested a review from yannbf August 15, 2023 16:21
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

This is just perfect! Thank you so so much @hjoelh <3

@yannbf yannbf changed the title additional 'no-uninstalled-addons' support no-uninstalled-addons: support satisfies operator and default reexport Oct 8, 2023
@yannbf yannbf merged commit 0fb2407 into storybookjs:main Oct 8, 2023
@github-actions
Copy link

github-actions bot commented Oct 8, 2023

🚀 PR was released in v0.6.15 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants