An ESLint plugin to disallow usage of JavaScript Date objects.
npm install @xtrctio/eslint-plugin-disallow-date> An ESLint plugin to disallow usage of JavaScript Date objects.
1. Install ESLint:
```
$ npm i -D eslint
2. Install @xtrctio/eslint-plugin-disallow-date:
``
$ npm i -D @xtrctio/eslint-plugin-disallow-date
Note:
If you installed ESLint globally (using the -g flag) then you must also@xtrctio/eslint-plugin-disallow-date
install globally.
Add @xtrctio/disallow-date to the plugins section of your .eslintrceslint-plugin-
configuration file. You can omit the prefix, but must include@xtrctio
the package scope:
`json`
{
"plugins": [
"@xtrctio/disallow-date"
]
}
Then configure the rules you want to use under the rules section.
`json`
{
"rules": {
"@miovision/disallow-date/no-new-date": 2,
"@miovision/disallow-date/no-static-date": 2,
"@miovision/disallow-date/no-to-date": 2,
}
}
Run the linter with npx eslint --ext=js .
| | Rule ID | Description |
|---|------------------------------|--------------------------------------------------|
| | disallow-date/no-new-date | disallow new Date() usage |Date.now()
| | disallow-date/no-static-date | disallow and other static functions |moment().toDate()` functions |
| | disallow-date/no-to-date | disallow
The content of this project under the MIT license.