Giter Site home page Giter Site logo

Comments (8)

pingshunhuang avatar pingshunhuang commented on May 21, 2024 7

@adidahiya Could you please recommend a way for the 2 cases you gave above. I got this rules triggered a lot and I'm not sure how to improve them. Thanks.

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024 1

@MiguelMadero eh, that wouldn't really solve my use case because so much of JS syntax is a valid expression. My primary motivation for using this rule was to ban multiline ternarys and function calls (primarily .map, since it's used to generate lists)

// bad
<div className={
    someComplicatedCondition
        ? "positive-case"
        : "positive-case"}
    otherProp={true}
/>

// bad
<div>
    {this.props.foo.map((f) => {
        return <span>{f}</span>;
    })}
</div>

I could imagine another option here for stylistic preference, however, ignore-conditional-expressions, to allow multiline ternarys like in my first example ^

from tslint-react.

markwongsk avatar markwongsk commented on May 21, 2024

How lenient do you think it should be? Should we just allow object literals, or do you think this should allow things like

popoverProps={this.computePopoverProps({
    popoverClassName: "docs-dropdown-ramen-popover",
})}

Also, this rule currently doesn't care about spread attributes, eg

<Dropdown {...{
    items: mocks.groups(),
    placeholder: "Ramen joint",
}} />

but that's probably a separate issue.

from tslint-react.

piotrwitek avatar piotrwitek commented on May 21, 2024

@adidahiya @markwongsk this is hanging for quite some time, can we push for this change?

I really need this configurability and I think that disable for object literals is enough for a start.
Checking tslint conventions suggested name might be: "ignore-object-literal"

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

@markwongsk I guess we could break down the use cases into "be lenient on multiline functions / lambdas" and "be lenient on object or array literals". so this rule could have two new options: ignore-functions and ignore-literals

@piotrwitek open to PRs, as always :)

from tslint-react.

MiguelMadero avatar MiguelMadero commented on May 21, 2024

Would it be a simpler distinction between JS statements and expressions? It seems like multline expressions (object literals, ternary, function calls, etc) make more sense than multiple statements.

from tslint-react.

petrdanecek avatar petrdanecek commented on May 21, 2024

Is there any plan or update about this topic?

from tslint-react.

adidahiya avatar adidahiya commented on May 21, 2024

Closing due to deprecation, see #210

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.