v7.8.0+ breaks in eslint v3: Bug with spacing before curly brace in jsx
See original GitHub issue-
Attempt check with lint following code:
<Component onChange={(e) => set('string', e.target.value)}/>
Causes the error:89:94 error A space is required before closing bracket react/jsx-tag-spacing
-
When trying to check the code with lint:
<Component onChange={(e) => set('string', e.target.value) }/>
Lint return:TypeError: sourceCode.getCommentsBefore is not a function at Object.fix (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:256:46)
at RuleContext.report (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint/lib/rule-context.js:127:34)
at reportNoEndingSpace (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:250:15)
at EventEmitter.validateBraceSpacing (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:368:11)
at emitOne (events.js:121:20)
at EventEmitter.emit (events.js:211:7)
at NodeEventGenerator.applySelector (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint/lib/util/node-event-generator.js:265:26)
at NodeEventGenerator.applySelectors (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint/lib/util/node-event-generator.js:294:22)
at NodeEventGenerator.enterNode (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint/lib/util/node-event-generator.js:308:14)
at CodePathAnalyzer.enterNode (/home/anton.pavlov/projects/trendmd-admin-dashboard/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
-
But lint works properly with the following code:
<Component
onChange={(e) => set('string', e.target.value)}
/>
Expected: Lint works properly with both of variant of codes above
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Thanks for the report @pavlovanton, and for the help to identify the issue @reergymerej.
After fixing this issue I found a couple of other small issues with ESLint 3 (https://github.com/yannickcr/eslint-plugin-react/commit/69b1317532600eec0618352f30231da29f9435c7, https://github.com/yannickcr/eslint-plugin-react/commit/31e4f333ef9f46493dad510483fef38cd8c62f74, https://github.com/yannickcr/eslint-plugin-react/commit/677e1bd41e1711d034dddbf2cbb28698e73a72ec) and they should all be fixed in next release.
I also updated our Travis configuration to run our tests on different ESLint versions (
3.x.x
,4.x.x
andnext
) to be sure we do not introduce some regressions in the future.@reergymerej thanks, that’s very helpful. We’ll have to figure out how to restore eslint v3 support, since changing the peer dep is semver-major.