Comments (9)
indent
checks for indentation consistency within statement blocks. Currently, a tab character is treated as 4 spaces, but we can make it configurable if necessary. Take a look at the indentation test if you really want to understand how the rule works.
from tslint.
I think there is a bug that was part of my confusion, looks related to the one-line literals:
With this rule:
"indent": [true, 4],
In this snippet (with tabs)
getKey(label:string, keyTerms?:any):string {
return xm.jsonToIdent([label, keyTerms ? keyTerms : {}]);
}
I get these 2 errors (line 75 is the indented line):
>> src/git/GitAPICached.ts[75, 27]: unexpected tab width: expected 16, got 0
>> src/git/GitAPICached.ts[75, 34]: unexpected tab width: expected 16, got 0
from tslint.
This one is interesting as well. This the content of a single file:
module xm {
export function callAsync(callback, ...args:any[]) {
process.nextTick(() => {
callback.apply(null, args);
});
};
}
With this error: (line 6 is is next-to-last-one with the };
>> src/xm/callAsync.ts[6, 3]: unexpected tab width: expected 4, got 0
Notice the };
is my mistake, the semicolon doesn't belong there (as the brace is from a named function). If I remove the semicolon the rule passes.
from tslint.
Fixed the indentation rule to allow one-line literals always. so, the first example above should work.
from tslint.
there's not much we can do about the second one. the single semi-colon is treated as an empty statement, and tslint complains about it not indented correctly (which is a valid complaint, IMHO). In general, we advise tslint to run after the tsc compilation succeeds, so we don't get tripped up by compiler errors, but there's not much we can do in this particular case.
from tslint.
Cool, I understand. I had tslint before compilation, as it is a lot faster then compiling. But I can see how that'd could go wrong, I'll swap it.
Note the noempty
doesn't warn about this particular case though (in my 0.2.1)
from tslint.
but there's no empty block in your example, right?
from tslint.
Ooops, you are right!
I was confused with your mention of 'empty statement' (which there is between the closing brace and the semicolon, but that's not this rule).
from tslint.
cool :)
from tslint.
Related Issues (20)
- TypeScript >=3.8 Support HOT 8
- Fix CVE-2020-7598 HOT 14
- Why is there a version 6.1 when 6.0 is deprecated? HOT 3
- run tslint to specific folder HOT 1
- Vulnerability in minimist, need to upgrade to latest version HOT 5
- Support Typescript 3.8 both type-only import and regular import HOT 2
- Update issue templates to mention deprecation HOT 3
- Make `case-insensitive-legacy` part of possible `ordered-imports` options HOT 3
- error HOT 7
- TSLint 6.1 requires TS 3.8 to compile HOT 4
- Build failed with TypeScript 3.8.3 HOT 2
- tslint wouldn't prompt error if I put before initialized `this` inside a JavaScript getter? HOT 1
- Update https://palantir.github.io/tslint/ to mention deprecation HOT 2
- Compiler option in tsconfig.json not considered causing rule violations of "typescript:S4328" HOT 5
- Improve codeFrame formatter to include rule severity with each failure HOT 1
- Update deps and devDeps? HOT 2
- align rule (and possibly others) broken with TypeScript 4.0.0-dev HOT 1
- Version 6.1.3 is not marked as deprecated HOT 1
- Error thrown in 'align' rule HOT 1
- Angular app not install HOT 3
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.