Skip to content

Add rule prefer-object-rule #101

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

Merged
merged 1 commit into from
Jun 23, 2020
Merged

Add rule prefer-object-rule #101

merged 1 commit into from
Jun 23, 2020

Conversation

bradzacher
Copy link
Member

Adds a simple rule to help enforce that a rule uses object style rule definitions instead of function style.

I wanted this to help me migrate a legacy codebase of ~300 rules.

This rule pairs well and help with the require-meta-* rules as it allows their fixers to work.
Currently those rules will report an error, but not fix function style rules.

create(context) {
return { Program() { context.report() } };
},
};
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a duplicate example of the above.


module.exports = (context) => {
return { Program() { context.report() } };
};
Copy link
Member

Choose a reason for hiding this comment

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

I personally wouldn't bother showing multiple ways of defining the same function or object. A single function (incorrect) example and a single object (correct) example get the idea across. But up to you.

return { Program() { context.report() } };
},
};
```
Copy link
Member

Choose a reason for hiding this comment

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

This rule doc could have a ## References section which links to this doc:

https://eslint.org/docs/developer-guide/working-with-rules

@not-an-aardvark not-an-aardvark merged commit 7f625f4 into eslint-community:master Jun 23, 2020
@bradzacher bradzacher deleted the add-rule-prefer-object branch June 23, 2020 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants