Skip to content

Commit b2b731b

Browse files
committed
Add TypeScript rules
1 parent f689fed commit b2b731b

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,39 @@ In your `.eslintrc` configuration file:
3737
```js
3838
module.exports = {
3939
plugins: [
40-
'eslint-plugin-node',
40+
'eslint-plugin-node'
4141
],
4242
extends: [
4343
'async',
4444
'async/node'
4545
],
4646
};
4747
```
48+
49+
### Base rules + Node.js specific rules + TypeScript rules (recommended for TypeScript users)
50+
Install this package and its peer dependencies:
51+
52+
```shell
53+
npm install --save-dev eslint eslint-config-async eslint-plugin-node typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
54+
```
55+
56+
In your `.eslintrc` configuration file:
57+
58+
```js
59+
module.exports = {
60+
plugins: [
61+
'eslint-plugin-node',
62+
'@typescript-eslint'
63+
],
64+
extends: [
65+
'async',
66+
'async/node',
67+
'async/typescript'
68+
],
69+
parser: '@typescript-eslint/parser',
70+
parserOptions: {
71+
tsconfigRootDir: __dirname,
72+
project: ['./tsconfig.json'],
73+
}
74+
};
75+
```

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
},
2424
"peerDependencies": {
2525
"eslint": ">=8.11.0",
26-
"eslint-plugin-node": ">=11.1.0"
26+
"eslint-plugin-node": ">=11.1.0",
27+
"typescript": "*",
28+
"@typescript-eslint/parser": "^5.0.0",
29+
"@typescript-eslint/eslint-plugin": "^5.0.0"
2730
}
2831
}

typescript.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
rules: {
3+
// TypeScript rules
4+
"@typescript-eslint/await-thenable": "error",
5+
"@typescript-eslint/no-floating-promises": "error",
6+
"@typescript-eslint/no-misused-promises": "error",
7+
"@typescript-eslint/promise-function-async": "error",
8+
},
9+
};

0 commit comments

Comments
 (0)