Giter Site home page Giter Site logo

Comments (15)

adidahiya avatar adidahiya commented on May 21, 2024 7

more false positives I've found:

return [
    <button type="submit">
        Submit
    </button>,
    <button type="button">
        Cancel
    </button>
];

from tslint-react.

wichert avatar wichert commented on May 21, 2024 7

Another repro using React 16.2:

return (
  <>
    <div>One</div>
    <div>Two</div>
  </>
)

from tslint-react.

dawnmist avatar dawnmist commented on May 21, 2024 4

Problem is that the 4.0.0 release of tslint-react no longer permits the standard prettier formatting for the reactDom.render() example, whereas they worked fine together in tslint-react 3.6.0.

Prettier removes any brackets around the JSX in the first parameter for reactDom.render, so it is not possible for:

 render(
  <ApolloProvider client={client}>
    <Router history={history}>
      <App />
    </Router>
  </ApolloProvider>,
  document.querySelector('main') as HTMLElement,
);

to be written as

render((
    <ApolloProvider client={client}>
      <Router history={history}>
        <App />
      </Router>
    </ApolloProvider>
  ),  document.querySelector('main') as HTMLElement,
);

when using prettier like tslint 4.0.0 now wants it to be. Can whatever was changed between those two versions for this particular rule & case please be reverted?

from tslint-react.

giladgray avatar giladgray commented on May 21, 2024 3

the array false positive @adidahiya mentioned above has forced me to disable this rule... we use that pattern everywhere.

from tslint-react.

evenfrost avatar evenfrost commented on May 21, 2024 2
render(
  <ApolloProvider client={client}>
    <Router history={history}>
      <App />
    </Router>
  </ApolloProvider>,
  document.querySelector('main') as HTMLElement,
);

Here's the code that throws false positive jsx-wrap-multiline for me.

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024 1

tslint-react had this rule before prettier was widely used in the typescript ecosystem and before we started using prettier in Palantir projects. all the code formatting rules in tslint & tslint-react are "legacy" rules in that sense; they are not guaranteed to play nicely with prettier. if you use tslint-config-prettier (the recommended configuration approach), you should have all formatting rules disabled in favor of prettier.

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

I can repro this, looks like a bug

from tslint-react.

IllusionMH avatar IllusionMH commented on May 21, 2024

Is it still can be reproduced?
Checked by replacing test/rules/jsx-wrap-multiline/test.tsx.lint with all code examples from this issue and link in original post. Win 10, tslint 4.5.1, tsc 2.2.1

Only example of bad code triggers error. Example with button in div passes lint as well as JSX Elements in array.

@adidahiya example from your last comment is false positive or false negative? I'd expect braces there too, but no lint errors at this moment.

from tslint-react.

quantuminformation avatar quantuminformation commented on May 21, 2024

I'm getting Multiline JSX elements must be wrapped in parentheses

for
image

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

@quantuminformation yeah, that's the same as my comment above #79 (comment)

from tslint-react.

rhys-vdw avatar rhys-vdw commented on May 21, 2024

I wouldn't call this a false positive:

return [
    <button type="submit">
        Submit
    </button>,
    <button type="button">
        Cancel
    </button>
];

I prefer:

return [(
    <button type="submit">
        Submit
    </button>
), (
    <button type="button">
        Cancel
    </button>
)];

One reason is that when refactoring it's very easy to leave the trailing , after the closing tag, which can end up appearing in your rendered markup.

from tslint-react.

Primajin avatar Primajin commented on May 21, 2024

@rhys-vdw problem with this way is that it is contradicting ESLint / Prettier rules...

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

I don't think we're going to fix this in tslint at this point. See #210 and palantir/tslint#4534. You're better off using prettier (edit: which you can already do without switching to ESLint).

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

but why would you want to enable jsx-wrap-multiline when prettier is enabled?

from tslint-react.

dawnmist avatar dawnmist commented on May 21, 2024

Good question, and one I really hadn't thought a lot about previously because the two packages worked in harmony previously and now do not.

Flipping the question back - if you're trying to encourage people to use prettier instead of tslint-react, why would you introduce conflicting formatting that makes migration between the two projects require additional work when it had previously been working in harmony? Now anyone using tslint-react has had to change their render functions from a prettier-compatible format into a prettier-incompatible format, only to have them changed back again after migrating to prettier. That introduces unnecessary noise to git commit/blame histories for no real benefit, and no good reason when the change wasn't needed in the first place.

from tslint-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.