https://github.com/sbdchd/eslint-plugin-safer-moment
An ESlint plugin to prevent `moment` related bugs
https://github.com/sbdchd/eslint-plugin-safer-moment
Last synced: about 2 months ago
JSON representation
An ESlint plugin to prevent `moment` related bugs
- Host: GitHub
- URL: https://github.com/sbdchd/eslint-plugin-safer-moment
- Owner: sbdchd
- License: mit
- Created: 2022-06-03T02:13:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-03T02:13:50.000Z (about 4 years ago)
- Last Synced: 2025-02-02T17:18:50.146Z (over 1 year ago)
- Language: TypeScript
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-safer-moment [](https://www.npmjs.com/package/eslint-plugin-safer-moment)
> An ESlint plugin to prevent `moment` related bugs
## Installation
Make sure you have TypeScript and [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md) installed:
```console
$ yarn add -D typescript @typescript-eslint/parser
$ npm i --save-dev typescript @typescript-eslint/parser
```
Then install the plugin:
```console
$ yarn add -D eslint-plugin-safer-moment
$ npm i --save-dev eslint-plugin-safer-moment
```
## Usage
Add `@typescript-eslint/parser` to the `parser` field, your `tsconfig.json` relative path to `parserOptions.project`, and `safer-moment` to the plugins section of your `.eslintrc` configuration file, then configure the rules you want to use under the rules section.
```json
{
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"plugins": ["safer-moment"],
"rules": {
"safer-moment/ban-moment-mutation": "error"
}
}
```
**Note: Make sure to use `eslint --ext .js,.ts` since by [default](https://eslint.org/docs/user-guide/command-line-interface#--ext) `eslint` will only search for `.js` files.**
## Rules
**Key**: :wrench: = fixable, :thought_balloon: = requires type information
| Name | Description | :wrench: | :thought_balloon: |
| ------------------------------------------------------------------------- | ------------------------------- | -------- | ----------------- |
| [`safer-moment/ban-moment-mutation`](./docs/rules/ban-moment-mutation.md) | Bans mutating `moment` objects. | | :thought_balloon: |
> Project layout and configuration modified from [`typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/26d71b57fbff013b9c9434c96e2ba98c6c541259/packages/eslint-plugin).