Skip to content

Commit 59cbb5f

Browse files
committed
Add prettier
1 parent 6906f73 commit 59cbb5f

13 files changed

+86
-86
lines changed

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
coverage
3+
dist
4+
es
5+
lib

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120
5+
}

.vscode/launch.json

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
{
22
"version": "0.2.0",
3-
"configurations": [{
4-
"name": "Debug",
5-
"type": "node",
6-
"request": "launch",
7-
"protocol": "inspector",
8-
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
9-
"args": [
10-
"--env=jsdom",
11-
"--no-cache",
12-
"--runInBand",
13-
"--findRelatedTests",
14-
"${file}"
15-
],
16-
"skipFiles": [
17-
"<node_internals>/**/*.js"
18-
]
19-
}]
3+
"configurations": [
4+
{
5+
"name": "Debug",
6+
"type": "node",
7+
"request": "launch",
8+
"protocol": "inspector",
9+
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
10+
"args": ["--env=jsdom", "--no-cache", "--runInBand", "--findRelatedTests", "${file}"],
11+
"skipFiles": ["<node_internals>/**/*.js"]
12+
}
13+
]
2014
}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## 0.1.0
44

5-
* First release
5+
- First release

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
Opinionated boilerplate for TypeScript 2.0 libraries.
1111

12-
1312
## Features
1413

15-
* [TypeScript 2.0](http://www.typescriptlang.org)
16-
* Code quality with [tslint](http://palantir.github.io/tslint/)
17-
* Module bundling with [Rollup](http://rollupjs.org)
18-
* Unit testing with [Jest](https://github.com/facebook/jest)
19-
* Continuous integration with [Travis](https://travis-ci.org)
14+
- [TypeScript 2.0](http://www.typescriptlang.org)
15+
- Code quality with [tslint](http://palantir.github.io/tslint/)
16+
- Module bundling with [Rollup](http://rollupjs.org)
17+
- Unit testing with [Jest](https://github.com/facebook/jest)
18+
- Continuous integration with [Travis](https://travis-ci.org)

jest.config.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function getSupportedTypescriptTarget() {
44
var nodeVersion = process.versions.node;
55

66
if (semver.gt(nodeVersion, '7.6.0')) {
7-
return 'es2017'
7+
return 'es2017';
88
} else if (semver.gt(nodeVersion, '7.0.0')) {
99
return 'es2016';
1010
} else if (semver.gt(nodeVersion, '6.0.0')) {
@@ -18,28 +18,20 @@ function getSupportedTypescriptTarget() {
1818

1919
module.exports = {
2020
transform: {
21-
'.(tsx?)': '<rootDir>/node_modules/ts-jest/preprocessor.js'
21+
'.(tsx?)': '<rootDir>/node_modules/ts-jest/preprocessor.js',
2222
},
23-
testMatch: [
24-
'**/__tests__/**/*.{t,j}s?(x)',
25-
'**/?(*.)(spec|test).{t,j}s?(x)'
26-
],
27-
testPathIgnorePatterns: [
28-
'<rootDir>/(node_modules|lib|es|dist)'
29-
],
30-
collectCoverageFrom: [
31-
'src/**/*.{t,j}s?(x)',
32-
'!src/**/*.d.ts',
33-
],
23+
testMatch: ['**/__tests__/**/*.{t,j}s?(x)', '**/?(*.)(spec|test).{t,j}s?(x)'],
24+
testPathIgnorePatterns: ['<rootDir>/(node_modules|lib|es|dist)'],
25+
collectCoverageFrom: ['src/**/*.{t,j}s?(x)', '!src/**/*.d.ts'],
3426
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
3527
mapCoverage: true,
3628
globals: {
37-
"ts-jest": {
29+
'ts-jest': {
3830
skipBabel: true,
3931
tsConfigFile: {
4032
target: getSupportedTypescriptTarget(),
4133
module: 'commonjs',
42-
}
43-
}
44-
}
34+
},
35+
},
36+
},
4537
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"clean": "rimraf dist es lib coverage",
1818
"typecheck": "tsc --noEmit",
1919
"lint": "tslint --project tsconfig.json --type-check --format stylish",
20+
"format": "prettier '**/*.{md,js,jsx,json,ts,tsx}' --write",
2021
"test": "jest --env=jsdom --coverage",
2122
"test:watch": "jest --env=jsdom --watch --updateSnapshot",
2223
"prepublishOnly": "npm run build",
@@ -46,6 +47,7 @@
4647
"dts-bundle": "^0.7.2",
4748
"jest": "^20.0.0",
4849
"pascal-case": "^2.0.1",
50+
"prettier": "^1.13.7",
4951
"rimraf": "^2.6.1",
5052
"rollup": "^0.62.0",
5153
"rollup-plugin-commonjs": "^9.1.0",
@@ -56,7 +58,9 @@
5658
"rollup-plugin-terser": "^1.0.1",
5759
"semver": "^5.4.0",
5860
"ts-jest": "^20.0.0",
59-
"tslint": "^5.6.0",
61+
"tslint": "^5.10.0",
62+
"tslint-config-prettier": "^1.13.0",
63+
"tslint-plugin-prettier": "^1.3.0",
6064
"typescript": "^2.4.0"
6165
}
6266
}

rollup.config.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ export default {
1616
exports: 'named',
1717
sourcemap: true,
1818
amd: {
19-
id: pkg.name
20-
}
19+
id: pkg.name,
20+
},
2121
},
22-
plugins: [
23-
sourcemaps(),
24-
nodeResolve(),
25-
nodeGlobals(),
26-
nodeBuiltins(),
27-
commonjs(),
28-
terser()
29-
]
22+
plugins: [sourcemaps(), nodeResolve(), nodeGlobals(), nodeBuiltins(), commonjs(), terser()],
3023
};

src/declarations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Declare stuff here
22

3-
declare module "some-module" {
3+
declare module 'some-module' {
44
export function doStuff(): void;
55
}

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { sleep } from './utils';
2+
13
export * from './utils';
24

35
export class HelloWorld {
@@ -12,9 +14,7 @@ export class HelloWorld {
1214
}
1315
}
1416

15-
const pause = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms));
16-
1717
export async function doSomethingAsync() {
18-
await pause(250);
18+
await sleep(250);
1919
return 'hello';
2020
}

src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
export function add(a: number, b: number) {
22
return a + b;
33
}
4+
5+
export function sleep(ms: number) {
6+
return new Promise<void>(resolve => {
7+
setTimeout(resolve, ms);
8+
});
9+
}

tsconfig.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,5 @@
1515
"noUnusedLocals": true,
1616
"strictNullChecks": true
1717
},
18-
"exclude": [
19-
"node_modules",
20-
"dist",
21-
"es",
22-
"lib"
23-
]
18+
"exclude": ["node_modules", "dist", "es", "lib"]
2419
}

tslint.json

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
{
2-
"extends": ["tslint:recommended"],
2+
"extends": ["tslint:recommended", "tslint-config-prettier", "tslint-plugin-prettier"],
33
"rules": {
4-
"arrow-parens": false,
54
"arrow-return-shorthand": [true],
6-
"import-spacing": true,
5+
"class-name": true,
6+
"encoding": true,
77
"interface-name": [false],
8-
"interface-over-type-literal": false,
9-
"linebreak-style": [true, "LF"],
10-
"max-classes-per-file": [false],
11-
"member-access": [false],
12-
"no-require-imports": true,
8+
"interface-over-type-literal": true,
9+
"max-classes-per-file": false,
10+
"member-access": [true, "no-public"],
11+
"no-bitwise": false,
12+
"no-boolean-literal-compare": true,
13+
"no-duplicate-imports": true,
14+
"no-empty-interface": false,
15+
"no-for-in-array": true,
16+
"no-inferrable-types": true,
17+
"no-invalid-template-strings": true,
18+
"no-return-await": true,
19+
"no-string-throw": true,
20+
"no-var-keyword": true,
1321
"object-literal-sort-keys": false,
14-
"ordered-imports": [false],
15-
"prefer-const": true,
16-
"quotemark": [true, "single", "jsx-double"],
17-
"space-before-function-paren": [true, {
18-
"anonymous": "always",
19-
"asyncArrow": "always",
20-
"constructor": "never",
21-
"method": "never",
22-
"named": "never"
23-
}],
24-
"variable-name": [
22+
"ordered-imports": [
2523
true,
26-
"ban-keywords",
27-
"check-format",
28-
"allow-pascal-case",
29-
"allow-leading-underscore"
30-
]
24+
{
25+
"grouped-imports": true,
26+
"named-imports-order": "lowercase-last"
27+
}
28+
],
29+
"prefer-const": true,
30+
"prefer-for-of": false,
31+
"prefer-function-over-method": true,
32+
"prefer-object-spread": true,
33+
"prefer-readonly": true,
34+
"prefer-template": true,
35+
"prettier": true,
36+
"switch-default": true,
37+
"variable-name": [true, "allow-leading-underscore", "ban-keywords", "check-format", "allow-pascal-case"]
3138
}
3239
}

0 commit comments

Comments
 (0)