From 6f9709d47d7f781d47aba28e7d336c082f1a0a55 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Sun, 12 Apr 2020 17:28:06 -0700 Subject: [PATCH] build!: update to latest version of gts and typescript (#376) --- packages/google-cloud-dns/.eslintrc.yml | 15 ----------- packages/google-cloud-dns/.prettierignore | 8 +++--- packages/google-cloud-dns/.prettierrc | 8 ------ packages/google-cloud-dns/package.json | 7 ++--- .../google-cloud-dns/samples/package.json | 3 ++- packages/google-cloud-dns/src/record.ts | 1 + packages/google-cloud-dns/src/zone.ts | 8 +++--- packages/google-cloud-dns/system-test/dns.ts | 3 ++- packages/google-cloud-dns/test/change.ts | 3 ++- packages/google-cloud-dns/test/index.ts | 5 +++- packages/google-cloud-dns/test/record.ts | 2 +- packages/google-cloud-dns/test/zone.ts | 27 ++++++++++--------- packages/google-cloud-dns/tsconfig.json | 1 + 13 files changed, 42 insertions(+), 49 deletions(-) delete mode 100644 packages/google-cloud-dns/.eslintrc.yml delete mode 100644 packages/google-cloud-dns/.prettierrc diff --git a/packages/google-cloud-dns/.eslintrc.yml b/packages/google-cloud-dns/.eslintrc.yml deleted file mode 100644 index 73eeec27612..00000000000 --- a/packages/google-cloud-dns/.eslintrc.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -extends: - - 'eslint:recommended' - - 'plugin:node/recommended' - - prettier -plugins: - - node - - prettier -rules: - prettier/prettier: error - block-scoped-var: error - eqeqeq: error - no-warning-comments: warn - no-var: error - prefer-const: error diff --git a/packages/google-cloud-dns/.prettierignore b/packages/google-cloud-dns/.prettierignore index f6fac98b0a8..b99e1215836 100644 --- a/packages/google-cloud-dns/.prettierignore +++ b/packages/google-cloud-dns/.prettierignore @@ -1,3 +1,5 @@ -node_modules/* -samples/node_modules/* -src/**/doc/* +**/node_modules +**/.coverage +build/ +docs/ +protos/ \ No newline at end of file diff --git a/packages/google-cloud-dns/.prettierrc b/packages/google-cloud-dns/.prettierrc deleted file mode 100644 index df6eac07446..00000000000 --- a/packages/google-cloud-dns/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ ---- -bracketSpacing: false -printWidth: 80 -semi: true -singleQuote: true -tabWidth: 2 -trailingComma: es5 -useTabs: false diff --git a/packages/google-cloud-dns/package.json b/packages/google-cloud-dns/package.json index 191f4cc6e41..cb64d0b2e71 100644 --- a/packages/google-cloud-dns/package.json +++ b/packages/google-cloud-dns/package.json @@ -60,21 +60,22 @@ "@types/tmp": "0.1.0", "@types/uuid": "^7.0.2", "c8": "^7.0.0", + "chai": "^4.2.0", "codecov": "^3.0.2", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", "eslint-plugin-node": "^11.0.0", "eslint-plugin-prettier": "^3.0.0", - "gts": "^1.0.0", + "gts": "^2.0.0-alpha.9", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.1", "jsdoc-region-tag": "^1.0.2", "linkinator": "^2.0.0", - "mocha": "^7.0.0", + "mocha": "^7.1.1", "prettier": "^1.13.5", "proxyquire": "^2.0.1", "tmp": "^0.1.0", - "typescript": "3.6.4", + "typescript": "^3.8.3", "uuid": "^7.0.2" } } diff --git a/packages/google-cloud-dns/samples/package.json b/packages/google-cloud-dns/samples/package.json index 71146c18917..f4a317e96d1 100644 --- a/packages/google-cloud-dns/samples/package.json +++ b/packages/google-cloud-dns/samples/package.json @@ -8,7 +8,8 @@ "node": ">=8" }, "files": [ - "*.js" + "*.js", + "!test/" ], "scripts": { "test": "mocha --timeout 600000" diff --git a/packages/google-cloud-dns/src/record.ts b/packages/google-cloud-dns/src/record.ts index 1eed8915d84..fabebb42620 100644 --- a/packages/google-cloud-dns/src/record.ts +++ b/packages/google-cloud-dns/src/record.ts @@ -20,6 +20,7 @@ import {Change, CreateChangeCallback} from './change'; import {Zone} from './zone'; import {Metadata} from '@google-cloud/common'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const format = require('string-format-obj'); export interface RecordObject { diff --git a/packages/google-cloud-dns/src/zone.ts b/packages/google-cloud-dns/src/zone.ts index a145ac343b0..16a32980ba2 100644 --- a/packages/google-cloud-dns/src/zone.ts +++ b/packages/google-cloud-dns/src/zone.ts @@ -27,9 +27,11 @@ import arrify = require('arrify'); import * as fs from 'fs'; import groupBy = require('lodash.groupby'); + +// eslint-disable-next-line @typescript-eslint/no-var-requires const zonefile = require('dns-zonefile'); -import {Change, CreateChangeCallback, CreateChangeRequest} from './change'; +import {Change} from './change'; import {Record, RecordMetadata, RecordObject} from './record'; import { DNS, @@ -83,7 +85,7 @@ export type DeleteZoneResponse = [Metadata]; * @param {?Error} err Request error, if any. * @param {object} apiResponse The full API response. */ -export interface DeleteZoneCallback extends DeleteCallback {} +export type DeleteZoneCallback = DeleteCallback; export interface DeleteZoneConfig { force?: boolean; @@ -541,7 +543,7 @@ class Zone extends ZoneServiceObject { }, (err, resp) => { if (err) { - callback!(err, null, resp); + callback!(err, undefined, resp); return; } const change = this.change(resp.id); diff --git a/packages/google-cloud-dns/system-test/dns.ts b/packages/google-cloud-dns/system-test/dns.ts index 238b0f32228..cea64d4be30 100644 --- a/packages/google-cloud-dns/system-test/dns.ts +++ b/packages/google-cloud-dns/system-test/dns.ts @@ -13,12 +13,13 @@ // limitations under the License. import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, after} from 'mocha'; import * as fs from 'fs'; import * as tmp from 'tmp'; import * as util from 'util'; import * as uuid from 'uuid'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const format = require('string-format-obj'); import {DNS, Record} from '../src'; diff --git a/packages/google-cloud-dns/test/change.ts b/packages/google-cloud-dns/test/change.ts index 88a3e509fef..4762fcea143 100644 --- a/packages/google-cloud-dns/test/change.ts +++ b/packages/google-cloud-dns/test/change.ts @@ -19,7 +19,7 @@ import { } from '@google-cloud/common'; import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {Change} from '../src/change'; @@ -37,6 +37,7 @@ class FakeServiceObject extends ServiceObject { calledWith_: IArguments; constructor(config: ServiceObjectConfig) { super(config); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } diff --git a/packages/google-cloud-dns/test/index.ts b/packages/google-cloud-dns/test/index.ts index 174674a5bdb..0c17100cda1 100644 --- a/packages/google-cloud-dns/test/index.ts +++ b/packages/google-cloud-dns/test/index.ts @@ -21,7 +21,7 @@ import { import * as promisify from '@google-cloud/promisify'; import arrify = require('arrify'); import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {CoreOptions, OptionsWithUri, Response} from 'request'; @@ -49,6 +49,7 @@ class FakeService extends Service { calledWith_: IArguments; constructor(config: ServiceConfig, options?: ServiceOptions) { super(config, options); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } @@ -73,6 +74,7 @@ const fakePromisify = Object.assign({}, promisify, { class FakeZone { calledWith_: IArguments; constructor() { + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } @@ -131,6 +133,7 @@ describe('DNS', () => { ]); assert.deepStrictEqual( calledWith.packageJson, + // eslint-disable-next-line @typescript-eslint/no-var-requires require('../../package.json') ); }); diff --git a/packages/google-cloud-dns/test/record.ts b/packages/google-cloud-dns/test/record.ts index 790807f2e9d..3ee4b7d099a 100644 --- a/packages/google-cloud-dns/test/record.ts +++ b/packages/google-cloud-dns/test/record.ts @@ -14,7 +14,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {Record} from '../src'; diff --git a/packages/google-cloud-dns/test/zone.ts b/packages/google-cloud-dns/test/zone.ts index 585844fe442..ae14d717183 100644 --- a/packages/google-cloud-dns/test/zone.ts +++ b/packages/google-cloud-dns/test/zone.ts @@ -16,7 +16,7 @@ import {ServiceObject, ServiceObjectConfig} from '@google-cloud/common'; import * as promisify from '@google-cloud/promisify'; import arrify = require('arrify'); import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {CoreOptions, OptionsWithUri, Response} from 'request'; import * as uuid from 'uuid'; @@ -38,6 +38,7 @@ const fakePromisify = Object.assign({}, promisify, { let parseOverride: Function | null; const fakeDnsZonefile = { parse() { + // eslint-disable-next-line prefer-spread, prefer-rest-params return (parseOverride || (() => {})).apply(null, arguments); }, }; @@ -46,37 +47,39 @@ let writeFileOverride: Function | null; let readFileOverride: Function | null; const fakeFs = { readFile() { + // eslint-disable-next-line prefer-spread, prefer-rest-params return (readFileOverride || (() => {})).apply(null, arguments); }, writeFile() { + // eslint-disable-next-line prefer-spread, prefer-rest-params return (writeFileOverride || (() => {})).apply(null, arguments); }, }; class FakeChange { - calledWith_: IArguments; - constructor() { - this.calledWith_ = arguments; + calledWith_: any[]; + constructor(...args: any[]) { + this.calledWith_ = args; } } class FakeRecord { - calledWith_: IArguments; - constructor() { - this.calledWith_ = arguments; + calledWith_: any[]; + constructor(...args: any[]) { + this.calledWith_ = args; } - static fromZoneRecord_() { + static fromZoneRecord_(...args: any[]) { const record = new FakeRecord(); - record.calledWith_ = arguments; + record.calledWith_ = args; return record; } } class FakeServiceObject extends ServiceObject { - calledWith_: IArguments; - constructor(config: ServiceObjectConfig) { + calledWith_: any[]; + constructor(config: ServiceObjectConfig, ...args: any[]) { super(config); - this.calledWith_ = arguments; + this.calledWith_ = args; } } diff --git a/packages/google-cloud-dns/tsconfig.json b/packages/google-cloud-dns/tsconfig.json index b10ee498aef..8b14ad98550 100644 --- a/packages/google-cloud-dns/tsconfig.json +++ b/packages/google-cloud-dns/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "./node_modules/gts/tsconfig-google.json", "compilerOptions": { + "lib": ["es2018", "dom"], "rootDir": ".", "outDir": "build" },