Skip to content

Commit 07d7900

Browse files
chore: update packages and linting (#473)
1 parent 8627add commit 07d7900

File tree

19 files changed

+60
-94
lines changed

19 files changed

+60
-94
lines changed

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
],
1717
"scripts": {
1818
"docs": "compodoc src/",
19-
"lint": "eslint '**/*.js' && gts check",
19+
"lint": "gts check",
2020
"presystem-test": "npm run compile",
2121
"system-test": "MOCHA_THROW_DEPRECATION=false c8 mocha build/system-test",
2222
"presamples-test": "npm run compile",
2323
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
2424
"test": "c8 mocha --recursive build/test/unit",
2525
"clean": "gts clean",
2626
"compile": "tsc -p .",
27-
"fix": "gts fix && eslint --fix '**/*.js'",
27+
"fix": "gts fix",
2828
"prepare": "npm run compile",
2929
"pretest": "npm run compile",
3030
"license-check": "jsgl --local .",
@@ -67,10 +67,6 @@
6767
"chai": "^4.2.0",
6868
"codecov": "^3.5.0",
6969
"delay": "^4.3.0",
70-
"eslint": "^6.0.0",
71-
"eslint-config-prettier": "^6.0.0",
72-
"eslint-plugin-node": "^11.0.0",
73-
"eslint-plugin-prettier": "^3.1.0",
7470
"express": "^4.17.1",
7571
"gts": "^2.0.0",
7672
"hapi": "^18.1.0",
@@ -88,7 +84,6 @@
8884
"mocha": "^7.1.1",
8985
"nock": "^12.0.0",
9086
"post-install-check": "0.0.1",
91-
"prettier": "^1.18.2",
9287
"proxyquire": "^2.1.0",
9388
"restify": "^8.3.3",
9489
"typescript": "^3.8.3",

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import * as restifyInterface from './interfaces/restify';
3232
import {createLogger} from './logger';
3333
import * as manualRequestExtractor from './request-extractors/manual';
3434

35-
// tslint:disable-next-line:no-any
35+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3636
export type RestifyRequestHandler = (req: any, res: any, next: Function) => any;
3737

3838
/**
@@ -106,7 +106,8 @@ export class ErrorReporting {
106106
private _client!: AuthClient;
107107
// the `err` argument can be anything, including `null` and `undefined`
108108
report!: (
109-
err: any, // tslint:disable-line:no-any
109+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
110+
err: any,
110111
request?: manualRequestExtractor.Request,
111112
additionalMessage?: string | {},
112113
callback?: manualInterface.Callback | {} | string
@@ -118,11 +119,11 @@ export class ErrorReporting {
118119
version?: string;
119120
};
120121
express!: (err: {}, req: {}, res: {}, next: Function) => void;
121-
// tslint:disable-next-line:no-any
122+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
122123
restify!: (server: any) => RestifyRequestHandler | RestifyRequestHandler[];
123-
// tslint:disable-next-line:no-any
124+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
124125
koa!: (context: any, next: {}) => IterableIterator<{}>;
125-
// tslint:disable-next-line:no-any
126+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126127
koa2!: (context: any, next: Function) => Promise<void>;
127128

128129
constructor(initConfiguration?: ConfigurationOptions) {

src/interfaces/hapi.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,23 @@ export function makeHapiPlugin(client: RequestHandler, config: Configuration) {
7777
* @returns {Undefined} - returns the execution of the next callback
7878
*/
7979
function hapiRegisterFunction(
80-
server: any, // tslint:disable-line:no-any
80+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
81+
server: any,
8182
options: {},
8283
next?: Function
8384
) {
8485
if (server) {
8586
if (server.events && server.events.on) {
8687
// Hapi 17 is being used
87-
server.events.on(
88-
'log',
89-
(event: {error?: {}; channel: string}, tags: {}) => {
90-
if (event.error && event.channel === 'app') {
91-
client.sendError(hapiErrorHandler(event.error));
92-
}
88+
server.events.on('log', (event: {error?: {}; channel: string}) => {
89+
if (event.error && event.channel === 'app') {
90+
client.sendError(hapiErrorHandler(event.error));
9391
}
94-
);
92+
});
9593

9694
server.events.on(
9795
'request',
98-
(
99-
request: hapi.Request,
100-
event: {error?: {}; channel: string},
101-
tags: {}
102-
) => {
96+
(request: hapi.Request, event: {error?: {}; channel: string}) => {
10397
if (event.error && event.channel === 'error') {
10498
client.sendError(hapiErrorHandler(event.error, request));
10599
}
@@ -113,7 +107,7 @@ export function makeHapiPlugin(client: RequestHandler, config: Configuration) {
113107
}
114108

115109
if (is.function(server.ext)) {
116-
// tslint:disable-next-line no-any
110+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
117111
server.ext('onPreResponse', (request: hapi.Request, reply: any) => {
118112
if (
119113
is.object(request) &&

src/interfaces/koa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {Middleware, Request, Response} from 'koa';
15+
import {Request, Response} from 'koa';
1616

1717
import {ErrorMessage} from '../classes/error-message';
1818
import {Configuration} from '../configuration';
@@ -40,7 +40,7 @@ export function koaErrorHandler(client: RequestHandler, config: Configuration) {
4040
* @param {Function} next - the result of the request handlers to yield
4141
* @returns {Undefined} does not return anything
4242
*/
43-
return function*(
43+
return function* (
4444
this: {request: Request; response: Response},
4545
next: Function
4646
) {

src/interfaces/manual.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type Callback = (
2828
body: {}
2929
) => void;
3030

31-
// tslint:disable-next-line:no-any
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3232
type AnyError = any;
3333

3434
/**

src/populate-error-message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface PopulatedObject {
3939
* @returns {Undefined} - does not return a value
4040
*/
4141
// the `ob` argument can be anything, including `null` and `undefined`
42-
// tslint:disable-next-line:no-any
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4343
export function populateErrorMessage(ob: any, em: ErrorMessage) {
4444
if (ob === null || ob === undefined) {
4545
em.setMessage(buildStackTrace('' + ob));

system-test/.eslintrc.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

system-test/error-reporting.ts

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ describe('Request/Response lifecycle mocking', () => {
153153
});
154154

155155
beforeEach(() => {
156-
env
157-
.setProjectId()
158-
.setKeyFilename()
159-
.setProduction();
156+
env.setProjectId().setKeyFilename().setProduction();
160157
fakeService = nock(
161158
'https://clouderrorreporting.googleapis.com/v1beta1/projects/' +
162159
process.env.GCLOUD_PROJECT
@@ -179,7 +176,7 @@ describe('Request/Response lifecycle mocking', () => {
179176
env.restoreProcessToOriginalState();
180177
});
181178

182-
it('Should fail when receiving non-retryable errors', function(this, done) {
179+
it('Should fail when receiving non-retryable errors', function (this, done) {
183180
this.timeout(5000);
184181
client.sendError({} as ErrorMessage, (err, response) => {
185182
assert(err instanceof Error);
@@ -193,7 +190,7 @@ describe('Request/Response lifecycle mocking', () => {
193190
});
194191
});
195192

196-
it('Should retry when receiving retryable errors', function(this, done) {
193+
it('Should retry when receiving retryable errors', function (this, done) {
197194
this.timeout(25000);
198195
let tries = 0;
199196
const intendedTries = 4;
@@ -212,10 +209,7 @@ describe('Request/Response lifecycle mocking', () => {
212209
'Should provide the key as a query string on outgoing requests when ' +
213210
'using an API key',
214211
done => {
215-
env
216-
.sterilizeProcess()
217-
.setProjectId()
218-
.setProduction();
212+
env.sterilizeProcess().setProjectId().setProduction();
219213
const key = env.apiKey;
220214
const logger = createLogger({logLevel: 5});
221215
const client = new RequestHandler(
@@ -256,7 +250,7 @@ describe('Client creation', () => {
256250
it(
257251
'Should not throw on initialization when using only project id as a ' +
258252
'runtime argument',
259-
function(this, done) {
253+
function (this, done) {
260254
env.sterilizeProcess().setKeyFilename();
261255
const logger = createLogger({logLevel: 5});
262256
const cfg = new Configuration(
@@ -284,11 +278,8 @@ describe('Client creation', () => {
284278
it(
285279
'Should not throw on initialization when using only project id as an ' +
286280
'env variable',
287-
function(this, done) {
288-
env
289-
.sterilizeProcess()
290-
.setProjectId()
291-
.setKeyFilename();
281+
function (this, done) {
282+
env.sterilizeProcess().setProjectId().setKeyFilename();
292283
const logger = createLogger({logLevel: 5});
293284
const cfg = new Configuration({reportMode: 'always'}, logger);
294285
this.timeout(10000);
@@ -309,7 +300,7 @@ describe('Client creation', () => {
309300
it(
310301
'Should not throw on initialization when using only project number as ' +
311302
'a runtime argument',
312-
function(this, done) {
303+
function (this, done) {
313304
env.sterilizeProcess().setKeyFilename();
314305
const logger = createLogger({logLevel: 5});
315306
const cfg = new Configuration(
@@ -337,11 +328,8 @@ describe('Client creation', () => {
337328
it(
338329
'Should not throw on initialization when using only project number as ' +
339330
'an env variable',
340-
function(this, done) {
341-
env
342-
.sterilizeProcess()
343-
.setKeyFilename()
344-
.setProjectNumber();
331+
function (this, done) {
332+
env.sterilizeProcess().setKeyFilename().setProjectNumber();
345333
const logger = createLogger({logLevel: 5});
346334
const cfg = new Configuration({reportMode: 'always'}, logger);
347335
this.timeout(10000);
@@ -376,10 +364,7 @@ describe('Expected Behavior', () => {
376364
});
377365

378366
it('Should callback with an error with a configuration that cannot report errors', done => {
379-
env
380-
.sterilizeProcess()
381-
.setKeyFilename()
382-
.setProjectId();
367+
env.sterilizeProcess().setKeyFilename().setProjectId();
383368
process.env.NODE_ENV = 'null';
384369
const logger = createLogger({logLevel: 5, reportMode: 'production'});
385370
const client = new RequestHandler(
@@ -461,7 +446,8 @@ describe('error-reporting', () => {
461446
// interfering with existing listeners of the 'unhandledRejection' event.
462447
assert.strictEqual(process.listenerCount('unhandledRejection'), 0);
463448
oldLogger = console.error;
464-
console.error = function(this, ...args: any[]) {
449+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
450+
console.error = function (this, ...args: any[]) {
465451
const text = util.format(null, args);
466452
oldLogger(text);
467453
logOutput += text;
@@ -579,15 +565,16 @@ describe('error-reporting', () => {
579565
const context = rep.serviceContext;
580566
assert.ok(
581567
context,
582-
`Expected the error item's representative to have a context`
568+
"Expected the error item's representative to have a context"
583569
);
584570
assert.strictEqual(context.service, SERVICE);
585571
assert.strictEqual(context.version, VERSION);
586572
}
587573

588574
// the `errOb` argument can be anything, including `null` and `undefined`
589575
async function verifyReporting(
590-
errOb: any, // tslint:disable-line:no-any
576+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
577+
errOb: any,
591578
messageTest: (message: string) => void,
592579
maxCount: number,
593580
timeout: number
@@ -638,7 +625,7 @@ describe('error-reporting', () => {
638625
);
639626
});
640627

641-
it('Should correctly publish an error that is a string', async function(this) {
628+
it('Should correctly publish an error that is a string', async function (this) {
642629
this.timeout(TIMEOUT);
643630
const errorId = buildName('with-string');
644631
await verifyReporting(
@@ -651,7 +638,7 @@ describe('error-reporting', () => {
651638
);
652639
});
653640

654-
it('Should correctly publish an error that is undefined', async function(this) {
641+
it('Should correctly publish an error that is undefined', async function (this) {
655642
this.timeout(TIMEOUT);
656643
await verifyReporting(
657644
undefined,
@@ -663,7 +650,7 @@ describe('error-reporting', () => {
663650
);
664651
});
665652

666-
it('Should correctly publish an error that is null', async function(this) {
653+
it('Should correctly publish an error that is null', async function (this) {
667654
this.timeout(TIMEOUT);
668655
await verifyReporting(
669656
null,
@@ -675,7 +662,7 @@ describe('error-reporting', () => {
675662
);
676663
});
677664

678-
it('Should correctly publish an error that is a plain object', async function(this) {
665+
it('Should correctly publish an error that is a plain object', async function (this) {
679666
this.timeout(TIMEOUT);
680667
await verifyReporting(
681668
{someKey: 'someValue'},
@@ -687,7 +674,7 @@ describe('error-reporting', () => {
687674
);
688675
});
689676

690-
it('Should correctly publish an error that is a number', async function(this) {
677+
it('Should correctly publish an error that is a number', async function (this) {
691678
this.timeout(TIMEOUT);
692679
const num = new Date().getTime();
693680
await verifyReporting(
@@ -700,7 +687,7 @@ describe('error-reporting', () => {
700687
);
701688
});
702689

703-
it('Should correctly publish an error that is of an unknown type', async function(this) {
690+
it('Should correctly publish an error that is of an unknown type', async function (this) {
704691
this.timeout(TIMEOUT);
705692
const bool = true;
706693
await verifyReporting(
@@ -713,7 +700,7 @@ describe('error-reporting', () => {
713700
);
714701
});
715702

716-
it('Should correctly publish errors using an error builder', async function(this) {
703+
it('Should correctly publish errors using an error builder', async function (this) {
717704
this.timeout(TIMEOUT);
718705
const errorId = buildName('with-error-builder');
719706
// Use an IIFE with the name `definitionSiteFunction` to use later to
@@ -749,7 +736,7 @@ describe('error-reporting', () => {
749736
await callingSiteFunction();
750737
});
751738

752-
it('Should report unhandledRejections if enabled', async function(this) {
739+
it('Should report unhandledRejections if enabled', async function (this) {
753740
this.timeout(TIMEOUT);
754741
reinitialize({reportUnhandledRejections: true});
755742
const rejectValue = buildName('report-promise-rejection');
@@ -772,7 +759,7 @@ describe('error-reporting', () => {
772759
assert.notStrictEqual(logOutput.indexOf(expected), -1);
773760
});
774761

775-
it('Should not report unhandledRejections if disabled', async function(this) {
762+
it('Should not report unhandledRejections if disabled', async function (this) {
776763
this.timeout(TIMEOUT);
777764
reinitialize({reportUnhandledRejections: false});
778765
const rejectValue = buildName('do-not-report-promise-rejection');

test/test-servers/hapi_scaffold_server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ const errorHandler = new ErrorReporting();
1818

1919
const server = new Hapi.Server({port: 3000});
2020

21-
// eslint-disable-next-line no-console
2221
const log = console.log;
23-
24-
// eslint-disable-next-line no-console
22+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2523
const error = console.error;
2624

2725
server.route({

0 commit comments

Comments
 (0)