Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives on "Declare only one React component per file" (react/no-multi-comp) #1088

Closed
MoOx opened this issue Feb 23, 2017 · 3 comments · Fixed by singapore/lint-condo#262

Comments

@MoOx
Copy link
Contributor

MoOx commented Feb 23, 2017

import test from "jest-ava-api"
import React, { createElement } from "react"
import { createRenderer } from "react-addons-test-utils"

const renderer = (...args) => { // I guess this is detected as a component
  const render = createRenderer()
  render.render(...args)
  return render.getRenderOutput()
}

test("what", () => {
  return {
    isActive: () => false, // what?
  }
})

react/no-multi-comp is detecting 2 components here since I get a warning on the last () => false.
Both are wrong.

Ps: the code does not make sense as it is as I removed some part to make the debugging more easy.

Not that if I does not import createElement, the error seems to disappear (but I need this...)

MoOx added a commit to MoOx/phenomic that referenced this issue Feb 23, 2017
benstepp added a commit to benstepp/eslint-plugin-react that referenced this issue Feb 23, 2017
Previously, when createElement was destructured from React, it would
cause any function defined in the file to be flagged as a React
Component. This change makes it such that the function must call
createElement to be considered a component.

Fixes jsx-eslint#1088
@ljharb
Copy link
Member

ljharb commented Feb 23, 2017

(Unrelated, but you may want to check out enzyme rather than creating your own renderers)

benstepp added a commit to benstepp/eslint-plugin-react that referenced this issue Feb 23, 2017
Previously, when createElement was destructured from React, it would
cause any function defined in the file to be flagged as a React
Component. This change makes it such that the function must call
createElement to be considered a component.

Fixes jsx-eslint#1088

---

Review: Use object.assign with sourceType: module in the added test over
babel-eslint.
omerzach pushed a commit to omerzach/eslint-plugin-react that referenced this issue Mar 21, 2017
Previously, when createElement was destructured from React, it would
cause any function defined in the file to be flagged as a React
Component. This change makes it such that the function must call
createElement to be considered a component.

Fixes jsx-eslint#1088

---

Review: Use object.assign with sourceType: module in the added test over
babel-eslint.
@ljharb
Copy link
Member

ljharb commented May 8, 2017

@nickbouton would you mind filing a new issue about it?

@nickbouton
Copy link

@ljharb Sure, added #1181 & removed my comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants