Added check for es6 methods (harmony) #1020
Conversation
@@ -41,7 +41,7 @@ module.exports.prototype = { | |||
check: function(file, errors) { | |||
file.iterateNodesByType('ObjectExpression', function(node) { | |||
node.properties.forEach(function(property) { | |||
if (property.shorthand) { | |||
if (property.shorthand || property.method) { |
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.
might be a good util: isKeylessProperty(node)
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.
Yep. Property
?
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 should maybe think about tree iteration yielding custom classes like an ObjectExpression class that has a list of Property instances. Each Property instance will have the isKeylessProperty method. This avoids the bag of utils. Probably an issue worthy comment?
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 really like that idea but realization can be painful. Anyway, we can discuss about it and decide in that issue ;-) So, yep!
I see 6 rules changed with only three tests updated. Please add a test to all 6 to prevent coverage regression. If you add the utils method, you'll need to test it in test/utils.js as well. |
LGTM otherwise. |
About method in utils: I've started to add this but it looks uglier ;-( I suggest to add it as property or method to |
@zxqfox it's a dangerous path modifying nodes. Let's just stick with what you have for now then, and we can revisit this in the future. |
LGTM |
@zxqfox, can you please make sure future commit messages match our documented format from contributing.md:
|
Fixes #1013