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 in jsx-pascal-case when a variable and an element has the same name #329

Closed
lencioni opened this issue Nov 23, 2015 · 4 comments

Comments

@lencioni
Copy link
Collaborator

I have a component that renders some SVG elements that are showing up as false positives for the new jsx-pascal-case rule. The one I've found so far is the <stop> element, which is demonstrated by the following code:

<svg>
  <defs>
    <linearGradient
      x1='-1'
      y1='0%'
      x2='1'
      y2='0%'
      gradientTransform='rotate(5 .5 .5)'
      >
      <stop offset='0%' style={{ stopColor: BACKGROUND_COLOR }} />
      <stop offset='20%' style={{ stopColor: SHIMMER_COLOR }} />
      <stop offset='40%' style={{ stopColor: BACKGROUND_COLOR }} />
    </linearGradient>
  </defs>
</svg>

I'm not sure if there are others.

@phun-ky
Copy link

phun-ky commented Dec 2, 2015

I've encountered the same issue with stop within a radialGradient

@lencioni
Copy link
Collaborator Author

lencioni commented Dec 2, 2015

I started looking into fixing this by adding the following test case to the valid section of jsx-pascal-case tests

  {
    code: [
      '<svg>',
      '  <defs>',
      '    <linearGradient',
      '      x1="-1"',
      '      y1="0%"',
      '      x2="1"',
      '      y2="0%"',
      '      gradientTransform="rotate(5 .5 .5)"',
      '      >',
      '      <stop offset="0%" style={{ stopColor: BACKGROUND_COLOR }} />',
      '      <stop offset="20%" style={{ stopColor: SHIMMER_COLOR }} />',
      '      <stop offset="40%" style={{ stopColor: BACKGROUND_COLOR }} />',
      '    </linearGradient>',
      '  </defs>',
      '</svg>'
    ].join('\n'),
    ecmaFeatures: {
      jsx: true
    }
  }

and it passed. So maybe this has been fixed somewhere, or the problem exists in some combination of things that aren't true in this test but are true in our environments?

@yannickcr
Copy link
Member

Ok, I think the problem only occurs if you have a variable with the same name as your element.

Another example by @yordis:

<label htmlFor={name}>{label}</label>

@yannickcr yannickcr changed the title Some SVG elements false positives in jsx-pascal-case False positives in jsx-pascal-case when a variable and an element has the same name Dec 5, 2015
@calebmer
Copy link

calebmer commented Dec 8, 2015

Is this being worked on?

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

No branches or pull requests

4 participants