eslint-plugin-momentjs
About a month ago, I was working on some stuff using Javascript and our favorite “make-dates-sane” library, Moment.js. As you might expect, they have a number of suggestions on how to use Moment.js in such a way that reduces the potential for errors - strict mode parsing, etc. Unfortunately no automatic mechanism for enforcing those suggestions existed.
So, I took the suggestions that my company adopted specifically and created an ESLint plugin, named quite boringly, eslint-plugin-momentjs. This plugin as well as installation instructions are also available on the npm registry. Of course, the most up to date documentation for the rules can be found on the project repository, but for convenience I’ll reproduce them here (there are only four):
no-moment-constructor
When creating moment instances, use moment-timezone constructor over the moment only constructor.
Moment.js Documentation for this rule
require-format
Always specify the format of the date-time string, so moment does not have to guess the format.
Moment.js Documentation for this rule
require-strict-parsing
Prefer strict format check over loose format check.
Moment.js Documentation for this rule
require-timezone
Require a time zone argument to calls to moment.tz
Moment.js Documentation for this rule
Feature requests (or better yet, pull requests!) are welcome at the project home page.