Implement fs module (#3)
* Implements the fs module * Add stats object * Add not implemented to createWriteStream * Update mkdtemp to use tmp dir * Unexport Stats * Add client web socket for commands and restructure
This commit is contained in:
37
rules/src/curlyStatementNewlinesRule.ts
Normal file
37
rules/src/curlyStatementNewlinesRule.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import * as ts from "typescript";
|
||||
import * as Lint from "tslint";
|
||||
|
||||
/**
|
||||
* Curly statement newlines rule.
|
||||
*/
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
|
||||
public static FAILURE_STRING = "curly statements must separate with newlines";
|
||||
|
||||
/**
|
||||
* Apply the rule.
|
||||
*/
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new CurlyStatementNewlinesWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Curly statement newlines walker.
|
||||
*/
|
||||
class CurlyStatementNewlinesWalker extends Lint.RuleWalker {
|
||||
|
||||
/**
|
||||
* Visit if statements.
|
||||
*/
|
||||
public visitIfStatement(node: ts.IfStatement): void {
|
||||
const splitLength = node.getFullText().split("\n").length;
|
||||
if (splitLength <= 2) {
|
||||
this.addFailureAt(node.getStart(), node.getWidth(), Rule.FAILURE_STRING);
|
||||
}
|
||||
|
||||
super.visitIfStatement(node);
|
||||
}
|
||||
|
||||
}
|
12
rules/tsconfig.json
Normal file
12
rules/tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"sourceMap": false,
|
||||
"declaration": false,
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": [
|
||||
"."
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user