Coder Social home page Coder Social logo

Comments (11)

eirikhm avatar eirikhm commented on July 24, 2024 10

Let me clarify:

I'd like a rule which checks if braces are on the next line, and that it complains if they are on the same line.

As far as I could tell there is no way to enforce this.

from tslint.

eirikhm avatar eirikhm commented on July 24, 2024 2

It would be great if next-line braces was a rule as well. Solving it by ignoring the "oneline" rule is not ideal.

from tslint.

jkjustjoshing avatar jkjustjoshing commented on July 24, 2024 1

Is there any way to enforce the opposite of check-else? I want to enforce the following style:

if (expr) {
    // code
}
else {
    // code
}

and restrict the following style:

if (expr) {
    // code
} else {
    // code
}

EDIT - this can be accomplished with tslint-eslint-rules

from tslint.

Bartvds avatar Bartvds commented on July 24, 2024

I can toggle it with the oneline rule.

I think it should be split to it's own rule: it is not the same thing as oneline's "opening brace to be on the same line as the expression preceding it".

from tslint.

ashwinr avatar ashwinr commented on July 24, 2024

sure, makes sense.

from tslint.

ashwinr avatar ashwinr commented on July 24, 2024

made all checks optional, fixed by 5cd203a

from tslint.

gscshoyru avatar gscshoyru commented on July 24, 2024

Can you give us an example of what you mean, @eirikhm? If you want your braces to be on the next line, why do you want to one-line rule enabled at all?

from tslint.

JoshMcCullough avatar JoshMcCullough commented on July 24, 2024

Agreed, why not add the inverse to force blocks to their own line?

from tslint.

sam-s4s avatar sam-s4s commented on July 24, 2024

Is there any way to enforce the opposite of check-else? I want to enforce the following style:

if (expr) {
    // code
}
else {
    // code
}

and restrict the following style:

if (expr) {
    // code
} else {
    // code
}

This is a very common requirement - I've just found out it's not supported in tslint and I'm a bit surprised... I thought this was exactly the type of thing tslint was for?

from tslint.

JoshuaKGoldberg avatar JoshuaKGoldberg commented on July 24, 2024

@sam-s4s see #4534

from tslint.

sam-s4s avatar sam-s4s commented on July 24, 2024

Aww that's almost a bit sad :( lol

from tslint.

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.