Skip to content

Commit 16e7019

Browse files
beefancohenyannickcr
authored andcommitted
Add support for function-bind to jsx-no-bind (fixes #532)
1 parent 9d4a59f commit 16e7019

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/rules/jsx-no-bind.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ module.exports = function(context) {
6363
node: node,
6464
message: 'JSX props should not use arrow functions'
6565
});
66+
} else if (
67+
!configuration.allowBind &&
68+
valueNode.type === 'BindExpression'
69+
) {
70+
context.report({
71+
node: node,
72+
message: 'JSX props should not use ::'
73+
});
6674
}
6775
}
6876
};

tests/lib/rules/jsx-no-bind.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ ruleTester.run('jsx-no-bind', rule, {
142142
code: '<div ref={c => this._input = c}></div>',
143143
errors: [{message: 'JSX props should not use arrow functions'}],
144144
parser: 'babel-eslint'
145+
},
146+
147+
// Bind expression
148+
{
149+
code: '<div foo={::this.onChange} />',
150+
errors: [{message: 'JSX props should not use ::'}],
151+
parser: 'babel-eslint'
152+
},
153+
{
154+
code: '<div foo={foo.bar::baz} />',
155+
errors: [{message: 'JSX props should not use ::'}],
156+
parser: 'babel-eslint'
157+
},
158+
{
159+
code: '<div foo={foo::bar} />',
160+
errors: [{message: 'JSX props should not use ::'}],
161+
parser: 'babel-eslint'
145162
}
146163
]
147164
});

0 commit comments

Comments
 (0)