Skip to content

Commit

Permalink
fix(eslint-plugin-taro): 组件属性无法使用 this.state.* 形式赋值
Browse files Browse the repository at this point in the history
fixed #145 : JSX 事件名需以 on 命名
  • Loading branch information
zacksleo committed Jun 23, 2018
1 parent ada4861 commit 827db83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/eslint-plugin-taro/__tests__/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ ruleTester.run('jsx-handler-names', rule, {
},
{
code: testComponent(`<View src={a.b} />`)
},
{
code: testComponent(`<View src={this.state.img} />`)
}
],
invalid: [{
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-taro/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
const propIsEventHandler = PROP_EVENT_HANDLER_REGEX.test(propKey)
console.log(node.value.expression)
const isPropValueFunction = source.startsWith('this.props.on') ||
source.startsWith('this.')
(source.startsWith('this.') && !source.startsWith('this.state.'))

if (!propIsEventHandler && isPropValueFunction) {
context.report({
Expand Down

0 comments on commit 827db83

Please sign in to comment.