Skip to content

Commit efd8809

Browse files
committed
running prettier over all of the files so we have a good baseline. Also found a way to use a better version of yarn in CodeShip. Also found another tslint rule (align) that was a duplicate of prettier functionality.
1 parent 7b52274 commit efd8809

File tree

98 files changed

+4578
-3761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+4578
-3761
lines changed

.prettierrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "all",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"printWidth": 200
7+
}

circle.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
machine:
22
pre:
33
- mkdir ~/.yarn-cache
4+
- npm update -g [email protected]
45
node:
56
version: 7.9
67
environment:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"copy-types": "copyfiles -u 1 ./src/*.d.ts ./dist",
3434
"copy-templates": "copyfiles -u 1 ./src/routeGeneration/templates/**/* ./dist",
3535
"clean": "rimraf dist && rimraf tests/fixtures/*/routes.ts",
36-
"lint": "tslint --exclude ./node_modules/** ./src/**/*.ts ./tests/**/*.ts",
36+
"lint": "tslint ./src/**/*.ts ./tests/**/*.ts",
3737
"format": "tsfmt -r",
3838
"prepare": "yarn build",
3939
"deploy": "yarn version patch -m \"Release v%s\" && yarn publish",

src/cli.ts

+45-26
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,46 @@ const validateCompilerOptions = (config?: ts.CompilerOptions): ts.CompilerOption
6161
};
6262

6363
export const validateSwaggerConfig = async (config: SwaggerConfig): Promise<SwaggerConfig> => {
64-
if (!config.outputDirectory) { throw new Error('Missing outputDirectory: configuration must contain output directory.'); }
65-
if (!config.entryFile) { throw new Error('Missing entryFile: Configuration must contain an entry point file.'); }
66-
if (!await fsExists(config.entryFile)) {
64+
if (!config.outputDirectory) {
65+
throw new Error('Missing outputDirectory: configuration must contain output directory.');
66+
}
67+
if (!config.entryFile) {
68+
throw new Error('Missing entryFile: Configuration must contain an entry point file.');
69+
}
70+
if (!(await fsExists(config.entryFile))) {
6771
throw new Error(`EntryFile not found: ${config.entryFile} - Please check your tsoa config.`);
6872
}
69-
config.version = config.version || await versionDefault();
73+
config.version = config.version || (await versionDefault());
7074

7175
config.specVersion = config.specVersion || 2;
72-
if (config.specVersion !== 2 && config.specVersion !== 3) { throw new Error('Unsupported Spec version.'); }
76+
if (config.specVersion !== 2 && config.specVersion !== 3) {
77+
throw new Error('Unsupported Spec version.');
78+
}
7379

74-
config.name = config.name || await nameDefault();
75-
config.description = config.description || await descriptionDefault();
76-
config.license = config.license || await licenseDefault();
80+
config.name = config.name || (await nameDefault());
81+
config.description = config.description || (await descriptionDefault());
82+
config.license = config.license || (await licenseDefault());
7783
config.basePath = config.basePath || '/';
7884

7985
return config;
8086
};
8187

8288
const validateRoutesConfig = async (config: RoutesConfig): Promise<RoutesConfig> => {
83-
if (!config.entryFile) { throw new Error('Missing entryFile: Configuration must contain an entry point file.'); }
84-
if (!await fsExists(config.entryFile)) {
89+
if (!config.entryFile) {
90+
throw new Error('Missing entryFile: Configuration must contain an entry point file.');
91+
}
92+
if (!(await fsExists(config.entryFile))) {
8593
throw new Error(`EntryFile not found: ${config.entryFile} - Please check your tsoa config.`);
8694
}
87-
if (!config.routesDir) { throw new Error('Missing routesDir: Configuration must contain a routes file output directory.'); }
95+
if (!config.routesDir) {
96+
throw new Error('Missing routesDir: Configuration must contain a routes file output directory.');
97+
}
8898

89-
if (config.authenticationModule && !(await fsExists(config.authenticationModule) || await fsExists(config.authenticationModule + '.ts'))) {
99+
if (config.authenticationModule && !((await fsExists(config.authenticationModule)) || (await fsExists(config.authenticationModule + '.ts')))) {
90100
throw new Error(`No authenticationModule file found at '${config.authenticationModule}'`);
91101
}
92102

93-
if (config.iocModule && !(await fsExists(config.iocModule) || await fsExists(config.iocModule + '.ts'))) {
103+
if (config.iocModule && !((await fsExists(config.iocModule)) || (await fsExists(config.iocModule + '.ts')))) {
94104
throw new Error(`No iocModule file found at '${config.iocModule}'`);
95105
}
96106

@@ -134,20 +144,29 @@ const jsonArgs: yargs.Options = {
134144
yargs
135145
.usage('Usage: $0 <command> [options]')
136146
.demand(1)
137-
.command('swagger', 'Generate swagger spec', {
138-
basePath: basePathArgs,
139-
configuration: configurationArgs,
140-
host: hostArgs,
141-
json: jsonArgs,
142-
yaml: yarmlArgs,
143-
}, swaggerSpecGenerator)
144-
.command('routes', 'Generate routes', {
145-
basePath: basePathArgs,
146-
configuration: configurationArgs,
147-
}, routeGenerator)
147+
.command(
148+
'swagger',
149+
'Generate swagger spec',
150+
{
151+
basePath: basePathArgs,
152+
configuration: configurationArgs,
153+
host: hostArgs,
154+
json: jsonArgs,
155+
yaml: yarmlArgs,
156+
},
157+
swaggerSpecGenerator,
158+
)
159+
.command(
160+
'routes',
161+
'Generate routes',
162+
{
163+
basePath: basePathArgs,
164+
configuration: configurationArgs,
165+
},
166+
routeGenerator,
167+
)
148168
.help('help')
149-
.alias('help', 'h')
150-
.argv;
169+
.alias('help', 'h').argv;
151170

152171
async function swaggerSpecGenerator(args) {
153172
try {

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export interface SwaggerConfig {
108108
* and only serves to provide the relevant details for each scheme.
109109
*/
110110
securityDefinitions?: {
111-
[name: string]: Swagger.Security,
111+
[name: string]: Swagger.Security;
112112
};
113113

114114
/**

src/decorators/customAttribute.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// tslint:disable-next-line:variable-name
22
export function CustomAttribute(_name: string, _value: string): Function {
3-
return () => { return; };
3+
return () => {
4+
return;
5+
};
46
}

src/decorators/example.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export function Example<T>(exampleModel: T): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}

src/decorators/methods.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
export function Get(value?: string): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}
46

57
export function Post(value?: string): Function {
6-
return () => { return; };
8+
return () => {
9+
return;
10+
};
711
}
812

913
export function Put(value?: string): Function {
10-
return () => { return; };
14+
return () => {
15+
return;
16+
};
1117
}
1218

1319
export function Patch(value?: string): Function {
14-
return () => { return; };
20+
return () => {
21+
return;
22+
};
1523
}
1624

1725
export function Delete(value?: string): Function {
18-
return () => { return; };
26+
return () => {
27+
return;
28+
};
1929
}
2030

2131
export function Head(value?: string): Function {
22-
return () => { return; };
32+
return () => {
33+
return;
34+
};
2335
}

src/decorators/operationid.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export function OperationId(value: string): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}

src/decorators/parameter.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* @param {string} [name] properties name in body object
44
*/
55
export function Body(): Function {
6-
return () => { return; };
6+
return () => {
7+
return;
8+
};
79
}
810

911
/**
@@ -12,14 +14,18 @@ export function Body(): Function {
1214
* @param {string} [name] The name of the body parameter
1315
*/
1416
export function BodyProp(name?: string): Function {
15-
return () => { return; };
17+
return () => {
18+
return;
19+
};
1620
}
1721

1822
/**
1923
* Inject http request
2024
*/
2125
export function Request(): Function {
22-
return () => { return; };
26+
return () => {
27+
return;
28+
};
2329
}
2430

2531
/**
@@ -28,7 +34,9 @@ export function Request(): Function {
2834
* @param {string} [name] The name of the path parameter
2935
*/
3036
export function Path(name?: string): Function {
31-
return () => { return; };
37+
return () => {
38+
return;
39+
};
3240
}
3341

3442
/**
@@ -37,7 +45,9 @@ export function Path(name?: string): Function {
3745
* @param {string} [name] The name of the query parameter
3846
*/
3947
export function Query(name?: string): Function {
40-
return () => { return; };
48+
return () => {
49+
return;
50+
};
4151
}
4252

4353
/**
@@ -46,5 +56,7 @@ export function Query(name?: string): Function {
4656
* @param {string} [name] The name of the header parameter
4757
*/
4858
export function Header(name?: string): Function {
49-
return () => { return; };
59+
return () => {
60+
return;
61+
};
5062
}

src/decorators/response.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
export function SuccessResponse(name: string | number, description?: string): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}
46

57
export function Response<T>(name: string | number, description?: string, example?: T): Function {
6-
return () => { return; };
8+
return () => {
9+
return;
10+
};
711
}

src/decorators/route.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
export function Route(name?: string): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}
46

57
/**
68
* can be used to entirely hide an method from documentation
79
*/
810
export function Hidden(): Function {
9-
return () => { return; };
11+
return () => {
12+
return;
13+
};
1014
}

src/decorators/security.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
* @param {name} security name from securityDefinitions
33
*/
44
export function Security(name: string | { [name: string]: string[] }, scopes?: string[]): Function {
5-
return () => { return; };
5+
return () => {
6+
return;
7+
};
68
}

src/decorators/tags.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export function Tags(...values: string[]): Function {
2-
return () => { return; };
2+
return () => {
3+
return;
4+
};
35
}

src/interfaces/controller.ts

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
21
export class Controller {
3-
private statusCode?: number = undefined;
4-
private headers = {} as { [name: string]: string | undefined };
2+
private statusCode?: number = undefined;
3+
private headers = {} as { [name: string]: string | undefined };
54

6-
public setStatus(statusCode: number) {
7-
this.statusCode = statusCode;
8-
}
5+
public setStatus(statusCode: number) {
6+
this.statusCode = statusCode;
7+
}
98

10-
public getStatus() {
11-
return this.statusCode;
12-
}
9+
public getStatus() {
10+
return this.statusCode;
11+
}
1312

14-
public setHeader(name: string, value?: string) {
15-
this.headers[name] = value;
16-
}
13+
public setHeader(name: string, value?: string) {
14+
this.headers[name] = value;
15+
}
1716

18-
public getHeader(name: string) {
19-
return this.headers[name];
20-
}
17+
public getHeader(name: string) {
18+
return this.headers[name];
19+
}
2120

22-
public getHeaders() {
23-
return this.headers;
24-
}
21+
public getHeaders() {
22+
return this.headers;
23+
}
2524
}

0 commit comments

Comments
 (0)