eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 92 forks source link

JSX fragment causes false positives with no-multi-str #503

Closed nickmccurdy closed 5 years ago

nickmccurdy commented 5 years ago

What version of TypeScript are you using? 2.9.2

What version of typescript-eslint-parser are you using? 16.0.1

What code were you trying to parse?

export default function Home() {
  return (
    <>
      {description}
      <br />
      <Options labels={getOptions(questions)} />
    </>
  )
}

What did you expect to happen? No errors, because <></> is short for <React.Fragment></React.Fragment> and React is already imported.

What happened? Multiline support is limited to browsers supporting ES5 only no-multi-str

sbason commented 5 years ago

+1 I am getting the same thing with quotes throwing false positives

nickmccurdy commented 5 years ago

I couldn't figure out how to get it to behave with the shorthand, so I disabled the rule. With the number of exceptions to rules like this in this parser, I think it would be really useful to include a shared config that disables rules conflicting with TypeScript and the parser implementation.

ThaJay commented 5 years ago

subscribing, I als have both issues (quotes and no-multi-str get triggered on fragment)

With just jsx the quotes rule got triggered and I moved to babel/quotes to fix this. Now with tsx both rules get triggered (and thus the babel/quotes rule also does not work for ts)

lostfictions commented 5 years ago

Looks like this might be fixed (via #511, now brought in as https://github.com/JamesHenry/typescript-estree/pull/15)

infctr commented 5 years ago

Is the dependency going to be updated? It currently has "typescript-estree": "2.1.0" while 4.0.0 is the latest version

alangpierce commented 5 years ago

https://github.com/JamesHenry/typescript-estree/pull/15 was published in typescript-estree 2.1.0, so I was able to get fragments working by updating typescript-eslint-parser to latest. (Looks like the 4.0.0 is just from two breaking change commits since the fragments commit, not sure how important those are to pull in.)