Comments (7)
So I'm thinking about implementing these rules:
no-loop-break
(does not check inswitch
)no-continue
no-if
no-switch
(which implicitly bansbreak
inswitch
)no-for
no-while
covers bothwhile() {}
anddo {} 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.
This seems like some nice additions to the functional style rules :-).
from tslint-immutable.
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.
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.
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.
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.
Awesome! Thank you!
from tslint-immutable.
Related Issues (20)
- Suggestion: make no-throw more restrictive HOT 8
- Rule "readonly-array" with option "ignore-return-type" doesn't work with generic parameters. HOT 3
- no-object-mutation conflicts with setters HOT 2
- Rule "readonly-array" with option "ignore-return-type" doesn't work with tuples.
- New option ignore-interface-prefix on readonly-keyword rule HOT 3
- Rule "readonly-array" with option "ignore-return-type" doesn't work with union, intersection and conditional types.
- Class member mutation in constructors is seen as initialization when it may not be. [no-object-mutation]
- Add support for new `readonly` keyword syntax for arrays and types in typescript 3.4 HOT 3
- [readonly-array] Nested arrays aren't allowed to be mutable with ignore-prefix.
- [no-array-mutation] Nested arrays are not checked.
- no-object-mutation does not respect the prefix setting HOT 4
- ESLint support HOT 7
- Some tests fail with node v12.
- Split readme up into smaller files. HOT 5
- rule requires type information. HOT 2
- How to disable semicolon insertion? HOT 1
- readonly-keyword does not support parameter properties HOT 2
- Question: cannot use reduce on array with initial = `[]` and no-array-mutation HOT 4
- "no-expression-statement" should allow super() call in constructors HOT 1
- "no-if-statement" enforces ternary even if no else present HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tslint-immutable.