Skip to content

Commit 2172423

Browse files
committed
fix(eslint-config-ts-lib): 修复 eslint 不检测 react hooks 的依赖的缺陷
1 parent c3ee025 commit 2172423

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"editor.formatOnSave": true,
33
"javascript.format.enable": false,
44
"typescript.format.enable": false,
5-
"eslint.enable": true,
65
"editor.codeActionsOnSave": {
76
"source.fixAll.eslint": true
87
},

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 变更说明
22

3+
## v0.13.9 - 2020.10.15
4+
5+
- fix(eslint-config-ts-lib): 修复 eslint 不检测 react hooks 的依赖的缺陷
6+
37
## v0.13.8 - 2020.10.15
48

59
- fix(eslint-config-ts-lib): 禁用 react/require-default-props,不推荐使用

e2e/eslint/react-hook-deps-demo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useEffect } from 'react';
2+
3+
export default function Demo({ open }: { open: boolean }) {
4+
useEffect(() => {
5+
console.log(open);
6+
}, []);
7+
8+
return null;
9+
}

packages/eslint-config-ts-lib/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ const eslintConfig = {
1919
},
2020
extends: [
2121
'airbnb-typescript',
22+
'plugin:react-hooks/recommended',
2223
'prettier',
2324
'prettier/@typescript-eslint',
24-
'prettier/standard',
2525
'prettier/react',
26+
'prettier/standard',
2627
'plugin:cypress/recommended',
2728
],
2829
globals: {
@@ -36,7 +37,7 @@ const eslintConfig = {
3637
ecmaVersion: 2019,
3738
sourceType: 'module',
3839
},
39-
plugins: ['@typescript-eslint', 'prettier', 'cypress'],
40+
plugins: ['@typescript-eslint', 'prettier', 'cypress', 'react-hooks'],
4041
settings: {
4142
'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.json', '.mjs'],
4243
'import/ignore': ['.css$', '.png$', '.jpg$', '.svg'],

0 commit comments

Comments
 (0)