Code Monkey home page Code Monkey logo

Comments (7)

jonaskello avatar jonaskello commented on June 10, 2024 1

So I'm thinking about implementing these rules:

  • no-loop-break (does not check in switch)
  • no-continue
  • no-if
  • no-switch (which implicitly bans break in switch)
  • no-for
  • no-while covers both while() {} and do {} while()

I think this would be a good division, but not 100% sure about no-loop-break and no-while. They could be implemented differently, for example no-break with option ignore-switch as in the original post. Also no-continue could be named no-loop-continue just for duality with no-loop-break.

from tslint-immutable.

jonaskello avatar jonaskello commented on June 10, 2024

This seems like some nice additions to the functional style rules :-).

from tslint-immutable.

jonaskello avatar jonaskello commented on June 10, 2024

I'm think about how the options for no-loops would work.

"no-loops": [true]

That would disable all loops, including while, for, do.

"no-loops": [true, "while"]

That would only disable while leaving for and do available?

I'm thinking maybe it is more logical to have ignore options, like ignore-for, ignore-while etc.

Also not sure if do is needed as an option? If the while keyword is banned then do would not be useful anyway? And in that case maybe two separate rules named no-for and no-while would make more sense?

from tslint-immutable.

kevinSuttle avatar kevinSuttle commented on June 10, 2024

You’re right. I like the last option. Agree it’s more logical. I like tailoring rules based on how frequently a part of code is likely to be used.

from tslint-immutable.

kevinSuttle avatar kevinSuttle commented on June 10, 2024

FWIW: the standard lib has a no-for-in rule: https://palantir.github.io/tslint/rules/no-for-in-array/

Also, it has prefer-for-of, but that's still a loop. https://palantir.github.io/tslint/rules/prefer-for-of/

Maybe ban? https://palantir.github.io/tslint/rules/ban/

from tslint-immutable.

jonaskello avatar jonaskello commented on June 10, 2024

I published 4.5.0 with the following new rules:

  • no-loop
  • no-if-statement

In order to keep the amount of rules and documentation down I went back to the original suggestion of no-loop which includes all loop types.

These rules remains to be implemented:

  • no-loop-break
  • no-loop-continue
  • no-switch

If anyone care to implement them I'm open for a PR on any or all of the above rules :-).

from tslint-immutable.

kevinSuttle avatar kevinSuttle commented on June 10, 2024

Awesome! Thank you!

from tslint-immutable.

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.