Skip to content

Commit 44ccec1

Browse files
committed
Improved ts & tslint configs
1 parent f1c72a6 commit 44ccec1

File tree

6 files changed

+162
-96
lines changed

6 files changed

+162
-96
lines changed

Takefile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (take) => {
1+
module.exports = take => {
22
take.options.shell.printStdout = true;
33
take.options.shell.printStderr = true;
44

@@ -10,13 +10,13 @@ module.exports = (take) => {
1010
desc: 'Builds Take',
1111
async execute() {
1212
await take.exec('tsc');
13-
}
13+
},
1414
},
1515
clean: {
1616
desc: 'Cleans up build output',
1717
async execute() {
1818
await take.exec('rm', '-rf', out);
19-
}
19+
},
2020
},
2121
test: {
2222
desc: 'Tests Take',
@@ -25,26 +25,31 @@ module.exports = (take) => {
2525
'ts-node',
2626
[
2727
'-P', 'tsconfig.json',
28-
'./test/test.ts'
29-
]
28+
'./test/test.ts',
29+
],
3030
);
31-
}
31+
},
3232
},
3333
lint: {
3434
async execute() {
3535
await take.exec('tslint', '--project', '.');
36-
}
36+
},
37+
},
38+
fix: {
39+
async execute() {
40+
await take.exec('tslint --project . --fix');
41+
},
3742
},
3843
publish: {
3944
desc: 'Publishes format-tree to npm',
4045
deps: [
41-
':'
46+
':',
4247
],
4348
async execute() {
4449
await take.exec('yarn', 'publish');
4550
await take.exec('git', 'push', 'origin', '--tags');
4651
await take.exec('git', 'push');
47-
}
48-
}
52+
},
53+
},
4954
};
5055
};

lib/mod.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ export function formatTree(tree: TreeNode | TreeNode[], options: Options = {}):
142142
// build current line
143143
toBuild.push({
144144
line: prefix + guide + node.text,
145-
extra: node.extra
145+
extra: node.extra,
146146
});
147147

148148
// build children
149149
if (hasChildren) {
150-
let nprefix = prefix + (last ? ' ' : '│') + ' ' + (inset === 1 ? ' ' : '');
150+
let nprefix = `${prefix}${last ? ' ' : '│'} ${inset === 1 ? ' ' : ''}`;
151151
if (options.guideFormat) {
152152
nprefix = options.guideFormat(nprefix);
153153
}
154154
processNodes(
155155
node.children!,
156-
nprefix
156+
nprefix,
157157
);
158158
}
159159
}
@@ -166,7 +166,7 @@ export function formatTree(tree: TreeNode | TreeNode[], options: Options = {}):
166166
} else {
167167
toBuild.push({
168168
line: tree.text,
169-
extra: tree.extra
169+
extra: tree.extra,
170170
});
171171
tr = tree.children;
172172
shouldFirstCap = false;
@@ -187,7 +187,7 @@ export function formatTree(tree: TreeNode | TreeNode[], options: Options = {}):
187187
for (const item of toBuild) {
188188
let line = item.line;
189189
if (item.extra) {
190-
line += ' '.repeat(maxLen - stringLength(item.line)) + `${extraSplit}${item.extra}`;
190+
line += `${' '.repeat(maxLen - stringLength(item.line))}${extraSplit}${item.extra}`;
191191
}
192192
output.push(line);
193193
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"@types/node": "^10.9.4",
2121
"chalk": "^2.4.1",
2222
"tslint": "^5.11.0",
23+
"tslint-config-prettier": "^1.17.0",
24+
"tslint-eslint-rules": "^5.4.0",
2325
"typescript": "^3.0.3"
2426
},
2527
"dependencies": {

tsconfig.json

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,32 @@
11
{
22
"compilerOptions": {
3-
/* Basic Options */
4-
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5-
"target": "esnext",
6-
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
73
"module": "commonjs",
8-
// "lib": [], /* Specify library files to be included in the compilation. */
9-
// "allowJs": true, /* Allow javascript files to be compiled. */
10-
// "checkJs": true, /* Report errors in .js files. */
11-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12-
/* Generates corresponding '.d.ts' file. */
13-
"declaration": true,
14-
/* Generates a sourcemap for each corresponding '.d.ts' file. */
15-
"declarationMap": true,
16-
/* Generates corresponding '.map' file. */
4+
"target": "es2018",
5+
"lib": ["esnext"],
176
"sourceMap": true,
18-
// "outFile": "./", /* Concatenate and emit output to single file. */
19-
/* Redirect output structure to the directory. */
20-
"outDir": "./dist",
21-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
22-
// "composite": true, /* Enable project compilation */
23-
// "removeComments": true, /* Do not emit comments to output. */
24-
// "noEmit": true, /* Do not emit outputs. */
25-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
26-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
27-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
28-
29-
/* Strict Type-Checking Options */
30-
/* Enable all strict type-checking options. */
31-
"strict": true,
32-
/* Raise error on expressions and declarations with an implied 'any' type. */
7+
"moduleResolution": "node",
8+
"rootDir": "lib",
9+
"forceConsistentCasingInFileNames": true,
10+
"noImplicitReturns": true,
11+
"noImplicitThis": true,
3312
"noImplicitAny": true,
34-
/* Enable strict null checks. */
13+
"esModuleInterop": true,
3514
"strictNullChecks": true,
36-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
37-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
38-
// "noImplicitThis": false, /* Raise error on 'this' expressions with an implied 'any' type. */
39-
/* Parse in strict mode and emit "use strict" for each source file. */
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true,
17+
"strict": true,
18+
"declaration": true,
19+
"declarationMap": true,
20+
"outDir": "./dist",
4021
"alwaysStrict": true,
41-
42-
/* Additional Checks */
43-
// "noUnusedLocals": true, /* Report errors on unused locals. */
44-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
45-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
46-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
47-
48-
/* Module Resolution Options */
49-
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
50-
"moduleResolution": "node",
51-
/* Base directory to resolve non-absolute module names. */
5222
"baseUrl": ".",
53-
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
5423
"paths": {
5524
"string-length": ["types/string-length"]
5625
},
57-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
58-
/* List of folders to include type definitions from. */
5926
"typeRoots": [
6027
"./node_modules/@types",
6128
"./types"
6229
],
63-
// "types": [], /* Type declaration files to be included in compilation. */
64-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
65-
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
66-
"esModuleInterop": true,
67-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
68-
69-
/* Source Map Options */
70-
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
71-
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
72-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
73-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
74-
75-
/* Experimental Options */
76-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
77-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
7830
},
7931
"include": [
8032
"lib/**/*.ts"

tslint.json

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,96 @@
11
{
2-
"defaultSeverity": "warning",
32
"extends": [
4-
"tslint:recommended"
3+
"tslint:recommended",
4+
"tslint-eslint-rules",
5+
"tslint-config-prettier"
56
],
6-
"linterOptions": {
7-
"exclude": [
8-
"node_modules/**"
9-
]
10-
},
117
"rules": {
8+
"interface-name": false,
9+
"semicolon": true,
10+
"object-literal-sort-keys": false,
11+
"no-console": {
12+
"severity": "warn"
13+
},
14+
"ordered-imports": {
15+
"severity": "warn"
16+
},
17+
"indent": [
18+
true,
19+
"spaces",
20+
2
21+
],
22+
"trailing-comma": [
23+
true,
24+
{
25+
"multiline": "always"
26+
}
27+
],
28+
"whitespace": [
29+
true,
30+
"check-branch",
31+
"check-decl",
32+
"check-operator",
33+
"check-module",
34+
"check-separator",
35+
"check-rest-spread",
36+
"check-type",
37+
"check-typecase",
38+
"check-type-operator",
39+
"check-preblock"
40+
],
1241
"quotemark": [
1342
true,
1443
"single"
1544
],
16-
"indent": [
45+
"no-return-await": true,
46+
"no-unnecessary-type-assertion": true,
47+
"await-promise": true,
48+
"ban-comma-operator": true,
49+
"no-floating-promises": true,
50+
"no-void-expression": [
1751
true,
18-
"spaces",
19-
2
52+
"ignore-arrow-function-shorthand"
2053
],
21-
"interface-name": false,
22-
"ordered-imports": false,
23-
"object-literal-sort-keys": false,
24-
"no-consecutive-blank-lines": false,
25-
"trailing-comma": false,
26-
"arrow-parens": false,
27-
"no-unused-expression": [
54+
"prefer-object-spread": true,
55+
"eofline": true,
56+
"linebreak-style": [
57+
true,
58+
"LF"
59+
],
60+
"no-irregular-whitespace": true,
61+
"one-line": [
62+
true,
63+
"check-catch",
64+
"check-finally",
65+
"check-else",
66+
"check-open-brace",
67+
"check-whitespace"
68+
],
69+
"prefer-template": true,
70+
"return-undefined": true,
71+
"no-inferrable-types": true,
72+
"member-access": [
2873
true,
29-
"allow-fast-null-checks"
74+
"check-accessor",
75+
"check-constructor",
76+
"check-parameter-property"
3077
],
31-
"no-return-await": true
78+
"no-trailing-whitespace": true,
79+
"space-within-parens": false,
80+
"space-before-function-paren": false,
81+
"object-curly-spacing": [
82+
true,
83+
"always"
84+
],
85+
"arrow-parens": [
86+
true,
87+
"ban-single-arg-parens"
88+
],
89+
"max-classes-per-file": false
90+
},
91+
"linterOptions": {
92+
"exclude": [
93+
"node_modules/**/*.ts"
94+
]
3295
}
3396
}

0 commit comments

Comments
 (0)