refactor(): update to the latest version of prettier

This commit is contained in:
Kamil Myśliwiec
2020-03-22 12:10:49 +01:00
parent 3dae6178b7
commit 0e5b402a6f
32 changed files with 70 additions and 150 deletions

View File

@@ -1,4 +1,5 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "all"
}

View File

@@ -18,25 +18,19 @@ describe('Error messages', () => {
});
it(`/GET`, () => {
return request(server)
.get('/sync')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
return request(server).get('/sync').expect(HttpStatus.BAD_REQUEST).expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
});
it(`/GET (Promise/async)`, () => {
return request(server)
.get('/async')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
return request(server).get('/async').expect(HttpStatus.BAD_REQUEST).expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
});
afterEach(async () => {

View File

@@ -78,16 +78,11 @@ describe('Exclude middleware (fastify)', () => {
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
await app.init();
await app
.getHttpAdapter()
.getInstance()
.ready();
await app.getHttpAdapter().getInstance().ready();
});
it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
});
it(`should not exclude "/test2" endpoint`, () => {

View File

@@ -77,9 +77,7 @@ describe('Exclude middleware', () => {
});
it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
});
it(`should not exclude "/test2" endpoint`, () => {

View File

@@ -20,10 +20,7 @@ describe('Hello world (express instance)', () => {
});
it(`/GET`, () => {
return request(server)
.get('/hello')
.expect(200)
.expect('Hello world!');
return request(server).get('/hello').expect(200).expect('Hello world!');
});
it(`/GET (Promise/async)`, () => {
@@ -41,14 +38,11 @@ describe('Hello world (express instance)', () => {
});
it(`/GET { host: ":tenant.example.com" } not matched`, () => {
return request(server)
.get('/host')
.expect(404)
.expect({
statusCode: 404,
error: 'Not Found',
message: 'Cannot GET /host',
});
return request(server).get('/host').expect(404).expect({
statusCode: 404,
error: 'Not Found',
message: 'Cannot GET /host',
});
});
afterEach(async () => {

View File

@@ -29,10 +29,7 @@ describe('Hello world (express instance with multiple applications)', () => {
});
it(`/GET`, () => {
return request(server)
.get('/hello')
.expect(200)
.expect('Hello world!');
return request(server).get('/hello').expect(200).expect('Hello world!');
});
it(`/GET (app2)`, () => {

View File

@@ -37,8 +37,6 @@ describe('Guards', () => {
app = (await createTestModule(new AuthGuard())).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello')
.expect(401);
return request(app.getHttpServer()).get('/hello').expect(401);
});
});

View File

@@ -77,9 +77,7 @@ describe('Interceptors', () => {
).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});
it(`should map response`, async () => {

View File

@@ -18,12 +18,9 @@ describe('Hello world (default adapter)', () => {
});
it(`host=example.com should execute locally injected pipe by HelloController`, () => {
return request(server)
.get('/hello/local-pipe/1')
.expect(200)
.expect({
id: '1',
});
return request(server).get('/hello/local-pipe/1').expect(200).expect({
id: '1',
});
});
it(`host=host.example.com should execute locally injected pipe by HostController`, () => {
@@ -39,14 +36,11 @@ describe('Hello world (default adapter)', () => {
});
it(`should return 404 for mismatched host`, () => {
return request(server)
.get('/host/local-pipe/1')
.expect(404)
.expect({
error: 'Not Found',
message: 'Cannot GET /host/local-pipe/1',
statusCode: 404,
});
return request(server).get('/host/local-pipe/1').expect(404).expect({
error: 'Not Found',
message: 'Cannot GET /host/local-pipe/1',
statusCode: 404,
});
});
afterEach(async () => {

View File

@@ -51,9 +51,7 @@ describe('Middleware (class)', () => {
});
it(`forRoutes(*)`, () => {
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});
afterEach(async () => {

View File

@@ -57,15 +57,11 @@ describe('Middleware', () => {
});
it(`forRoutes(*)`, () => {
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});
it(`forRoutes(TestController)`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, SCOPED_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, SCOPED_VALUE);
});
it(`forRoutes(tests/*)`, () => {

View File

@@ -33,9 +33,7 @@ describe('MQTT transport', () => {
});
it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});
afterEach(async () => {

View File

@@ -33,9 +33,7 @@ describe('NATS transport', () => {
});
it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});
afterEach(async () => {

View File

@@ -33,9 +33,7 @@ describe('REDIS transport', () => {
});
it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});
afterEach(async () => {

View File

@@ -129,11 +129,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
@@ -165,11 +161,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});

View File

@@ -63,11 +63,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
@@ -89,11 +85,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});

View File

@@ -106,17 +106,11 @@ describe('Kafka transport', () => {
user: newUser,
};
it(`/POST (sync command create user)`, () => {
return request(server)
.post('/user')
.send(userDto)
.expect(200);
return request(server).post('/user').send(userDto).expect(200);
});
it(`/POST (sync command create business`, () => {
return request(server)
.post('/business')
.send(businessDto)
.expect(200);
return request(server).post('/business').send(businessDto).expect(200);
});
it(`/POST (sync command create user) Concurrency Test`, async () => {
@@ -124,12 +118,7 @@ describe('Kafka transport', () => {
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
const innerUserDto = JSON.parse(JSON.stringify(userDto));
innerUserDto.name += `+${concurrencyKey}`;
promises.push(
request(server)
.post('/user')
.send(userDto)
.expect(200),
);
promises.push(request(server).post('/user').send(userDto).expect(200));
}
await Promise.all(promises);
});

View File

@@ -49,7 +49,7 @@ describe('MQTT transport', () => {
.expect(200, '15');
});
it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
return request(server)
.post('/concurrent')
.send([

View File

@@ -75,12 +75,10 @@ describe('NATS transport', () => {
});
it(`/GET (exception)`, () => {
return request(server)
.get('/exception')
.expect(200, {
message: 'test',
status: 'error',
});
return request(server).get('/exception').expect(200, {
message: 'test',
status: 'error',
});
});
it(`/POST (event notification)`, done => {

View File

@@ -49,7 +49,7 @@ describe('REDIS transport', () => {
.expect(200, '15');
});
it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
this.retries(10);
return request(server)

View File

@@ -76,9 +76,7 @@ describe('RPC transport', () => {
});
it(`/POST (pattern not found)`, () => {
return request(server)
.post('/?command=test')
.expect(500);
return request(server).post('/?command=test').expect(500);
});
it(`/POST (event notification)`, done => {

View File

@@ -65,7 +65,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
);
});
it(`should support 2 different gateways`, async function() {
it(`should support 2 different gateways`, async function () {
this.retries(10);
app = await createNestApp(ApplicationGateway, CoreGateway);

View File

@@ -3,8 +3,9 @@ import { RuntimeException } from './runtime.exception';
export class UnknownElementException extends RuntimeException {
constructor(name?: string) {
super(
`Nest could not find ${name ||
'given'} element (this provider does not exist in the current context)`,
`Nest could not find ${
name || 'given'
} element (this provider does not exist in the current context)`,
);
}
}

View File

@@ -109,8 +109,9 @@ export const INVALID_CLASS_SCOPE_MESSAGE = (
text: TemplateStringsArray,
name: string | undefined,
) =>
`${name ||
'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
`${
name || 'This class'
} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
export const INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
export const UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;

View File

@@ -138,12 +138,7 @@ export class NestApplicationContext implements INestApplicationContext {
}
signals = signals
.map((signal: string) =>
signal
.toString()
.toUpperCase()
.trim(),
)
.map((signal: string) => signal.toString().toUpperCase().trim())
// filter out the signals which is already listening to
.filter(signal => !this.activeShutdownSignals.includes(signal));

View File

@@ -313,7 +313,9 @@ export class DependenciesScanner {
if (!providersKeys.includes(type as string)) {
return this.container.addProvider(provider as any, token);
}
const providerToken = `${type as string} (UUID: ${randomStringGenerator()})`;
const providerToken = `${
type as string
} (UUID: ${randomStringGenerator()})`;
let scope = (provider as ClassProvider | FactoryProvider).scope;
if (isNil(scope) && (provider as ClassProvider).useClass) {

View File

@@ -240,9 +240,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
call.on('data', (m: any) => req.next(m));
call.on('error', (e: any) => {
// Check if error means that stream ended on other end
const isCancelledError = String(e)
.toLowerCase()
.indexOf('cancelled');
const isCancelledError = String(e).toLowerCase().indexOf('cancelled');
if (isCancelledError) {
call.end();

View File

@@ -16,7 +16,7 @@ class TestClientProxy extends ClientProxy {
public async close() {}
}
describe('ClientProxy', function() {
describe('ClientProxy', function () {
this.retries(10);
let client: TestClientProxy;

View File

@@ -4,7 +4,7 @@ import { empty } from 'rxjs';
import * as sinon from 'sinon';
import { ClientRMQ } from '../../client/client-rmq';
describe('ClientRMQ', function() {
describe('ClientRMQ', function () {
this.retries(10);
let client: ClientRMQ;

View File

@@ -23,12 +23,9 @@ describe('Cats', () => {
});
it(`/GET cats`, () => {
return request(app.getHttpServer())
.get('/cats')
.expect(200)
.expect({
data: catsService.findAll(),
});
return request(app.getHttpServer()).get('/cats').expect(200).expect({
data: catsService.findAll(),
});
});
afterAll(async () => {

View File

@@ -4,7 +4,7 @@ import { defaultFieldResolver, GraphQLField } from 'graphql';
export class UpperCaseDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field: GraphQLField<any, any>) {
const { resolve = defaultFieldResolver } = field;
field.resolve = async function(...args) {
field.resolve = async function (...args) {
const result = await resolve.apply(this, args);
if (typeof result === 'string') {
return result.toUpperCase();

View File

@@ -4,7 +4,7 @@ import { defaultFieldResolver, GraphQLField } from 'graphql';
export class UpperCaseDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field: GraphQLField<any, any>) {
const { resolve = defaultFieldResolver } = field;
field.resolve = async function(...args) {
field.resolve = async function (...args) {
const result = await resolve.apply(this, args);
if (typeof result === 'string') {
return result.toUpperCase();