Skip to content

Commit 18dd9e8

Browse files
committed
build: use prettier to format the code
1 parent 921eaa0 commit 18dd9e8

39 files changed

+196
-248
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages/*/lib
2+
packages/*/lib6
3+
packages/*/api-docs

.prettierrc

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

.vscode/settings.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"editor.tabCompletion": true,
44
"editor.tabSize": 2,
55
"editor.trimAutoWhitespace": true,
6+
"editor.formatOnSave": true,
7+
68
"files.exclude": {
79
"**/.DS_Store": true,
810
"**/.git": true,
@@ -19,10 +21,6 @@
1921
"files.trimTrailingWhitespace": true,
2022

2123
"prettier.eslintIntegration": true,
22-
"prettier.bracketSpacing": false,
23-
"prettier.singleQuote": true,
24-
"prettier.printWidth": 80,
25-
"prettier.trailingComma": "all",
2624

2725
"tslint.ignoreDefinitionFiles": true,
2826
"typescript.tsdk": "./node_modules/typescript/lib"

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
},
1111
"license": "MIT",
1212
"devDependencies": {
13+
"@commitlint/cli": "^3.2.0",
14+
"@commitlint/config-angular": "^3.1.1",
15+
"@commitlint/config-lerna-scopes": "^3.1.1",
1316
"@types/mocha": "^2.2.42",
1417
"@types/node": "^8.0.27",
1518
"@types/request": "^2.0.3",
1619
"@types/request-promise": "^4.1.37",
17-
"@commitlint/cli": "^3.2.0",
18-
"@commitlint/config-angular": "^3.1.1",
19-
"@commitlint/config-lerna-scopes": "^3.1.1",
2020
"coveralls": "^2.13.1",
21-
"lerna": "^2.1.2",
2221
"cz-conventional-changelog": "^2.0.0",
22+
"lerna": "^2.1.2",
2323
"mocha": "^3.4.0",
2424
"nyc": "^11.2.1",
25+
"prettier": "^1.7.3",
2526
"request": "^2.79.0",
2627
"request-promise": "^4.1.1",
2728
"strong-docs": "^1.4.0",
@@ -34,8 +35,13 @@
3435
"coverage:ci": "nyc report --reporter=text-lcov | coveralls",
3536
"precoverage": "npm test",
3637
"coverage": "open coverage/index.html",
37-
"lint": "tslint -c tslint.full.json --project tsconfig.json --type-check",
38-
"lint:fix": "npm run lint -- --fix",
38+
"lint": "npm run prettier:check && npm run tslint",
39+
"lint:fix": "npm run prettier:fix && npm run tslint:fix",
40+
"tslint": "tslint -c tslint.full.json --project tsconfig.json --type-check",
41+
"tslint:fix": "npm run tslint -- --fix",
42+
"prettier:cli": "prettier \"**/*.ts\"",
43+
"prettier:check": "npm run prettier:cli -- -l",
44+
"prettier:fix": "npm run prettier:cli -- --write",
3945
"clean": "lerna run --loglevel=silent clean",
4046
"build": "lerna run --loglevel=silent build",
4147
"build:current": "lerna run --loglevel=silent build:current",

packages/authentication/test/unit/authenticate-action.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ describe('AuthenticationProvider', () => {
4040
const authenticate: AuthenticateFn = await Promise.resolve(
4141
provider.value(),
4242
);
43-
const request = <ParsedRequest> {};
43+
const request = <ParsedRequest>{};
4444
const user = await authenticate(request);
4545
expect(user).to.be.equal(mockUser);
4646
});
4747

4848
it('updates current user', async () => {
4949
const authenticate = await Promise.resolve(provider.value());
50-
const request = <ParsedRequest> {};
50+
const request = <ParsedRequest>{};
5151
await authenticate(request);
5252
expect(currentUser).to.equal(mockUser);
5353
});
@@ -59,7 +59,7 @@ describe('AuthenticationProvider', () => {
5959
context
6060
.bind(AuthenticationBindings.AUTH_ACTION)
6161
.toProvider(AuthenticationProvider);
62-
const request = <ParsedRequest> {};
62+
const request = <ParsedRequest>{};
6363
const authenticate = await context.get(
6464
AuthenticationBindings.AUTH_ACTION,
6565
);
@@ -76,7 +76,7 @@ describe('AuthenticationProvider', () => {
7676
const authenticate = await context.get(
7777
AuthenticationBindings.AUTH_ACTION,
7878
);
79-
const request = <ParsedRequest> {};
79+
const request = <ParsedRequest>{};
8080
let error;
8181
try {
8282
await authenticate(request);
@@ -95,7 +95,7 @@ describe('AuthenticationProvider', () => {
9595
const authenticate = await context.get(
9696
AuthenticationBindings.AUTH_ACTION,
9797
);
98-
const request = <ParsedRequest> {};
98+
const request = <ParsedRequest>{};
9999
request.headers = {testState: 'fail'};
100100
let error;
101101
try {

packages/authentication/test/unit/authenticate-decorator.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {expect} from '@loopback/testlab';
7-
import {
8-
authenticate,
9-
getAuthenticateMetadata,
10-
} from '../..';
7+
import {authenticate, getAuthenticateMetadata} from '../..';
118

129
describe('Authentication', () => {
1310
describe('@authenticate decorator', () => {

packages/authentication/test/unit/strategy-adapter.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Strategy Adapter', () => {
2525
}
2626
const strategy = new Strategy();
2727
const adapter = new StrategyAdapter(strategy);
28-
const request = <ParsedRequest> {};
28+
const request = <ParsedRequest>{};
2929
await adapter.authenticate(request);
3030
expect(calledFlag).to.be.true();
3131
});
@@ -34,7 +34,7 @@ describe('Strategy Adapter', () => {
3434
const strategy = new MockStrategy();
3535
strategy.setMockUser(mockUser);
3636
const adapter = new StrategyAdapter(strategy);
37-
const request = <ParsedRequest> {};
37+
const request = <ParsedRequest>{};
3838
const user: Object = await adapter.authenticate(request);
3939
expect(user).to.be.eql(mockUser);
4040
});
@@ -43,7 +43,7 @@ describe('Strategy Adapter', () => {
4343
const strategy = new MockStrategy();
4444
strategy.setMockUser(mockUser);
4545
const adapter = new StrategyAdapter(strategy);
46-
const request = <ParsedRequest> {};
46+
const request = <ParsedRequest>{};
4747
request.headers = {testState: 'fail'};
4848
let error;
4949
try {
@@ -58,7 +58,7 @@ describe('Strategy Adapter', () => {
5858
const strategy = new MockStrategy();
5959
strategy.setMockUser(mockUser);
6060
const adapter = new StrategyAdapter(strategy);
61-
const request = <ParsedRequest> {};
61+
const request = <ParsedRequest>{};
6262
request.headers = {testState: 'error'};
6363
let error;
6464
try {

packages/context/src/binding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class Binding {
120120

121121
return {
122122
key: keyWithPath.substr(0, index).trim(),
123-
path: keyWithPath.substr(index+1),
123+
path: keyWithPath.substr(index + 1),
124124
};
125125
}
126126

packages/context/src/is-promise.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
*
1010
* @param value The value to check.
1111
*/
12-
export function isPromise<T>(value: T | PromiseLike<T>):
13-
value is PromiseLike<T> {
12+
export function isPromise<T>(
13+
value: T | PromiseLike<T>,
14+
): value is PromiseLike<T> {
1415
if (!value) return false;
1516
if (typeof value !== 'object' && typeof value !== 'function') return false;
1617
return typeof (value as PromiseLike<T>).then === 'function';

packages/context/src/reflect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class NamespacedReflect {
161161
if (targetKey) {
162162
return Reflect.decorate(decorators, target, targetKey, descriptor);
163163
} else {
164-
return Reflect.decorate(<ClassDecorator[]> decorators, <Function> target);
164+
return Reflect.decorate(<ClassDecorator[]>decorators, <Function>target);
165165
}
166166
}
167167

0 commit comments

Comments
 (0)