-
-
Notifications
You must be signed in to change notification settings - Fork 681
⭐️New: Add vue/require-direct-export
rule
#581
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @hirokiosame ! It looks like a nice addition to the current set :) I have one suggestion though
lib/rules/require-direct-export.js
Outdated
meta: { | ||
docs: { | ||
description: 'require the component to be directly exported', | ||
category: 'essential', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add every new rule as uncategorized
to have a nice period for testing it and introducing breaking changes if necessary, without having to wait for another major release. So I think we should change the category to undefined
for the time being :) We're still in v5 beta though, so it might land in v5 after all - we'll see.
In theory it's perfectly fine to have the component assigned to a variable and then exported. You can use a special comment for determining that this is a Vue component and it will be linted properly:
// @vue/component
const ComponentA = {
...
}
export default ComponentA;
The way I see it - essentials are here to prevent errors. And this is technically not an error-situation so I think it would better fit in strongly-recommended
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I didn't know about the comment. Good to know, thank you!
docs/rules/require-direct-export.md
Outdated
} | ||
} | ||
|
||
export default Component A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwanted space in Component A
docs/rules/require-direct-export.md
Outdated
|
||
## Rule Details | ||
|
||
This rule aims to... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please provide the short description?
Hey @michalsnik Apologies for the delayed changes, but made the fixes now. Let me know if there's anything else you'd like me to do! |
The category @hirokiosame is still not |
Vue SFC only allows default export where the default export must be a component object. A lot of the linting rules in this package only work when the component is directly exported like so (this is why I mark is as "essential"):
My team follows the Airbnb JS style, and sometimes the components are assigned to a variable before getting exported.
This rule is to deter components from being assigned to a variable before being exported so that all linting rules can be correctly applied.