Skip to content

Commit

Permalink
build!: update to latest version of gts and typescript (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl committed Apr 12, 2020
1 parent 0ce41a8 commit 454f76b
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 59 deletions.
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
**/node_modules
**/.coverage
build/
docs/
protos/
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@
"body-parser": "^1.19.0",
"boom": "^7.3.0",
"c8": "^7.0.0",
"chai": "^4.2.0",
"codecov": "^3.5.0",
"delay": "^4.3.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.0",
"express": "^4.17.1",
"gts": "^1.0.0",
"gts": "^2.0.0",
"hapi": "^18.1.0",
"js-green-licenses": "^1.1.0",
"json-stable-stringify": "^1.0.1",
Expand All @@ -84,13 +85,13 @@
"lodash.pick": "^4.4.0",
"lodash.random": "^3.2.0",
"lodash.without": "^4.4.0",
"mocha": "^7.0.0",
"mocha": "^7.1.1",
"nock": "^12.0.0",
"post-install-check": "0.0.1",
"prettier": "^1.18.2",
"proxyquire": "^2.1.0",
"restify": "^8.3.3",
"typescript": "3.6.4",
"typescript": "^3.8.3",
"uuid": "^7.0.0"
}
}
3 changes: 2 additions & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"author": "Google Inc.",
"repository": "googleapis/nodejs-error-reporting",
"files": [
"*.js"
"*.js",
"!test/"
],
"engines": {
"node": ">=10"
Expand Down
6 changes: 3 additions & 3 deletions src/google-apis/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../package.json');
import * as is from 'is';
import {Configuration, Logger} from '../configuration';
Expand Down Expand Up @@ -110,12 +111,11 @@ export class RequestHandler extends Service {
this._config = config;
this._logger = logger;

const that = this;
if (tryAuthenticate) {
this.authClient.getAccessToken().then(
() => {},
err => {
that._logger.error(
this._logger.error(
[
'Unable to find credential information on instance. This library',
'will be unable to communicate with the Stackdriver API to save',
Expand Down Expand Up @@ -149,7 +149,7 @@ export class RequestHandler extends Service {
}
}
);
that._logger.info('API key provided; skipping OAuth2 token request.');
this._logger.info('API key provided; skipping OAuth2 token request.');
}
}
/**
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ export class ErrorReporting {
this._client = new AuthClient(this._config, this._logger);

if (this._config.getReportUnhandledRejections()) {
const that = this;
process.on('unhandledRejection', reason => {
that._logger.warn(
this._logger.warn(
'UnhandledPromiseRejectionWarning: ' +
'Unhandled promise rejection: ' +
reason +
'. This rejection has been reported to the ' +
'Google Cloud Platform error-reporting console.'
);
that.report(reason);
this.report(reason);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/hapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {ErrorMessage} from '../classes/error-message';
import {populateErrorMessage} from '../populate-error-message';
import {hapiRequestInformationExtractor} from '../request-extractors/hapi';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../../../package.json');

import {RequestHandler} from '../google-apis/auth-client';
Expand Down
1 change: 1 addition & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as is from 'is';
import has = require('lodash.has');
import consoleLogLevel = require('console-log-level');

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../../package.json');

import {ConfigurationOptions, Logger} from './configuration';
Expand Down
9 changes: 3 additions & 6 deletions system-test/error-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, before, beforeEach, after, afterEach} from 'mocha';
import delay from 'delay';
import * as is from 'is';
import * as nock from 'nock';
Expand Down Expand Up @@ -461,11 +461,8 @@ describe('error-reporting', () => {
// interfering with existing listeners of the 'unhandledRejection' event.
assert.strictEqual(process.listenerCount('unhandledRejection'), 0);
oldLogger = console.error;
console.error = function(this) {
const text = util.format.apply(
null,
(arguments as {}) as [{}, Array<{}>]
);
console.error = function(this, ...args: any[]) {
const text = util.format(null, args);
oldLogger(text);
logOutput += text;
};
Expand Down
4 changes: 2 additions & 2 deletions system-test/test-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ app.get('/error', (req, res, next) => {
});
app.get('/exception', () => {
JSON.parse('{\"malformedJson\": true');
JSON.parse('{"malformedJson": true');
});
app.use(errors.express);
Expand Down Expand Up @@ -293,7 +293,7 @@ app.get('/error', (req, res, next) => {
});
app.get('/exception', () => {
JSON.parse('{\"malformedJson\": true');
JSON.parse('{"malformedJson": true');
});
// Note that express error handling middleware should be attached after all
Expand Down
3 changes: 2 additions & 1 deletion test/test-servers/express_scaffold_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ const EXCLAMATION_LN = '\n!!';
import has = require('lodash.has');
import * as express from 'express';
const app = express();
// eslint-disable-next-line @typescript-eslint/no-var-requires
const errorHandler = require('../../src/index.js')({
onUncaughtException: 'report',
key: process.env.STUBBED_API_KEY,
projectId: process.env.STUBBED_PROJECT_NUM,
});
const bodyParser = require('body-parser');
import bodyParser = require('body-parser');

// eslint-disable-next-line no-console
const log = console.log;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/classes/error-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach} from 'mocha';
import {ErrorMessage} from '../../../src/classes/error-message';
import {RequestInformationContainer} from '../../../src/classes/request-information-container';
import {deepStrictEqual} from '../../util';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/classes/request-information-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach} from 'mocha';
import {RequestInformationContainer} from '../../../src/classes/request-information-container';
import {Fuzzer} from '../../../utils/fuzzer';
import {deepStrictEqual} from '../../util';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, before, after, afterEach, beforeEach} from 'mocha';
import * as is from 'is';
import merge = require('lodash.merge');
import {FakeConfiguration as Configuration} from '../fixtures/configuration';
Expand Down
1 change: 1 addition & 0 deletions test/unit/google-apis/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import * as proxyquire from 'proxyquire';
import {describe, beforeEach, afterEach, it} from 'mocha';

import {
Configuration,
Expand Down
3 changes: 2 additions & 1 deletion test/unit/interfaces/hapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as is from 'is';
import has = require('lodash.has');
import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach, before, afterEach} from 'mocha';
import {makeHapiPlugin as hapiInterface} from '../../../src/interfaces/hapi';
import {ErrorMessage} from '../../../src/classes/error-message';
import {Fuzzer} from '../../../utils/fuzzer';
Expand All @@ -27,6 +27,7 @@ import * as http from 'http';
import * as hapi from 'hapi';
import * as boom from 'boom';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../../../../package.json');

interface HapiPlugin {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/interfaces/restify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {handlerSetup as restifyInterface} from '../../../src/interfaces/restify'
// node v0.12 compatibility
if (!EventEmitter.prototype.listenerCount) {
EventEmitter.prototype.listenerCount = function(this, eventName) {
// tslint:disable-next-line deprecation
// eslint-disable-next-line node/no-deprecated-api
return EventEmitter.listenerCount(this, eventName);
};
}
Expand Down
12 changes: 6 additions & 6 deletions test/unit/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, before, after, beforeEach, afterEach} from 'mocha';
import {createLogger} from '../../src/logger';

describe('logger', () => {
Expand Down Expand Up @@ -66,17 +66,17 @@ describe('logger', () => {
});
});
describe('Default log level', () => {
let oldLog: (text: string) => void;
let oldLog: (text: any, args: string[]) => void;
let text: string | undefined;
beforeEach(() => {
// eslint-disable-next-line no-console
oldLog = console.error;
text = '';
// eslint-disable-next-line no-console
console.error = function(this) {
oldLog.apply(this, (arguments as {}) as [string]);
for (let i = 0; i < arguments.length; i++) {
text += arguments[i];
console.error = function(this, ...args: string[]) {
oldLog(this, args);
for (let i = 0; i < args.length; i++) {
text += args[i];
}
};
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/populate-error-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach} from 'mocha';

import {ErrorMessage} from '../../src/classes/error-message';
import {populateErrorMessage} from '../../src/populate-error-message';
Expand Down
3 changes: 2 additions & 1 deletion test/unit/request-extractors/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {Response} from 'express';
import {expressRequestInformationExtractor} from '../../../src/request-extractors/express';
import {Fuzzer} from '../../../utils/fuzzer';
import {deepStrictEqual} from '../../util';
import {describe, it, beforeEach} from 'mocha';

describe('Behaviour under varying input', () => {
let f: Fuzzer;
Expand Down Expand Up @@ -105,7 +106,7 @@ describe('Behaviour under varying input', () => {
const headerFactory = (toDeriveFrom: any) => {
const lrn = Object.assign({}, toDeriveFrom);
lrn.header = (toRet: string) => {
if (lrn.hasOwnProperty(toRet)) {
if (Object.prototype.hasOwnProperty.call(lrn, toRet)) {
return lrn[toRet];
}
return undefined;
Expand Down
1 change: 1 addition & 0 deletions test/unit/request-extractors/hapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import * as hapi from 'hapi';
import {URL} from 'url';
import {describe, it} from 'mocha';

import {hapiRequestInformationExtractor} from '../../../src/request-extractors/hapi';
import {Fuzzer} from '../../../utils/fuzzer';
Expand Down
1 change: 1 addition & 0 deletions test/unit/request-extractors/koa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import {Request, Response} from 'koa';
import {describe, it} from 'mocha';

import {koaRequestInformationExtractor} from '../../../src/request-extractors/koa';
import {Fuzzer} from '../../../utils/fuzzer';
Expand Down
1 change: 1 addition & 0 deletions test/unit/request-extractors/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import omit = require('lodash.omit');
import {manualRequestInformationExtractor} from '../../../src/request-extractors/manual';
import {Fuzzer} from '../../../utils/fuzzer';
import {deepStrictEqual} from '../../util';
import {describe, it} from 'mocha';

describe('manualRequestInformationExtractor', () => {
describe('Behaviour given invalid input', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/unit/service-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, beforeEach, after, it} from 'mocha';
import * as is from 'is';
import omitBy = require('lodash.omitby');
import {FakeConfiguration as Configuration} from '../fixtures/configuration';
import {deepStrictEqual} from '../util';
const level = process.env.GCLOUD_ERRORS_LOGLEVEL;
import {createLogger} from '../../src/logger';

const logger = createLogger({
logLevel: is.number(level) ? level : 4,
});
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"lib": ["es2018", "dom"],
"rootDir": ".",
"outDir": "build"
},
Expand Down

0 comments on commit 454f76b

Please sign in to comment.