From 9bec1122a4ddf329e41678c855d031925f64ee94 Mon Sep 17 00:00:00 2001 From: yuche Date: Mon, 17 Dec 2018 11:02:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformer):=20=E5=9C=A8=20JSX=20=E4=B8=AD?= =?UTF-8?q?=E7=94=A8=E5=88=B0=E6=BA=90=E4=BA=8E=20`this.state`=20=E7=9A=84?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=B2=A1=E6=9C=89=E5=8A=A0=E5=85=A5=20usedSt?= =?UTF-8?q?ate=EF=BC=8Cclose=20#1492?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eslint-plugin-taro/__tests__/no-jsx-in-class-method.js | 6 +++--- packages/taro-transformer-wx/src/class.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin-taro/__tests__/no-jsx-in-class-method.js b/packages/eslint-plugin-taro/__tests__/no-jsx-in-class-method.js index 9cf1e495f73f..d6dca58ac9f1 100644 --- a/packages/eslint-plugin-taro/__tests__/no-jsx-in-class-method.js +++ b/packages/eslint-plugin-taro/__tests__/no-jsx-in-class-method.js @@ -36,12 +36,12 @@ ruleTester.run('no-jsx-in-class-method', rule, { } return })` - ]), + ]).com, invalid: testInvalid(ERROR_MESSAGE, [ ` class App extends Component { - _render() { - return + test(a) { + return a.map(_ => ) } } `, diff --git a/packages/taro-transformer-wx/src/class.ts b/packages/taro-transformer-wx/src/class.ts index 38007720306a..b42693bc18c0 100644 --- a/packages/taro-transformer-wx/src/class.ts +++ b/packages/taro-transformer-wx/src/class.ts @@ -349,7 +349,7 @@ class Transformer { const sibling = path.getSibling('property') if ( path.get('object').isThisExpression() && - path.get('property').isIdentifier({ name: 'props' }) && + (path.get('property').isIdentifier({ name: 'props' }) || path.get('property').isIdentifier({ name: 'state' })) && sibling.isIdentifier() ) { const attr = path.findParent(p => p.isJSXAttribute()) as NodePath