Skip to content

Commit cad79bb

Browse files
G-Rathljharb
authored andcommitted
[Fix] jsx-handler-names: properly substitute value into message
1 parent 495a4cf commit cad79bb

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
88
### Added
99
* component detection: add componentWrapperFunctions setting ([#2713][] @@jzabala @LandonSchropp)
1010

11+
### Fixed
12+
* [`jsx-handler-names`]: properly substitute value into message ([#2975][] @G-Rath)
13+
14+
[#2975]: https://github.com/yannickcr/eslint-plugin-react/pull/2975
1115
[#2713]: https://github.com/yannickcr/eslint-plugin-react/pull/2713
1216

1317
## [7.23.2] - 2021.04.08

lib/rules/jsx-handler-names.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222

2323
messages: {
2424
badHandlerName: 'Handler function for {{propKey}} prop key must be a camelCase name beginning with \'{{handlerPrefix}}\' only',
25-
badPropKey: 'Prop key for {{propValue}} must begin with \'{{handlerPropPrefix}\''
25+
badPropKey: 'Prop key for {{propValue}} must begin with \'{{handlerPropPrefix}}\''
2626
},
2727

2828
schema: [{

tests/lib/rules/jsx-handler-names.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ ruleTester.run('jsx-handler-names', rule, {
210210
options: [{
211211
checkInlineFunction: true
212212
}]
213+
}, {
214+
code: '<TestComponent only={this.handleChange} />',
215+
errors: [{
216+
message: 'Prop key for handleChange must begin with \'on\''
217+
}]
213218
}, {
214219
code: '<TestComponent only={this.handleChange} />',
215220
errors: [{

0 commit comments

Comments
 (0)