Skip to content

Commit 8133cca

Browse files
committed
update code according to prettier rules
1 parent 491b134 commit 8133cca

25 files changed

+989
-620
lines changed

.eslintrc.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ module.exports = {
33
jest: true,
44
node: true,
55
},
6-
plugins: [
7-
'@typescript-eslint',
8-
'prettier',
9-
'import',
10-
'prefer-arrow',
11-
],
6+
plugins: ['@typescript-eslint', 'prettier', 'import', 'prefer-arrow'],
127
parser: '@typescript-eslint/parser',
138
parserOptions: {
149
ecmaVersion: '2017',
@@ -28,19 +23,19 @@ module.exports = {
2823
node: {},
2924
typescript: {
3025
directory: './tsconfig.eslint.json',
31-
}
32-
}
26+
},
27+
},
3328
},
34-
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
29+
ignorePatterns: ['*.d.ts', '*.generated.ts'],
3530
rules: {
3631
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
3732
'@typescript-eslint/no-require-imports': ['error'],
3833

34+
'@typescript-eslint/ban-ts-ignore': ['warn'],
35+
'@typescript-eslint/no-empty-function': ['warn'],
36+
3937
// Require all imported dependencies are actually declared in package.json
4038
'import/no-extraneous-dependencies': ['error'],
4139
'import/no-unresolved': ['error'],
42-
43-
'@typescript-eslint/ban-ts-ignore': ['warn'],
44-
'@typescript-eslint/no-empty-function': ['warn'],
45-
}
46-
}
40+
},
41+
};

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ jobs:
4747
ls -la
4848
printf "AWS::Foo::Bar\n1\nn" | cfn init -vv
4949
ls -la
50+
npm install --optional
51+
npm run build

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ repos:
7575
- id: jest-local
7676
name: jest-local
7777
description: Run jest in the local environment
78-
entry: npm run test:ci
78+
entry: npx jest --ci
7979
language: system
8080
# ignore all files, run on hard-coded modules instead
8181
pass_filenames: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pip3 install \
100100

101101
That ensures neither is accidentally installed from PyPI.
102102

103-
Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit after being installed (`pre-commit install`).
103+
Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit after being installed (`pre-commit install`). The continuous integration also runs these checks. Manual options are available so you don't have to commit:
104104

105105
```shell
106106
# run all hooks on all files, mirrors what the CI runs

jest.config.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
module.exports = {
2-
preset: 'ts-jest',
3-
testEnvironment: 'node',
4-
globals: {
5-
'ts-jest': {
6-
diagnostics: false, // Necessary to avoid typeschecking error in decorators
7-
}
8-
},
9-
testRegex: '\\.test.ts$',
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
globals: {
5+
'ts-jest': {
6+
diagnostics: false, // Necessary to avoid typeschecking error in decorators
7+
},
8+
},
9+
testRegex: '\\.test.ts$',
10+
coverageThreshold: {
11+
global: {
12+
branches: 80,
13+
statements: 90,
14+
},
15+
},
16+
collectCoverage: true,
17+
coverageReporters: ['lcov', 'html', 'text-summary'],
1018
};

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
"scripts": {
1414
"build": "npx tsc",
1515
"prepack": "npm run build",
16-
"postinstall": "npm run build",
17-
"lint": "npx eslint '**/*.ts'",
18-
"lint:fix": "npx eslint --fix '**/*.ts'",
16+
"lint": "npx eslint --ext .ts,.js .",
17+
"lint:fix": "npx eslint --fix --ext .ts,.js .",
1918
"test": "npx jest",
20-
"test:debug": "npx --node-arg=--inspect jest --runInBand",
21-
"test:ci": "npx jest --ci --collect-coverage"
19+
"test:debug": "npx --node-arg=--inspect jest --runInBand"
2220
},
2321
"engines": {
2422
"node": ">=10.0.0",

src/callback.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import CloudFormation from 'aws-sdk/clients/cloudformation';
44
import { SessionProxy } from './proxy';
55
import { BaseResourceModel, CfnResponse, OperationStatus } from './interface';
66

7-
87
const LOGGER = console;
98

109
interface ProgressOptions extends CfnResponse<BaseResourceModel> {
@@ -13,7 +12,6 @@ interface ProgressOptions extends CfnResponse<BaseResourceModel> {
1312
}
1413

1514
export async function reportProgress(options: ProgressOptions): Promise<void> {
16-
1715
const {
1816
session,
1917
bearerToken,
@@ -39,11 +37,16 @@ export async function reportProgress(options: ProgressOptions): Promise<void> {
3937
}
4038
if (currentOperationStatus) {
4139
request.CurrentOperationStatus = currentOperationStatus;
42-
const response: { [key: string]: any } = await client.recordHandlerProgress(request).promise();
40+
const response: { [key: string]: any } = await client
41+
.recordHandlerProgress(request)
42+
.promise();
4343
let requestId = '';
4444
if (response['ResponseMetadata']) {
4545
requestId = response.ResponseMetadata.RequestId;
4646
}
47-
LOGGER.debug(`Record Handler Progress with Request Id ${requestId} and Request:`, request);
47+
LOGGER.debug(
48+
`Record Handler Progress with Request Id ${requestId} and Request:`,
49+
request
50+
);
4851
}
4952
}

src/exceptions.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ export abstract class BaseHandlerException extends Error {
66

77
public errorCode: HandlerErrorCode;
88

9-
public constructor(message? : any, errorCode? : HandlerErrorCode) {
9+
public constructor(message?: any, errorCode?: HandlerErrorCode) {
1010
super(message);
11-
this.errorCode = errorCode || HandlerErrorCode[this.constructor.name as HandlerErrorCode];
11+
this.errorCode =
12+
errorCode || HandlerErrorCode[this.constructor.name as HandlerErrorCode];
1213
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
1314
}
1415

@@ -28,16 +29,16 @@ export class InvalidCredentials extends BaseHandlerException {}
2829
export class AlreadyExists extends BaseHandlerException {
2930
constructor(typeName: string, identifier: string) {
3031
super(
31-
`Resource of type '${typeName}' with identifier '${identifier}' already exists.`,
32-
)
32+
`Resource of type '${typeName}' with identifier '${identifier}' already exists.`
33+
);
3334
}
3435
}
3536

3637
export class NotFound extends BaseHandlerException {
3738
constructor(typeName: string, identifier: string) {
3839
super(
39-
`Resource of type '${typeName}' with identifier '${identifier}' was not found.`,
40-
)
40+
`Resource of type '${typeName}' with identifier '${identifier}' was not found.`
41+
);
4142
}
4243
}
4344

src/interface.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
} from 'aws-sdk/clients/cloudformation';
66
import { allArgsConstructor, builder } from 'tombok';
77

8-
98
export type Optional<T> = T | undefined | null;
109

1110
export interface Callable<R extends Array<any>, T> {
@@ -75,7 +74,9 @@ export class BaseResourceModel {
7574
protected static readonly TYPE_NAME?: string;
7675

7776
constructor(...args: any[]) {}
78-
public static builder(): any {return null}
77+
public static builder(): any {
78+
return null;
79+
}
7980

8081
public getTypeName(): string {
8182
return Object.getPrototypeOf(this).constructor.TYPE_NAME;

0 commit comments

Comments
 (0)