-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
Description
I noticed after upgrading to v7.0.0 of this package that the jsx-sort-props
rule is no longer honoring my callbacksLast
flag. Given this hunk of my ESLint configuration...
react/jsx-sort-props:
- warn
-
callbacksLast: true
ignoreCase: true
reservedFirst: false
shorthandFirst: true
...a line like this...
<AppBar showLogo={ showLogo } onLogoClick={ this.handleNavigateHome } onToggleMenu={ this.handleToggleMenu } />
...will yield the following warnings:
warning: Props should be sorted alphabetically (react/jsx-sort-props) at src/app/views/app/index.jsx:118:39:
116 | <AppMenu />
117 | </Popover>
> 118 | <AppBar showLogo={ showLogo } onLogoClick={ this.handleNavigateHome } onToggleMenu={ this.handleToggleMenu } />
| ^
119 | <main className={ styles.main }>
120 | <div className={ styles.mainWrapper } ref={ node => this.scroller = node }>
121 | <Switch>
warning: Props should be sorted alphabetically (react/jsx-sort-props) at src/app/views/app/index.jsx:118:79:
116 | <AppMenu />
117 | </Popover>
> 118 | <AppBar showLogo={ showLogo } onLogoClick={ this.handleNavigateHome } onToggleMenu={ this.handleToggleMenu } />
| ^
119 | <main className={ styles.main }>
120 | <div className={ styles.mainWrapper } ref={ node => this.scroller = node }>
121 | <Switch>
My expectation would be that with callbacksLast
enabled, the showLogo
prop should appear before the on...
props, which latter should be sorted alphabetically at the end into onLogoClick
then onToggleMenu
. Though I could certainly be misunderstanding some change to the rule.
Thanks in advance for your help, and let me know if I can furnish any more debugging information!
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
jseminck commentedon May 23, 2017
The problem seems to be the combination of
ignoreCase: true
andcallbacksLast: true
callbacksLast
is looking for a pattern:on[A-Z]
:However,
ignoreCase: true
is callingtoLowerCase()
:The bug was introduced in 7.0.0. Specifically here - where the check for the
isCallbackPropName()
was moved from beforeif (ignoreCase)
to after this condition.6e18e40#diff-bf26edcfae7aa27411d9a791b4eb8a8eL74
Seems like a simple fix, moving it back to it's original position does not break any tests. Will create a PR that includes a test case containing these two properties as defined options.
23 remaining items
chore(deps): update all non-major dependencies (patch) (#6329)
fix(deps): update dependency eslint-plugin-react to v7.35.2 (#899)
fix(deps): update dependency eslint-plugin-react to v7.35.2 (#11470)
fix(deps): update dependency eslint-plugin-react to v7.35.2 (#11470)
Update all non-major dependencies (#1207)
chore(deps): update eslint (#363)
build(deps): update dependency eslint-plugin-react to v7.35.2 (#10285)
Update dependency eslint-plugin-react to v7.36.1 (#2605)
fix(deps): update dependency eslint-plugin-react to v7.36.1 (#30)
Update all non-major dependencies (#280)
Update dependency eslint-plugin-react to v7.36.1 (#2443)
fix(deps): update dependency eslint-plugin-react to v7.37.3