-
-
Notifications
You must be signed in to change notification settings - Fork 681
Add no-shared-component-data
rule.
#84
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
89f7ec3
to
8f4c945
Compare
@michalsnik cleaned up and merged |
I'm considering the rule name. In general, eslint rules which disallow something starts with I don't have the best idea, but maybe |
@mysticatea |
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.
Few minor suggestions @armano2
).forEach(cp => { | ||
context.report({ | ||
node: cp.value, | ||
message: 'Component `data` must be a function.' |
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.
What do you think about changing the message to:
data
property in component must be a function
module.exports = { | ||
meta: { | ||
docs: { | ||
description: 'Enforces that a component data must be a function', |
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.
component's
@@ -0,0 +1,33 @@ | |||
# Enforces that a component data must be a function (no-shared-component-data) |
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.
What about: Enforces component's data property to be a function
?
@@ -0,0 +1,51 @@ | |||
/** | |||
* @fileoverview When using the data property on a component (i.e. anywhere except on new Vue), the value must be a function that returns an object. |
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.
I'd use the same title as in documentation
p.key.name === 'data' && | ||
p.value.type !== 'FunctionExpression' && | ||
p.value.type !== 'Identifier' | ||
).forEach(cp => { |
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.
Move .forEach
to new line for consistency
5992614
to
7453a77
Compare
@michalsnik suggestions applied + i rebased changes and applied |
// Public | ||
// ---------------------------------------------------------------------- | ||
|
||
return Object.assign({}, |
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.
Object.assign
seems to be redundant
@michalsnik fixed |
This PR implements rules proposed in #79
DONE:
Importnant:
This rule splits
executeOnVueComponent
intoexecuteOnVueInstance
andexecuteOnVueComponent
and adds aliasexecuteOnVue
utils.executeOnVueComponent
new Vue
useutils.executeOnVueInstance
utils.executeOnVue