Skip to content

Commit

Permalink
feat(rule): implement
Browse files Browse the repository at this point in the history
  • Loading branch information
gund committed Feb 16, 2020
0 parents commit 607a932
Show file tree
Hide file tree
Showing 11 changed files with 1,513 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"directory": "./tsconfig.json"
}
}
},
// "plugins": ["@typescript-eslint", "deprecation"],
"rules": {
// "deprecation/deprecation": "warn"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"endOfLine": "lf",
"trailingComma": "all"
}
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# eslint-plugin-deprecation

> Rule that reports usage of deprecated code
## Prerequisites

This plugin only works with `@typescript-eslint/parser`.

Which means that you should install dev deps:

- `@typescript-eslint/parser`
- `typescript`

Then configure your `.eslintrc` like this:

```jsonc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json" // <-- Point to your project's tsconfig.json or create new one
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"directory": "./tsconfig.json" // <-- Same tsconfig.json must be referenced
}
}
}
}
```

## Install

Install the plugin

```
npm i -D eslint-plugin-deprecation
```

## Setup

Now add deprecation plugin and rule to your `.eslintrc`:

```jsonc
{
"plugins": ["deprecation", ...],
"rules": {
"deprecation/deprecation": "warn", // or "error" to have stricter rule
...
}
}
```

Now eslint will report all deprecated code that you use!

---

_NOTE:_ This code was ported from https://github.com/SonarSource/SonarJS repository.
Loading

0 comments on commit 607a932

Please sign in to comment.