Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chdsbd/eslint-plugin-better-dates
⏱ An ESlint plugin to encourage better `Date` usage and prevent `Date`-related bugs.
https://github.com/chdsbd/eslint-plugin-better-dates
eslint eslint-plugin typescript
Last synced: 7 days ago
JSON representation
⏱ An ESlint plugin to encourage better `Date` usage and prevent `Date`-related bugs.
- Host: GitHub
- URL: https://github.com/chdsbd/eslint-plugin-better-dates
- Owner: chdsbd
- License: mit
- Created: 2021-04-18T03:34:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-20T14:38:19.000Z (about 2 years ago)
- Last Synced: 2024-05-01T21:15:53.722Z (7 months ago)
- Topics: eslint, eslint-plugin, typescript
- Language: TypeScript
- Homepage:
- Size: 83 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-better-dates [![npm version](https://img.shields.io/npm/v/eslint-plugin-better-dates.svg)](https://www.npmjs.com/package/eslint-plugin-better-dates)
> An ESlint plugin to prevent `Date`-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-better-dates
$ npm i --save-dev eslint-plugin-better-dates
```## Usage
Add `@typescript-eslint/parser` to the `parser` field, your `tsconfig.json` relative path to `parserOptions.project`, and `better-dates` 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": ["better-dates"],
"rules": {
"better-dates/ban-date-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: |
| --------------------------------------------------------------------- | --------------------------------------------------------- | -------- | ----------------- |
| [`better-dates/ban-date-mutation`](./docs/rules/ban-date-mutation.md) | Bans calling methods on `Date` that will mutate the date. | | :thought_balloon: |> Project layout and configuration modified from [`typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/26d71b57fbff013b9c9434c96e2ba98c6c541259/packages/eslint-plugin).