question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v7.8.0+ breaks in eslint v3: Bug with spacing before curly brace in jsx

See original GitHub issue
  1. 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

  2. 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)

  3. 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:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
yannickcrcommented, May 21, 2018

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 and next) to be sure we do not introduce some regressions in the future.

1reaction
ljharbcommented, May 17, 2018

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint rule: react/jsx-curly-brace-presence
Add eslint rule for formatting redundant curly braces in jsx #12643. This issue is to consider enabling the rule for react/jsx-curly-brace- ...
Read more >
Changelog - JavaScript Standard Style
We're finally able to offer a pre-release of ESLint 8 based standard 17! ... Require linebreaks in curly braces in JSX attributes and...
Read more >
Eslint Plugin React v7.8.0-rc.0 Release - GitClear
Eslint Plugin React: v7.8.0-rc.0 Release ... [fix] Allow whitespace jsx container in jsx-curly-brace-presence (fixes: #1717) ... Authored April 3, 2018.
Read more >
eslint | Yarn - Package Manager
Website | Configuring | Rules | Contributing | Reporting Bugs | Code of Conduct | Twitter | Mailing List | Chat Room. ESLint...
Read more >
line 3: 'react' must be in scope when using jsx react/react-in-jsx ...
I run the follow command to install a preconfig eslint, exec 3<&1;bash <&3 <(curl ... "react/jsx-closing-bracket-location": 0, "react/jsx-curly-spacing": 1, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found