From d119ace15f88adc90617ca020aab8556ed410e5c Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Mon, 30 Mar 2020 13:01:19 -0700 Subject: [PATCH 01/15] samples: add v4 signed policy sample (#1116) * add v4 signed policy sample * fix comments * nit: v4 signed policy * use updated method name * add test * fixy * fixy * fix assert * copy: file to create * use string concat instead of console.log each line * const => let * fix Co-authored-by: Jonathan Lui --- samples/generateV4SignedPolicy.js | 69 +++++++++++++++++++++++++++++++ samples/system-test/files.test.js | 22 ++++++++++ 2 files changed, 91 insertions(+) create mode 100644 samples/generateV4SignedPolicy.js diff --git a/samples/generateV4SignedPolicy.js b/samples/generateV4SignedPolicy.js new file mode 100644 index 0000000000..d2308e4dc1 --- /dev/null +++ b/samples/generateV4SignedPolicy.js @@ -0,0 +1,69 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * This application demonstrates how to perform basic operations on files with + * the Google Cloud Storage API. + * + * For more information, see the README.md under /storage and the documentation + * at https://cloud.google.com/storage/docs. + */ + +function main(bucketName = 'my-bucket', filename = 'test.txt') { + // [START storage_generate_post_policy_url_v4] + /** + * TODO(developer): Uncomment the following lines before running the sample. + */ + // const bucketName = 'Name of a bucket, e.g. my-bucket'; + // const filename = 'File to access, e.g. file.txt'; + + // Imports the Google Cloud client library + const {Storage} = require('@google-cloud/storage'); + + // Creates a client + const storage = new Storage(); + + async function generateV4SignedPolicy() { + const bucket = storage.bucket(bucketName); + const file = bucket.file(filename); + + // These options will allow temporary uploading of a file + // through an HTML form. + const expires = Date.now() + 10 * 60 * 1000; // 10 minutes + const options = { + expires, + fields: {'x-goog-meta-test': 'data'}, + }; + + // Get a v4 signed policy for uploading file + const [response] = await file.generateSignedPostPolicyV4(options); + + // Create an HTML form with the provided policy + let output = `
\n`; + // Include all fields returned in the HTML form as they're required + for (const name of Object.keys(response.fields)) { + const value = response.fields[name]; + output += ` \n`; + } + output += " \n"; + output += " \n"; + output += '
'; + + console.log(output); + } + + generateV4SignedPolicy().catch(console.error); + // [END storage_generate_post_policy_url_v4] +} +main(...process.argv.slice(2)); diff --git a/samples/system-test/files.test.js b/samples/system-test/files.test.js index 947a31cedd..5eef83a99d 100644 --- a/samples/system-test/files.test.js +++ b/samples/system-test/files.test.js @@ -240,6 +240,28 @@ it('should generate a v4 signed URL and upload a file', async () => { }); }); +it('should generate a v4 signed policy', async () => { + const output = execSync( + `node generateV4SignedPolicy.js ${bucketName} ${signedFileName}` + ); + + assert.include( + output, + `
"); +}); + it('should get metadata for a file', () => { const output = execSync( `node getMetadata.js ${bucketName} ${copiedFileName}` From dcee78b98da23b02fe7d2f13a9270546bc07bba8 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Mon, 30 Mar 2020 14:11:42 -0700 Subject: [PATCH 02/15] fix: add whitespace to generateV4SignedPolicy (#1136) * fix: add whitespace to generateV4SignedPolicy * fix: revert break for hidden fields. * fix Co-authored-by: Jonathan Lui --- samples/generateV4SignedPolicy.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/generateV4SignedPolicy.js b/samples/generateV4SignedPolicy.js index d2308e4dc1..9e8f0e1627 100644 --- a/samples/generateV4SignedPolicy.js +++ b/samples/generateV4SignedPolicy.js @@ -56,8 +56,9 @@ function main(bucketName = 'my-bucket', filename = 'test.txt') { const value = response.fields[name]; output += ` \n`; } - output += " \n"; - output += " \n"; + output += "
\n"; + output += + "
\n"; output += ''; console.log(output); From e3625cd99f08913984d3dce2796175e2da2864b7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 1 Apr 2020 11:31:08 -0700 Subject: [PATCH 03/15] chore: template and doc updates --- .eslintrc.json | 3 +++ .github/workflows/ci.yaml | 2 +- .prettierrc.js | 17 +++++++++++++++++ README.md | 1 + samples/README.md | 18 ++++++++++++++++++ synth.metadata | 5 +++-- 6 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .prettierrc.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..7821534954 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 92394b1e42..7138a79a95 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [8, 10, 12, 13] + node: [10, 12, 13] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..08cba3775b --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,17 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/README.md b/README.md index 4ac36ed626..c6a27c677c 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ has instructions for running the samples. | Generate Encryption Key | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateEncryptionKey.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateEncryptionKey.js,samples/README.md) | | Generate Signed Url | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateSignedUrl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateSignedUrl.js,samples/README.md) | | Generate V4 Read Signed Url | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4ReadSignedUrl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateV4ReadSignedUrl.js,samples/README.md) | +| Generate V4 Signed Policy | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4SignedPolicy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateV4SignedPolicy.js,samples/README.md) | | Generate V4 Upload Signed Url | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4UploadSignedUrl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateV4UploadSignedUrl.js,samples/README.md) | | Get Default Event Based Hold | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/getDefaultEventBasedHold.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getDefaultEventBasedHold.js,samples/README.md) | | Get Metadata | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/getMetadata.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getMetadata.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 859ee19d45..5cfad334b5 100644 --- a/samples/README.md +++ b/samples/README.md @@ -44,6 +44,7 @@ objects to users via direct download. * [Generate Encryption Key](#generate-encryption-key) * [Generate Signed Url](#generate-signed-url) * [Generate V4 Read Signed Url](#generate-v4-read-signed-url) + * [Generate V4 Signed Policy](#generate-v4-signed-policy) * [Generate V4 Upload Signed Url](#generate-v4-upload-signed-url) * [Get Default Event Based Hold](#get-default-event-based-hold) * [Get Metadata](#get-metadata) @@ -549,6 +550,23 @@ __Usage:__ +### Generate V4 Signed Policy + +View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4SignedPolicy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/generateV4SignedPolicy.js,samples/README.md) + +__Usage:__ + + +`node samples/generateV4SignedPolicy.js` + + +----- + + + + ### Generate V4 Upload Signed Url View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4UploadSignedUrl.js). diff --git a/synth.metadata b/synth.metadata index 34f3f59506..da50f4a3a9 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,11 +1,12 @@ { - "updateTime": "2020-03-22T11:49:19.238679Z", + "updateTime": "2020-04-01T13:16:47.815197Z", "sources": [ { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "7e98e1609c91082f4eeb63b530c6468aefd18cfd" + "sha": "99820243d348191bc9c634f2b48ddf65096285ed", + "log": "99820243d348191bc9c634f2b48ddf65096285ed\nfix: update template files for Node.js libraries (#463)\n\n\n3cbe6bcd5623139ac9834c43818424ddca5430cb\nfix(ruby): remove dead troubleshooting link from generated auth guide (#462)\n\n\na003d8655d3ebec2bbbd5fc3898e91e152265c67\ndocs: remove \"install stable\" instructions (#461)\n\nThe package hasn't been released to PyPI in some time\nf5e8c88d9870d8aa4eb43fa0b39f07e02bfbe4df\nchore(python): add license headers to config files; make small tweaks to templates (#458)\n\n\ne36822bfa0acb355502dab391b8ef9c4f30208d8\nchore(java): treat samples shared configuration dependency update as chore (#457)\n\n\n1b4cc80a7aaf164f6241937dd87f3bd1f4149e0c\nfix: do not run node 8 CI (#456)\n\n\nee4330a0e5f4b93978e8683fbda8e6d4148326b7\nchore(java_templates): mark version bumps of current library as a chore (#452)\n\nWith the samples/install-without-bom/pom.xml referencing the latest released library, we want to mark updates of this version as a chore for renovate bot.\na0d3133a5d45544a66345059eebf76933265c099\nfix(java): run mvn install with retry (#453)\n\n* fix(java): run mvn install with retry\n\n* fix invocation of command\n6a17abc7652e2fe563e1288c6e8c23fc260dda97\ndocs: document the release schedule we follow (#454)\n\n\n" } } ] From 58a5e7ae8b425125458ab12d732bbf0826b89d34 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 1 Apr 2020 22:10:47 +0200 Subject: [PATCH 04/15] chore(deps): update dependency @types/sinon to v9 (#1140) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 860acf52fc..e1a1944f73 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "@types/node-fetch": "^2.1.3", "@types/proxyquire": "^1.3.28", "@types/pumpify": "^1.4.1", - "@types/sinon": "^7.0.10", + "@types/sinon": "^9.0.0", "@types/through2": "^2.0.33", "@types/tmp": "0.1.0", "@types/uuid": "^7.0.0", From 5d27e0351c4c2e7f7fe8b85dafe0decf96cae466 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Wed, 1 Apr 2020 13:20:02 -0700 Subject: [PATCH 05/15] chore(samples): region tag for post policy sample (#1138) Co-authored-by: Jonathan Lui --- samples/generateV4SignedPolicy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/generateV4SignedPolicy.js b/samples/generateV4SignedPolicy.js index 9e8f0e1627..0c41da41f5 100644 --- a/samples/generateV4SignedPolicy.js +++ b/samples/generateV4SignedPolicy.js @@ -21,7 +21,7 @@ */ function main(bucketName = 'my-bucket', filename = 'test.txt') { - // [START storage_generate_post_policy_url_v4] + // [START storage_generate_signed_post_policy_v4] /** * TODO(developer): Uncomment the following lines before running the sample. */ @@ -65,6 +65,6 @@ function main(bucketName = 'my-bucket', filename = 'test.txt') { } generateV4SignedPolicy().catch(console.error); - // [END storage_generate_post_policy_url_v4] + // [END storage_generate_signed_post_policy_v4] } main(...process.argv.slice(2)); From c60d7ef427e5bfd8015cae837a99b4816d89ff43 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 1 Apr 2020 17:42:13 -0700 Subject: [PATCH 06/15] build: set AUTOSYNTH_MULTIPLE_COMMITS=true for context aware commits (#1139) --- synth.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synth.py b/synth.py index dac2b7d1d7..c958eea17a 100644 --- a/synth.py +++ b/synth.py @@ -17,6 +17,9 @@ import logging logging.basicConfig(level=logging.DEBUG) + +AUTOSYNTH_MULTIPLE_COMMITS = True + common_templates = gcp.CommonTemplates() templates = common_templates.node_library(source_location='build/src') s.copy(templates, excludes=['.jsdoc.js']) From 260aed34e526bf5965908c2e6de4a80c3ce46c1d Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sun, 5 Apr 2020 12:50:30 -0700 Subject: [PATCH 07/15] chore: remove duplicate mocha config (#1147) --- .mocharc.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .mocharc.json diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index 670c5e2c24..0000000000 --- a/.mocharc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} From e8116d3c6fa7412858692e67745b514eef78850e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 8 Apr 2020 14:30:29 -0700 Subject: [PATCH 08/15] fix: apache license URL (#468) (#1151) --- .prettierrc.js | 2 +- synth.metadata | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index 08cba3775b..d1b95106f4 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/synth.metadata b/synth.metadata index da50f4a3a9..538450f7f5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-04-01T13:16:47.815197Z", + "updateTime": "2020-04-08T13:02:56.471752Z", "sources": [ { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "99820243d348191bc9c634f2b48ddf65096285ed", - "log": "99820243d348191bc9c634f2b48ddf65096285ed\nfix: update template files for Node.js libraries (#463)\n\n\n3cbe6bcd5623139ac9834c43818424ddca5430cb\nfix(ruby): remove dead troubleshooting link from generated auth guide (#462)\n\n\na003d8655d3ebec2bbbd5fc3898e91e152265c67\ndocs: remove \"install stable\" instructions (#461)\n\nThe package hasn't been released to PyPI in some time\nf5e8c88d9870d8aa4eb43fa0b39f07e02bfbe4df\nchore(python): add license headers to config files; make small tweaks to templates (#458)\n\n\ne36822bfa0acb355502dab391b8ef9c4f30208d8\nchore(java): treat samples shared configuration dependency update as chore (#457)\n\n\n1b4cc80a7aaf164f6241937dd87f3bd1f4149e0c\nfix: do not run node 8 CI (#456)\n\n\nee4330a0e5f4b93978e8683fbda8e6d4148326b7\nchore(java_templates): mark version bumps of current library as a chore (#452)\n\nWith the samples/install-without-bom/pom.xml referencing the latest released library, we want to mark updates of this version as a chore for renovate bot.\na0d3133a5d45544a66345059eebf76933265c099\nfix(java): run mvn install with retry (#453)\n\n* fix(java): run mvn install with retry\n\n* fix invocation of command\n6a17abc7652e2fe563e1288c6e8c23fc260dda97\ndocs: document the release schedule we follow (#454)\n\n\n" + "sha": "1df68ed6735ddce6797d0f83641a731c3c3f75b4", + "log": "1df68ed6735ddce6797d0f83641a731c3c3f75b4\nfix: apache license URL (#468)\n\n\nf4a59efa54808c4b958263de87bc666ce41e415f\nfeat: Add discogapic support for GAPICBazel generation (#459)\n\n* feat: Add discogapic support for GAPICBazel generation\n\n* reformat with black\n\n* Rename source repository variable\n\nCo-authored-by: Jeffrey Rennie \n" } } ] From 2a26e62ada6ebd081fa46082bab896d5addb307c Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sat, 11 Apr 2020 19:18:26 -0700 Subject: [PATCH 09/15] build: remove unused codecov config (#1154) --- codecov.yaml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 codecov.yaml diff --git a/codecov.yaml b/codecov.yaml deleted file mode 100644 index 5724ea9478..0000000000 --- a/codecov.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -codecov: - ci: - - source.cloud.google.com From b80c025f106052fd25554c64314b3b3520e829b5 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sat, 11 Apr 2020 22:12:29 -0700 Subject: [PATCH 10/15] build!: drop support for node.js 8.x --- .eslintrc.yml | 15 -- .prettierrc | 8 - conformance-test/v4SignedUrl.ts | 2 +- package.json | 20 +- samples/deleteFile.js | 5 +- samples/deleteNotification.js | 5 +- samples/disableRequesterPays.js | 2 +- samples/downloadEncryptedFile.js | 4 +- samples/downloadFile.js | 5 +- samples/downloadFileUsingRequesterPays.js | 7 +- samples/enableRequesterPays.js | 2 +- samples/getRequesterPaysStatus.js | 6 +- samples/hmacKeyActivate.js | 4 +- samples/hmacKeyCreate.js | 4 +- samples/hmacKeyDeactivate.js | 4 +- samples/hmacKeyDelete.js | 2 +- samples/hmacKeyGet.js | 2 +- samples/makePublic.js | 5 +- samples/moveFile.js | 5 +- samples/notifications.js | 41 ++- samples/printFileAcl.js | 5 +- samples/releaseEventBasedHold.js | 9 +- samples/releaseTemporaryHold.js | 9 +- samples/rotateEncryptionKey.js | 2 +- samples/setEventBasedHold.js | 9 +- samples/setTemporarydHold.js | 9 +- samples/system-test/buckets.test.js | 12 +- samples/system-test/encryption.test.js | 10 +- samples/system-test/hmacKey.test.js | 6 +- samples/system-test/iam.test.js | 6 +- samples/system-test/requesterPays.test.js | 12 +- samples/uploadEncryptedFile.js | 4 +- samples/viewBucketIamMembers.js | 4 +- src/acl.ts | 6 +- src/bucket.ts | 22 +- src/file.ts | 45 ++-- src/iam.ts | 5 +- src/notification.ts | 2 +- src/signer.ts | 6 +- src/storage.ts | 3 +- src/util.ts | 7 +- system-test/storage.ts | 73 +++--- test/acl.ts | 13 +- test/bucket.ts | 99 +++---- test/channel.ts | 8 +- test/file.ts | 300 ++++++++++------------ test/hmacKey.ts | 23 +- test/iam.ts | 8 +- test/index.ts | 17 +- test/notification.ts | 7 +- test/signer.ts | 28 +- tslint.json | 3 - 52 files changed, 388 insertions(+), 532 deletions(-) delete mode 100644 .eslintrc.yml delete mode 100644 .prettierrc delete mode 100644 tslint.json diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 73eeec2761..0000000000 --- a/.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/.prettierrc b/.prettierrc deleted file mode 100644 index df6eac0744..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ ---- -bracketSpacing: false -printWidth: 80 -semi: true -singleQuote: true -tabWidth: 2 -trailingComma: es5 -useTabs: false diff --git a/conformance-test/v4SignedUrl.ts b/conformance-test/v4SignedUrl.ts index 55453609cc..f263ddd45d 100644 --- a/conformance-test/v4SignedUrl.ts +++ b/conformance-test/v4SignedUrl.ts @@ -92,7 +92,7 @@ const testFile = fs.readFileSync( 'utf-8' ); -// tslint:disable-next-line no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any const testCases = JSON.parse(testFile); const v4SignedUrlCases: V4SignedURLTestCase[] = testCases.signingV4Tests; const v4SignedPolicyCases: V4SignedPolicyTestCase[] = diff --git a/package.json b/package.json index e1a1944f73..9e412a0573 100644 --- a/package.json +++ b/package.json @@ -5,17 +5,14 @@ "license": "Apache-2.0", "author": "Google Inc.", "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "repository": "googleapis/nodejs-storage", "main": "./build/src/index.js", "types": "./build/src/index.d.ts", "files": [ "build/src", - "!build/src/**/*.map", - "AUTHORS", - "CONTRIBUTORS", - "COPYING" + "!build/src/**/*.map" ], "keywords": [ "google apis client", @@ -38,13 +35,13 @@ "presystem-test": "npm run compile", "test": "c8 mocha build/test", "pretest": "npm run compile", - "lint": "eslint samples/ && gts check", + "lint": "gts check", "samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../", "all-test": "npm test && npm run system-test && npm run samples-test", "check": "gts check", "clean": "gts clean", "compile": "tsc -p .", - "fix": "gts fix && eslint --fix '**/*.js'", + "fix": "gts fix", "prepare": "npm run compile", "docs-test": "linkinator docs", "predocs-test": "npm run docs", @@ -98,13 +95,9 @@ "@types/xdg-basedir": "^2.0.0", "c8": "^7.0.0", "codecov": "^3.0.0", - "eslint": "^6.0.0", - "eslint-config-prettier": "^6.0.0", - "eslint-plugin-node": "^11.0.0", - "eslint-plugin-prettier": "^3.0.0", "form-data": "^3.0.0", "grpc": "^1.22.2", - "gts": "^1.0.0", + "gts": "^2.0.0", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.1", "jsdoc-region-tag": "^1.0.2", @@ -113,11 +106,10 @@ "nock": "~12.0.0", "node-fetch": "^2.2.0", "normalize-newline": "^3.0.0", - "prettier": "^1.7.0", "proxyquire": "^2.1.3", "sinon": "^9.0.0", "tmp": "^0.1.0", - "typescript": "3.6.4", + "typescript": "^3.8.3", "uuid": "^7.0.0", "yargs": "^15.0.0" } diff --git a/samples/deleteFile.js b/samples/deleteFile.js index 196e0023d0..85035665c5 100644 --- a/samples/deleteFile.js +++ b/samples/deleteFile.js @@ -36,10 +36,7 @@ function main(bucketName = 'my-bucket', filename = 'test.txt') { async function deleteFile() { // Deletes the file from the bucket - await storage - .bucket(bucketName) - .file(filename) - .delete(); + await storage.bucket(bucketName).file(filename).delete(); console.log(`gs://${bucketName}/${filename} deleted.`); } diff --git a/samples/deleteNotification.js b/samples/deleteNotification.js index 242fd7aeeb..8a9e5b9b5b 100644 --- a/samples/deleteNotification.js +++ b/samples/deleteNotification.js @@ -36,10 +36,7 @@ function main(bucketName = 'my-bucket', notificationId = '1') { async function deleteNotification() { // Deletes the notification from the bucket - await storage - .bucket(bucketName) - .notification(notificationId) - .delete(); + await storage.bucket(bucketName).notification(notificationId).delete(); console.log(`Notification ${notificationId} deleted.`); } diff --git a/samples/disableRequesterPays.js b/samples/disableRequesterPays.js index 31bc8ab269..0687448290 100644 --- a/samples/disableRequesterPays.js +++ b/samples/disableRequesterPays.js @@ -29,7 +29,7 @@ function main(bucketName = 'my-bucket') { // const bucketName = 'Name of a bucket, e.g. my-bucket'; // Imports the Google Cloud client library - const {Storage} = require(`@google-cloud/storage`); + const {Storage} = require('@google-cloud/storage'); // Creates a client const storage = new Storage(); diff --git a/samples/downloadEncryptedFile.js b/samples/downloadEncryptedFile.js index 056cf9ddf2..8dfc533c00 100644 --- a/samples/downloadEncryptedFile.js +++ b/samples/downloadEncryptedFile.js @@ -24,8 +24,8 @@ const path = require('path'); function main( bucketName = 'my-bucket', - srcFilename = path.join(__dirname, `../resources`, 'test.txt'), - destFilename = `test.txt`, + srcFilename = path.join(__dirname, '../resources', 'test.txt'), + destFilename = 'test.txt', key = process.env.GOOGLE_CLOUD_KMS_KEY_US ) { // [START storage_download_encrypted_file] diff --git a/samples/downloadFile.js b/samples/downloadFile.js index 1f513426e8..7cb27d65a3 100644 --- a/samples/downloadFile.js +++ b/samples/downloadFile.js @@ -48,10 +48,7 @@ function main( }; // Downloads the file - await storage - .bucket(bucketName) - .file(srcFilename) - .download(options); + await storage.bucket(bucketName).file(srcFilename).download(options); console.log( `gs://${bucketName}/${srcFilename} downloaded to ${destFilename}.` diff --git a/samples/downloadFileUsingRequesterPays.js b/samples/downloadFileUsingRequesterPays.js index ced70e02c9..d8ea117eaa 100644 --- a/samples/downloadFileUsingRequesterPays.js +++ b/samples/downloadFileUsingRequesterPays.js @@ -40,7 +40,7 @@ function main( // const destFilename = 'Local destination of file, e.g. ./local/path/to/file.txt'; // Imports the Google Cloud client library - const {Storage} = require(`@google-cloud/storage`); + const {Storage} = require('@google-cloud/storage'); // Creates a client const storage = new Storage(); @@ -55,10 +55,7 @@ function main( }; // Downloads the file - await storage - .bucket(bucketName) - .file(srcFilename) - .download(options); + await storage.bucket(bucketName).file(srcFilename).download(options); console.log( `gs://${bucketName}/${srcFilename} downloaded to ${destFilename} using requester-pays requests.` diff --git a/samples/enableRequesterPays.js b/samples/enableRequesterPays.js index 800107b22e..a93c3a513b 100644 --- a/samples/enableRequesterPays.js +++ b/samples/enableRequesterPays.js @@ -28,7 +28,7 @@ function main(bucketName = 'my-bucket') { // const bucketName = 'Name of a bucket, e.g. my-bucket'; // Imports the Google Cloud client library - const {Storage} = require(`@google-cloud/storage`); + const {Storage} = require('@google-cloud/storage'); // Creates a client const storage = new Storage(); diff --git a/samples/getRequesterPaysStatus.js b/samples/getRequesterPaysStatus.js index 049716f8e8..2ba1213c74 100644 --- a/samples/getRequesterPaysStatus.js +++ b/samples/getRequesterPaysStatus.js @@ -28,7 +28,7 @@ function main(bucketName = 'my-bucket') { // const bucketName = 'Name of a bucket, e.g. my-bucket'; // Imports the Google Cloud client library - const {Storage} = require(`@google-cloud/storage`); + const {Storage} = require('@google-cloud/storage'); // Creates a client const storage = new Storage(); @@ -39,9 +39,9 @@ function main(bucketName = 'my-bucket') { let status; if (metadata && metadata.billing && metadata.billing.requesterPays) { - status = `enabled`; + status = 'enabled'; } else { - status = `disabled`; + status = 'disabled'; } console.log( `Requester-pays requests are ${status} for bucket ${bucketName}.` diff --git a/samples/hmacKeyActivate.js b/samples/hmacKeyActivate.js index c1b06aaa5e..40ecb9ec71 100644 --- a/samples/hmacKeyActivate.js +++ b/samples/hmacKeyActivate.js @@ -41,8 +41,8 @@ function main( const hmacKey = storage.hmacKey(hmacKeyAccessId, {projectId}); const [hmacKeyMetadata] = await hmacKey.setMetadata({state: 'ACTIVE'}); - console.log(`The HMAC key is now active.`); - console.log(`The HMAC key metadata is:`); + console.log('The HMAC key is now active.'); + console.log('The HMAC key metadata is:'); for (const [key, value] of Object.entries(hmacKeyMetadata)) { console.log(`${key}: ${value}`); } diff --git a/samples/hmacKeyCreate.js b/samples/hmacKeyCreate.js index d359fb6f89..cc399a0bf4 100644 --- a/samples/hmacKeyCreate.js +++ b/samples/hmacKeyCreate.js @@ -43,8 +43,8 @@ function main( }); console.log(`The base64 encoded secret is: ${secret}`); - console.log(`Do not miss that secret, there is no API to recover it.`); - console.log(`The HMAC key metadata is:`); + console.log('Do not miss that secret, there is no API to recover it.'); + console.log('The HMAC key metadata is:'); for (const [key, value] of Object.entries(hmacKey.metadata)) { console.log(`${key}: ${value}`); } diff --git a/samples/hmacKeyDeactivate.js b/samples/hmacKeyDeactivate.js index 33374519ac..bc16a23f1c 100644 --- a/samples/hmacKeyDeactivate.js +++ b/samples/hmacKeyDeactivate.js @@ -41,8 +41,8 @@ function main( const hmacKey = storage.hmacKey(hmacKeyAccessId, {projectId}); const [hmacKeyMetadata] = await hmacKey.setMetadata({state: 'INACTIVE'}); - console.log(`The HMAC key is now inactive.`); - console.log(`The HMAC key metadata is:`); + console.log('The HMAC key is now inactive.'); + console.log('The HMAC key metadata is:'); for (const [key, value] of Object.entries(hmacKeyMetadata)) { console.log(`${key}: ${value}`); } diff --git a/samples/hmacKeyDelete.js b/samples/hmacKeyDelete.js index 4a49e3db86..7d752b772c 100644 --- a/samples/hmacKeyDelete.js +++ b/samples/hmacKeyDelete.js @@ -42,7 +42,7 @@ function main( await hmacKey.delete(); console.log( - `The key is deleted, though it may still appear in getHmacKeys() results.` + 'The key is deleted, though it may still appear in getHmacKeys() results.' ); } // [END storage_delete_hmac_key] diff --git a/samples/hmacKeyGet.js b/samples/hmacKeyGet.js index d2f002aad9..5bc0d6ba00 100644 --- a/samples/hmacKeyGet.js +++ b/samples/hmacKeyGet.js @@ -42,7 +42,7 @@ function main( // Populate the hmacKey object with metadata from server. await hmacKey.getMetadata(); - console.log(`The HMAC key metadata is:`); + console.log('The HMAC key metadata is:'); for (const [key, value] of Object.entries(hmacKey.metadata)) { console.log(`${key}: ${value}`); } diff --git a/samples/makePublic.js b/samples/makePublic.js index c0b7ba2964..6099a30f64 100644 --- a/samples/makePublic.js +++ b/samples/makePublic.js @@ -36,10 +36,7 @@ function main(bucketName = 'my-bucket', filename = 'test.txt') { async function makePublic() { // Makes the file public - await storage - .bucket(bucketName) - .file(filename) - .makePublic(); + await storage.bucket(bucketName).file(filename).makePublic(); console.log(`gs://${bucketName}/${filename} is now public.`); } diff --git a/samples/moveFile.js b/samples/moveFile.js index 00f3aca6b5..0c565bcbc4 100644 --- a/samples/moveFile.js +++ b/samples/moveFile.js @@ -41,10 +41,7 @@ function main( async function moveFile() { // Moves the file within the bucket - await storage - .bucket(bucketName) - .file(srcFilename) - .move(destFilename); + await storage.bucket(bucketName).file(srcFilename).move(destFilename); console.log( `gs://${bucketName}/${srcFilename} moved to gs://${bucketName}/${destFilename}.` diff --git a/samples/notifications.js b/samples/notifications.js index d1d084f361..e3631c8a12 100644 --- a/samples/notifications.js +++ b/samples/notifications.js @@ -113,59 +113,56 @@ async function deleteNotification(bucketName, notificationId) { // const notificationId = 'ID of notification to delete, e.g. 1'; // Deletes the notification from the bucket - await storage - .bucket(bucketName) - .notification(notificationId) - .delete(); + await storage.bucket(bucketName).notification(notificationId).delete(); console.log(`Notification ${notificationId} deleted.`); // [END storage_delete_notification] } -require(`yargs`) +require('yargs') .demand(1) .command( - `create `, - `Creates a new notification`, + 'create ', + 'Creates a new notification', {}, opts => createNotification(opts.bucketName, opts.topic) ) .command( - `list `, - `Lists notifications for a given bucket.`, + 'list ', + 'Lists notifications for a given bucket.', {}, opts => listNotifications(opts.bucketName) ) .command( - `get-metadata `, - `Gets metadata for a notification.`, + 'get-metadata ', + 'Gets metadata for a notification.', {}, opts => getMetadata(opts.bucketName, opts.notificationId) ) .command( - `delete `, - `Deletes a notification from a bucket.`, + 'delete ', + 'Deletes a notification from a bucket.', {}, opts => deleteNotification(opts.bucketName, opts.notificationId) ) .example( - `node $0 create my-bucket my-topic`, - `Creates a notification subscription.` + 'node $0 create my-bucket my-topic', + 'Creates a notification subscription.' ) .example( - `node $0 list my-bucket`, - `Lists notifications associated with "my-bucket".` + 'node $0 list my-bucket', + 'Lists notifications associated with "my-bucket".' ) .example( - `node $0 get-metadata my-bucket 1`, - `Gets the metadata for notification "1" attached to "my-bucket".` + 'node $0 get-metadata my-bucket 1', + 'Gets the metadata for notification "1" attached to "my-bucket".' ) .example( - `node $0 delete my-bucket 1`, - `Deletes the notification "1" from "my-bucket".` + 'node $0 delete my-bucket 1', + 'Deletes the notification "1" from "my-bucket".' ) .wrap(120) .recommendCommands() - .epilogue(`For more information, see https://cloud.google.com/storage/docs`) + .epilogue('For more information, see https://cloud.google.com/storage/docs') .strict() .help().argv; diff --git a/samples/printFileAcl.js b/samples/printFileAcl.js index b3df6ec1f9..74120cae05 100644 --- a/samples/printFileAcl.js +++ b/samples/printFileAcl.js @@ -36,10 +36,7 @@ function main(bucketName = 'my-bucket', filename = 'test.txt') { async function printFileAcl() { // Gets the ACL for the file - const [acls] = await storage - .bucket(bucketName) - .file(filename) - .acl.get(); + const [acls] = await storage.bucket(bucketName).file(filename).acl.get(); acls.forEach(acl => { console.log(`${acl.role}: ${acl.entity}`); diff --git a/samples/releaseEventBasedHold.js b/samples/releaseEventBasedHold.js index 135050dcd9..65def65078 100644 --- a/samples/releaseEventBasedHold.js +++ b/samples/releaseEventBasedHold.js @@ -35,12 +35,9 @@ function main(bucketName = 'my-bucket', fileName = 'test.txt') { const storage = new Storage(); async function releaseEventBasedHold() { - await storage - .bucket(bucketName) - .file(fileName) - .setMetadata({ - eventBasedHold: false, - }); + await storage.bucket(bucketName).file(fileName).setMetadata({ + eventBasedHold: false, + }); console.log(`Event-based hold was released for ${fileName}.`); } diff --git a/samples/releaseTemporaryHold.js b/samples/releaseTemporaryHold.js index 48ad924945..3c015dbfdc 100644 --- a/samples/releaseTemporaryHold.js +++ b/samples/releaseTemporaryHold.js @@ -35,12 +35,9 @@ function main(bucketName = 'my-bucket', fileName = 'test.txt') { const storage = new Storage(); async function releaseTemporaryHold() { - await storage - .bucket(bucketName) - .file(fileName) - .setMetadata({ - temporaryHold: false, - }); + await storage.bucket(bucketName).file(fileName).setMetadata({ + temporaryHold: false, + }); console.log(`Temporary hold was released for ${fileName}.`); } diff --git a/samples/rotateEncryptionKey.js b/samples/rotateEncryptionKey.js index 8684232db0..c876215513 100644 --- a/samples/rotateEncryptionKey.js +++ b/samples/rotateEncryptionKey.js @@ -52,7 +52,7 @@ function main( encryptionKey: Buffer.from(newKey, 'base64'), }); - console.log(`Encryption key rotated successfully.`); + console.log('Encryption key rotated successfully.'); } rotateEncryptionKey().catch(console.error); diff --git a/samples/setEventBasedHold.js b/samples/setEventBasedHold.js index fd7a7224e7..7fb1a870f8 100644 --- a/samples/setEventBasedHold.js +++ b/samples/setEventBasedHold.js @@ -36,12 +36,9 @@ function main(bucketName = 'my-bucket', fileName = 'test.txt') { async function setEventBasedHold() { // Set event-based hold - await storage - .bucket(bucketName) - .file(fileName) - .setMetadata({ - eventBasedHold: true, - }); + await storage.bucket(bucketName).file(fileName).setMetadata({ + eventBasedHold: true, + }); console.log(`Event-based hold was set for ${fileName}.`); } diff --git a/samples/setTemporarydHold.js b/samples/setTemporarydHold.js index 71074419f1..b71073c195 100644 --- a/samples/setTemporarydHold.js +++ b/samples/setTemporarydHold.js @@ -35,12 +35,9 @@ function main(bucketName = 'my-bucket', fileName = 'test.txt') { const storage = new Storage(); async function setTemporarydHold() { - await storage - .bucket(bucketName) - .file(fileName) - .setMetadata({ - temporaryHold: true, - }); + await storage.bucket(bucketName).file(fileName).setMetadata({ + temporaryHold: true, + }); console.log(`Temporary hold was set for ${fileName}.`); } diff --git a/samples/system-test/buckets.test.js b/samples/system-test/buckets.test.js index d86e92b29a..4d8dbf4289 100644 --- a/samples/system-test/buckets.test.js +++ b/samples/system-test/buckets.test.js @@ -14,7 +14,7 @@ 'use strict'; -const {Storage} = require(`@google-cloud/storage`); +const {Storage} = require('@google-cloud/storage'); const {assert} = require('chai'); const {after, it} = require('mocha'); const cp = require('child_process'); @@ -39,7 +39,7 @@ it('should create a bucket', async () => { }); it('should list buckets', () => { - const output = execSync(`node listBuckets.js`); + const output = execSync('node listBuckets.js'); assert.match(output, /Buckets:/); assert.match(output, new RegExp(bucketName)); }); @@ -64,7 +64,7 @@ it('should set a buckets default KMS key', async () => { ); }); -it(`should enable a bucket's uniform bucket-level access`, async () => { +it("should enable a bucket's uniform bucket-level access", async () => { const output = execSync( `node enableUniformBucketLevelAccess.js ${bucketName}` ); @@ -80,7 +80,7 @@ it(`should enable a bucket's uniform bucket-level access`, async () => { ); }); -it(`should get a bucket's uniform bucket-level access metadata`, async () => { +it("should get a bucket's uniform bucket-level access metadata", async () => { const output = execSync(`node getUniformBucketLevelAccess.js ${bucketName}`); assert.match( @@ -96,7 +96,7 @@ it(`should get a bucket's uniform bucket-level access metadata`, async () => { ); }); -it(`should disable a bucket's uniform bucket-level access`, async () => { +it("should disable a bucket's uniform bucket-level access", async () => { const output = execSync( `node disableUniformBucketLevelAccess.js ${bucketName}` ); @@ -112,7 +112,7 @@ it(`should disable a bucket's uniform bucket-level access`, async () => { ); }); -it(`should delete a bucket`, async () => { +it('should delete a bucket', async () => { const output = execSync(`node deleteBucket.js ${bucketName}`); assert.match(output, new RegExp(`Bucket ${bucketName} deleted.`)); const [exists] = await bucket.exists(); diff --git a/samples/system-test/encryption.test.js b/samples/system-test/encryption.test.js index e9b665baed..77445745f3 100644 --- a/samples/system-test/encryption.test.js +++ b/samples/system-test/encryption.test.js @@ -29,9 +29,9 @@ const storage = new Storage(); const bucketName = `nodejs-storage-samples-${uuid.v4()}`; const bucket = storage.bucket(bucketName); -const fileName = `test.txt`; -const filePath = path.join(__dirname, `../resources`, fileName); -const downloadFilePath = path.join(__dirname, `../resources/downloaded.txt`); +const fileName = 'test.txt'; +const filePath = path.join(__dirname, '../resources', fileName); +const downloadFilePath = path.join(__dirname, '../resources/downloaded.txt'); let key; @@ -48,7 +48,7 @@ after(async () => { }); it('should generate a key', () => { - const output = execSync(`node generateEncryptionKey.js`); + const output = execSync('node generateEncryptionKey.js'); assert.match(output, /Base 64 encoded encryption key:/); const test = /^Base 64 encoded encryption key: ([^\s]+)/; key = output.match(test)[1]; @@ -78,7 +78,7 @@ it('should download a file', () => { }); it('should rotate keys', () => { - let output = execSync(`node generateEncryptionKey.js`); + let output = execSync('node generateEncryptionKey.js'); assert.match(output, /Base 64 encoded encryption key:/); const test = /^Base 64 encoded encryption key: ([^\s]+)/; const newKey = output.match(test)[1]; diff --git a/samples/system-test/hmacKey.test.js b/samples/system-test/hmacKey.test.js index a16cbcd48e..9ca156a7ef 100644 --- a/samples/system-test/hmacKey.test.js +++ b/samples/system-test/hmacKey.test.js @@ -14,7 +14,7 @@ 'use strict'; -const {Storage} = require(`@google-cloud/storage`); +const {Storage} = require('@google-cloud/storage'); const {assert} = require('chai'); const {before, after, describe, it} = require('mocha'); const cp = require('child_process'); @@ -72,7 +72,7 @@ describe('HMAC SA Key samples', () => { assert.include(output, 'The HMAC key is now active.'); }); - it(`should delete HMAC key`, async () => { + it('should delete HMAC key', async () => { // Deactivate then delete execSync( `node hmacKeyDeactivate.js ${hmacKey.metadata.accessId} ${SERVICE_ACCOUNT_PROJECT}` @@ -82,7 +82,7 @@ describe('HMAC SA Key samples', () => { ); assert.include( output, - `The key is deleted, though it may still appear in getHmacKeys() results.` + 'The key is deleted, though it may still appear in getHmacKeys() results.' ); }); }); diff --git a/samples/system-test/iam.test.js b/samples/system-test/iam.test.js index 054eca8182..40d91bc870 100644 --- a/samples/system-test/iam.test.js +++ b/samples/system-test/iam.test.js @@ -69,7 +69,7 @@ it('should add conditional binding to a bucket', async () => { output, `Added the following member(s) with role ${roleName} to ${bucketName}:` ); - assert.include(output, `with condition:`); + assert.include(output, 'with condition:'); assert.include(output, `Title: ${title}`); assert.include(output, `Description: ${description}`); assert.include(output, `Expression: ${expression}`); @@ -79,7 +79,7 @@ it('should list members of a role on a bucket', async () => { const output = execSync(`node viewBucketIamMembers.js ${bucketName}`); assert.match(output, new RegExp(`Bindings for bucket ${bucketName}:`)); assert.match(output, new RegExp(`Role: ${roleName}`)); - assert.match(output, new RegExp(`Members:`)); + assert.match(output, new RegExp('Members:')); assert.match(output, new RegExp(`user:${userEmail}`)); }); @@ -99,5 +99,5 @@ it('should remove conditional binding to a bucket', async () => { const output = execSync( `node removeBucketConditionalBinding.js ${bucketName} ${roleName} '${title}' '${description}' '${expression}'` ); - assert.include(output, `Conditional Binding was removed.`); + assert.include(output, 'Conditional Binding was removed.'); }); diff --git a/samples/system-test/requesterPays.test.js b/samples/system-test/requesterPays.test.js index bd308262c0..1da7404719 100644 --- a/samples/system-test/requesterPays.test.js +++ b/samples/system-test/requesterPays.test.js @@ -49,7 +49,7 @@ after(async () => { await bucket.delete().catch(console.error); }); -it.skip(`should error on requester-pays requests if they are disabled`, () => { +it.skip('should error on requester-pays requests if they are disabled', () => { const result = execSync( `node downloadFileUsingRequesterPays.js ${projectId} ${bucketName} ${fileName} ${downloadFilePath}` ); @@ -60,7 +60,7 @@ it.skip(`should error on requester-pays requests if they are disabled`, () => { ); }); -it(`should fetch requester-pays status on a default bucket`, () => { +it('should fetch requester-pays status on a default bucket', () => { const out = execSync(`node getRequesterPaysStatus.js ${bucketName}`); assert.include( out, @@ -68,7 +68,7 @@ it(`should fetch requester-pays status on a default bucket`, () => { ); }); -it(`should enable requester-pays requests`, () => { +it('should enable requester-pays requests', () => { const out = execSync(`node enableRequesterPays.js ${bucketName}`); assert.include( out, @@ -76,7 +76,7 @@ it(`should enable requester-pays requests`, () => { ); }); -it(`should fetch requester-pays status on a modified bucket`, () => { +it('should fetch requester-pays status on a modified bucket', () => { const out = execSync(`node getRequesterPaysStatus.js ${bucketName}`); assert.include( out, @@ -84,7 +84,7 @@ it(`should fetch requester-pays status on a modified bucket`, () => { ); }); -it(`should download a file using requester-pays requests`, () => { +it('should download a file using requester-pays requests', () => { const out = execSync( `node downloadFileUsingRequesterPays.js ${projectId} ${bucketName} ${fileName} ${downloadFilePath}` ); @@ -95,7 +95,7 @@ it(`should download a file using requester-pays requests`, () => { fs.statSync(downloadFilePath); }); -it(`should disable requester-pays requests`, () => { +it('should disable requester-pays requests', () => { const out = execSync(`node disableRequesterPays.js ${bucketName}`); assert.include( out, diff --git a/samples/uploadEncryptedFile.js b/samples/uploadEncryptedFile.js index 6b811bcc06..57d22ddd6d 100644 --- a/samples/uploadEncryptedFile.js +++ b/samples/uploadEncryptedFile.js @@ -15,8 +15,8 @@ const path = require('path'); function main( bucketName = 'my-bucket', - srcFilename = path.join(__dirname, `../resources`, 'test.txt'), - destFilename = `test.txt`, + srcFilename = path.join(__dirname, '../resources', 'test.txt'), + destFilename = 'test.txt', key = process.env.GOOGLE_CLOUD_KMS_KEY_US ) { // [START storage_upload_encrypted_file] diff --git a/samples/viewBucketIamMembers.js b/samples/viewBucketIamMembers.js index 9954d7f781..08b74f0020 100644 --- a/samples/viewBucketIamMembers.js +++ b/samples/viewBucketIamMembers.js @@ -38,7 +38,7 @@ function main(bucketName = 'my-bucket') { console.log(`Bindings for bucket ${bucketName}:`); for (const binding of bindings) { console.log(` Role: ${binding.role}`); - console.log(` Members:`); + console.log(' Members:'); const members = binding.members; for (const member of members) { @@ -47,7 +47,7 @@ function main(bucketName = 'my-bucket') { const condition = binding.condition; if (condition) { - console.log(` Condiiton:`); + console.log(' Condiiton:'); console.log(` Title: ${condition.title}`); console.log(` Description: ${condition.description}`); console.log(` Expression: ${condition.expression}`); diff --git a/src/acl.ts b/src/acl.ts index 31984864ab..1240b600b9 100644 --- a/src/acl.ts +++ b/src/acl.ts @@ -293,7 +293,7 @@ class AclRoleAccessorMethods { const entities = AclRoleAccessorMethods.entities; const roleGroup = role.toLowerCase() + 's'; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (this as any)[roleGroup] = entities.reduce((acc, entity) => { const isPrefix = entity.charAt(entity.length - 1) === '-'; @@ -306,7 +306,7 @@ class AclRoleAccessorMethods { // Wrap the parent accessor method (e.g. `add` or `delete`) to avoid the // more complex API of specifying an `entity` and `role`. - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (acc as any)[method] = ( entityId: string, options: {}, @@ -343,7 +343,7 @@ class AclRoleAccessorMethods { args.push(callback); } - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (this as any)[accessMethod].apply(this, args); }; }); diff --git a/src/bucket.ts b/src/bucket.ts index 5f220c01a4..103e888cf8 100644 --- a/src/bucket.ts +++ b/src/bucket.ts @@ -20,7 +20,6 @@ import { ExistsCallback, GetConfig, Metadata, - MetadataResponse, ResponseBody, ServiceObject, util, @@ -36,9 +35,10 @@ import * as path from 'path'; import pLimit from 'p-limit'; import {promisify} from 'util'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const snakeize = require('snakeize'); -import {Acl, AddAclCallback} from './acl'; +import {Acl} from './acl'; import {Channel} from './channel'; import { File, @@ -185,7 +185,7 @@ export interface DeleteFilesCallback { export type DeleteLabelsResponse = [Metadata]; -export interface DeleteLabelsCallback extends SetLabelsCallback {} +export type DeleteLabelsCallback = SetLabelsCallback; export type DisableRequesterPaysResponse = [Metadata]; @@ -205,7 +205,7 @@ export interface BucketExistsOptions extends GetConfig { export type BucketExistsResponse = [boolean]; -export interface BucketExistsCallback extends ExistsCallback {} +export type BucketExistsCallback = ExistsCallback; export interface GetBucketOptions extends GetConfig { userProject?: string; @@ -1249,7 +1249,7 @@ class Bucket extends ServiceObject { return this.file(file); }; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any sources = (sources as any).map(convertToFile); const destinationFile = convertToFile(destination); callback = callback || util.noop; @@ -1536,7 +1536,7 @@ class Bucket extends ServiceObject { const topicIsObject = topic !== null && typeof topic === 'object'; if (topicIsObject && util.isCustomType(topic, 'pubsub/topic')) { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any topic = (topic as any).name; } @@ -2180,7 +2180,7 @@ class Bucket extends ServiceObject { }, (err, resp) => { if (err) { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (callback as any)(err, null, null, resp); return; } @@ -2208,7 +2208,7 @@ class Bucket extends ServiceObject { pageToken: resp.nextPageToken, }); } - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (callback as any)(null, files, nextQuery, resp); } ); @@ -3400,7 +3400,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: UploadOptions | UploadCallback, callback?: UploadCallback ): Promise | void { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any if ((global as any)['GCLOUD_SANDBOX_ENV']) { return; } @@ -3421,7 +3421,7 @@ class Bucket extends ServiceObject { if (options.destination instanceof File) { newFile = options.destination; } else if ( - options.destination != null && + options.destination !== null && typeof options.destination === 'string' ) { // Use the string as the name of the file. @@ -3444,7 +3444,7 @@ class Bucket extends ServiceObject { options.metadata.contentType = contentType; } - if (options.resumable != null && typeof options.resumable === 'boolean') { + if (options.resumable !== null && typeof options.resumable === 'boolean') { upload(); } else { // Determine if the upload should be resumable if it's over the threshold. diff --git a/src/file.ts b/src/file.ts index b49aa709b2..d5f36070f2 100644 --- a/src/file.ts +++ b/src/file.ts @@ -29,10 +29,12 @@ import * as crypto from 'crypto'; import * as dateFormat from 'date-and-time'; import * as extend from 'extend'; import * as fs from 'fs'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const hashStreamValidation = require('hash-stream-validation'); import * as mime from 'mime'; import * as once from 'onetime'; import * as os from 'os'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const pumpify = require('pumpify'); import * as resumableUpload from 'gcs-resumable-upload'; import {Duplex, Writable, Readable} from 'stream'; @@ -59,6 +61,7 @@ import { Duplexify, DuplexifyConstructor, } from '@google-cloud/common/build/src/util'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const duplexify: DuplexifyConstructor = require('duplexify'); import {normalize, objectKeyToLowercase} from './util'; import {GaxiosError, Headers, request as gaxiosRequest} from 'gaxios'; @@ -94,13 +97,11 @@ export interface GetSignedPolicyOptions { contentLengthRange?: {min?: number; max?: number}; } -export interface GenerateSignedPostPolicyV2Options - extends GetSignedPolicyOptions {} +export type GenerateSignedPostPolicyV2Options = GetSignedPolicyOptions; export type GenerateSignedPostPolicyV2Response = GetSignedPolicyResponse; -export interface GenerateSignedPostPolicyV2Callback - extends GetSignedPolicyCallback {} +export type GenerateSignedPostPolicyV2Callback = GetSignedPolicyCallback; export interface PolicyFields { [key: string]: string; @@ -220,7 +221,7 @@ export interface MakeFilePrivateOptions { export type MakeFilePrivateResponse = [Metadata]; -export interface MakeFilePrivateCallback extends SetFileMetadataCallback {} +export type MakeFilePrivateCallback = SetFileMetadataCallback; export interface IsPublicCallback { (err: Error | null, resp?: boolean): void; @@ -255,7 +256,7 @@ export interface EncryptionKeyOptions { kmsKeyName?: string; } -export interface RotateEncryptionKeyCallback extends CopyCallback {} +export type RotateEncryptionKeyCallback = CopyCallback; export type RotateEncryptionKeyResponse = CopyResponse; @@ -348,7 +349,7 @@ export interface CreateReadStreamOptions { decompress?: boolean; } -export interface SaveOptions extends CreateWriteStreamOptions {} +export type SaveOptions = CreateWriteStreamOptions; export interface SaveCallback { (err?: Error | null): void; @@ -479,11 +480,11 @@ class File extends ServiceObject { const requestQueryObject: {generation?: number; userProject?: string} = {}; let generation: number; - if (options.generation != null) { + if (options.generation !== null) { if (typeof options.generation === 'string') { generation = Number(options.generation); } else { - generation = options.generation; + generation = options.generation!; } if (!isNaN(generation)) { requestQueryObject.generation = generation; @@ -779,16 +780,16 @@ class File extends ServiceObject { }); this.bucket = bucket; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any this.storage = (bucket as any).parent as Storage; // @TODO Can this duplicate code from above be avoided? - if (options.generation != null) { + if (options.generation !== null) { let generation: number; if (typeof options.generation === 'string') { generation = Number(options.generation); } else { - generation = options.generation; + generation = options.generation!; } if (!isNaN(generation)) { this.generation = generation; @@ -967,6 +968,7 @@ class File extends ServiceObject { options = optionsOrCallback; } + // eslint-disable-next-line no-prototype-builtins if (options.hasOwnProperty('keepAcl')) { // TODO: remove keepAcl from interface in next major. emitWarning(); @@ -1185,7 +1187,7 @@ class File extends ServiceObject { typeof options.start === 'number' || typeof options.end === 'number'; const tailRequest = options.end! < 0; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let validateStream: any; // Created later, if necessary. // TODO: remove `through2` dependency in favor of native PassThrough @@ -1199,7 +1201,7 @@ class File extends ServiceObject { let refreshedMetadata = false; if (typeof options.validation === 'string') { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (options as any).validation = (options.validation as string).toLowerCase(); crc32c = options.validation === 'crc32c'; md5 = options.validation === 'md5'; @@ -1259,7 +1261,7 @@ class File extends ServiceObject { }) .on('response', res => { throughStream.emit('response', res); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any util.handleResp(null, res, null, onResponse as any); }) .resume(); @@ -1308,7 +1310,7 @@ class File extends ServiceObject { if (throughStreams.length === 1) { rawResponseStream = - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any rawResponseStream.pipe(throughStreams[0]) as any; } else if (throughStreams.length > 1) { rawResponseStream = rawResponseStream.pipe( @@ -1692,7 +1694,7 @@ class File extends ServiceObject { * // The file upload is complete. * }); */ - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any createWriteStream(options: CreateWriteStreamOptions = {}): Writable { options = Object.assign({metadata: {}}, options); @@ -2045,7 +2047,7 @@ class File extends ServiceObject { ); this.encryptionKeyHash = crypto .createHash('sha256') - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .update(this.encryptionKeyBase64, 'base64' as any) .digest('base64'); @@ -2979,7 +2981,7 @@ class File extends ServiceObject { const query = { predefinedAcl: options.strict ? 'private' : 'projectPrivate', - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; if (options.userProject) { @@ -3312,9 +3314,11 @@ class File extends ServiceObject { this.copy(newFile, callback!); } - // tslint:disable:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any save(data: any, options?: SaveOptions): Promise; + // eslint-disable-next-line @typescript-eslint/no-explicit-any save(data: any, callback: SaveCallback): void; + // eslint-disable-next-line @typescript-eslint/no-explicit-any save(data: any, options: SaveOptions, callback: SaveCallback): void; /** * @typedef {object} SaveOptions @@ -3365,6 +3369,7 @@ class File extends ServiceObject { * file.save(contents).then(function() {}); */ save( + // eslint-disable-next-line @typescript-eslint/no-explicit-any data: any, optionsOrCallback?: SaveOptions | SaveCallback, callback?: SaveCallback diff --git a/src/iam.ts b/src/iam.ts index fc23f2536a..657cc62d35 100644 --- a/src/iam.ts +++ b/src/iam.ts @@ -248,7 +248,10 @@ class Iam { qs.userProject = options.userProject; } - if (options.requestedPolicyVersion != null) { + if ( + options.requestedPolicyVersion !== null && + options.requestedPolicyVersion !== undefined + ) { qs.optionsRequestedPolicyVersion = options.requestedPolicyVersion; } diff --git a/src/notification.ts b/src/notification.ts index a0b5f06836..9f8cf4f54f 100644 --- a/src/notification.ts +++ b/src/notification.ts @@ -333,7 +333,7 @@ class Notification extends ServiceObject { args.push(onCreate); - // tslint:disable-next-line no-any + // eslint-disable-next-line this.create.apply(this, args as any); return; } diff --git a/src/signer.ts b/src/signer.ts index fa7271d5f0..af83e483ff 100644 --- a/src/signer.ts +++ b/src/signer.ts @@ -170,7 +170,7 @@ export class URLSigner { this.bucket.name, config.file ); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any signedUrl.search = qsStringify(query as any); return signedUrl.href; }); @@ -278,7 +278,7 @@ export class URLSigner { ...(config.queryParams || {}), }; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any const canonicalQueryParams = this.getCanonicalQueryParams(queryParams); const canonicalRequest = this.getCanonicalRequest( @@ -343,7 +343,7 @@ export class URLSigner { .sort((a, b) => a[0].localeCompare(b[0])); return sortedHeaders - .filter(([_, value]) => value !== undefined) + .filter(([, value]) => value !== undefined) .map(([headerName, value]) => { // - Convert Array (multi-valued header) into string, delimited by // ',' (no space). diff --git a/src/storage.ts b/src/storage.ts index ab1e03305d..479938ad65 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -599,7 +599,7 @@ export class Storage extends Service { metadata = metadataOrCallback as CreateBucketRequest; } - const body = Object.assign({}, metadata, {name}) as { + const body = (Object.assign({}, metadata, {name}) as {}) as { [index: string]: string | {}; }; @@ -1091,6 +1091,7 @@ export class Storage extends Service { const camelCaseResponse = {} as {[index: string]: string}; for (const prop in resp) { + // eslint-disable-next-line no-prototype-builtins if (resp.hasOwnProperty(prop)) { const camelCaseProp = prop.replace(/_(\w)/g, (_, match) => match.toUpperCase() diff --git a/src/util.ts b/src/util.ts index e9725b9bb5..19d0b77ed3 100644 --- a/src/util.ts +++ b/src/util.ts @@ -48,12 +48,7 @@ export function objectEntries(obj: {[key: string]: T}): Array<[string, T]> { export function fixedEncodeURIComponent(str: string): string { return encodeURIComponent(str).replace( /[!'()*]/g, - c => - '%' + - c - .charCodeAt(0) - .toString(16) - .toUpperCase() + c => '%' + c.charCodeAt(0).toString(16).toUpperCase() ); } diff --git a/system-test/storage.ts b/system-test/storage.ts index 3375186573..b24cfe463e 100644 --- a/system-test/storage.ts +++ b/system-test/storage.ts @@ -13,11 +13,12 @@ // limitations under the License. import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; import * as crypto from 'crypto'; import * as fs from 'fs'; -import fetch, {Request} from 'node-fetch'; +import fetch from 'node-fetch'; import * as FormData from 'form-data'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const normalizeNewline = require('normalize-newline'); import pLimit from 'p-limit'; import {promisify} from 'util'; @@ -25,14 +26,7 @@ import * as path from 'path'; import * as through from 'through2'; import * as tmp from 'tmp'; import * as uuid from 'uuid'; -import { - util, - ApiError, - InstanceResponseCallback, - BodyResponseCallback, - MetadataResponse, - Metadata, -} from '@google-cloud/common'; +import {util, ApiError, Metadata} from '@google-cloud/common'; import { Storage, Bucket, @@ -51,7 +45,6 @@ import { MakeBucketPrivateCallback, SetBucketMetadataOptions, SetBucketMetadataCallback, - DeleteFileCallback, SaveCallback, DownloadOptions, DownloadCallback, @@ -91,14 +84,13 @@ import { GetNotificationMetadataCallback, DeleteNotificationOptions, DeleteNotificationCallback, - Iam, } from '../src'; import * as nock from 'nock'; interface ErrorCallbackFunction { (err: Error | null): void; } -const {PubSub} = require('@google-cloud/pubsub'); +import {PubSub} from '@google-cloud/pubsub'; // When set to true, skips all tests that is not compatible for // running inside VPCSC. @@ -106,7 +98,7 @@ const RUNNING_IN_VPCSC = !!process.env['GOOGLE_CLOUD_TESTS_IN_VPCSC']; // block all attempts to chat with the metadata server (kokoro runs on GCE) nock('http://metadata.google.internal') - .get(url => true) + .get(() => true) .replyWithError({code: 'ENOTFOUND'}) .persist(); @@ -121,9 +113,9 @@ describe('storage', () => { const pubsub = new PubSub({ projectId: process.env.PROJECT_ID, }); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let topic: any; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any const FILES: {[index: string]: any} = { logo: { path: path.join( @@ -175,6 +167,7 @@ describe('storage', () => { let storageWithoutAuth: Storage; let GOOGLE_APPLICATION_CREDENTIALS: string | undefined; + // eslint-disable-next-line @typescript-eslint/no-unused-vars let GOOGLE_CLOUD_PROJECT: string | undefined; before(done => { @@ -193,6 +186,7 @@ describe('storage', () => { delete process.env.GOOGLE_CLOUD_PROJECT; delete require.cache[require.resolve('../src')]; + // eslint-disable-next-line @typescript-eslint/no-var-requires const {Storage} = require('../src'); storageWithoutAuth = new Storage(); }); @@ -203,7 +197,7 @@ describe('storage', () => { }); describe('public data', () => { - before(function() { + before(function () { if (RUNNING_IN_VPCSC) this.skip(); }); @@ -452,7 +446,7 @@ describe('storage', () => { }); it('should get access controls', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.acl.get(done as any, (err, accessControls) => { assert.ifError(err); assert(Array.isArray(accessControls)); @@ -461,7 +455,7 @@ describe('storage', () => { }); it('should not expose default api', () => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any assert.strictEqual(typeof (file as any).default, 'undefined'); }); @@ -879,7 +873,7 @@ describe('storage', () => { }); describe('unicode validation', () => { - before(function() { + before(function () { if (RUNNING_IN_VPCSC) this.skip(); }); @@ -1686,7 +1680,7 @@ describe('storage', () => { USER_PROJECT_OPTIONS ); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any function createFileAsync(fileObject: any) { return fileObject.file.save( fileObject.contents, @@ -1726,7 +1720,7 @@ describe('storage', () => { it( 'bucket#get', doubleTest((options: GetBucketOptions, done: GetBucketCallback) => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any bucketNonWhitelist.get(options, done as any); }) ); @@ -1734,7 +1728,7 @@ describe('storage', () => { it( 'bucket#getMetadata', doubleTest((options: GetBucketOptions, done: GetBucketCallback) => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any bucketNonWhitelist.get(options, done as any); }) ); @@ -2363,14 +2357,14 @@ describe('storage', () => { }); }); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any function upload(opts: any, callback: ErrorCallbackFunction) { const ws = file.createWriteStream(); let sizeStreamed = 0; fs.createReadStream(FILES.big.path) .pipe( - through(function(chunk, enc, next) { + through(function (chunk, enc, next) { sizeStreamed += chunk.length; if (opts.interrupt && sizeStreamed >= fileSize / 2) { @@ -2395,7 +2389,7 @@ describe('storage', () => { it('should write/read/remove from a buffer', done => { tmp.setGracefulCleanup(); - tmp.file(function _tempFileCreated(err, tmpFilePath) { + tmp.file((err, tmpFilePath) => { assert.ifError(err); const file = bucket.file('MyBuffer'); @@ -2952,7 +2946,7 @@ describe('storage', () => { }); describe('second service account', () => { - before(async function() { + before(async function () { if (!SECOND_SERVICE_ACCOUNT) { this.skip(); } @@ -2960,14 +2954,14 @@ describe('storage', () => { }); it('should create key for a second service account', async () => { - const _ = await storage.createHmacKey(SECOND_SERVICE_ACCOUNT!, { + await storage.createHmacKey(SECOND_SERVICE_ACCOUNT!, { projectId: HMAC_PROJECT, }); }); it('get HMAC keys for both service accounts', async () => { // Create a key for the first service account - const _ = await storage.createHmacKey(SERVICE_ACCOUNT!, { + await storage.createHmacKey(SERVICE_ACCOUNT!, { projectId: HMAC_PROJECT, }); @@ -3392,7 +3386,7 @@ describe('storage', () => { file = bucket.file('LogoToSign.jpg'); }); - beforeEach(function() { + beforeEach(function () { if (!storage.projectId) { this.skip(); } @@ -3447,7 +3441,7 @@ describe('storage', () => { describe('notifications', () => { let notification: Notification; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let subscription: any; before(() => { @@ -3470,10 +3464,10 @@ describe('storage', () => { .then(() => { return bucket.getNotifications(); }) - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .then((data: any) => { return Promise.all( - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any data[0].map((notification: any) => { return notification.delete(); }) @@ -3525,7 +3519,7 @@ describe('storage', () => { }); it('should emit events to a subscription', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any subscription.on('error', done).on('message', (message: any) => { const attrs = message.attributes; assert.strictEqual(attrs.eventType, 'OBJECT_FINALIZE'); @@ -3621,16 +3615,13 @@ describe('storage', () => { return file.delete(); } - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any function deleteTopicAsync(topic: any) { return topic.delete(); } function shortUUID() { - return uuid - .v1() - .split('-') - .shift(); + return uuid.v1().split('-').shift(); } function generateName() { @@ -3650,7 +3641,7 @@ describe('storage', () => { async function deleteAllTopicsAsync() { const [topics] = await pubsub.getTopics(); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any const filteredTopics = (topics as any[]).filter(topic => { return topic.name.indexOf(TESTS_PREFIX) > -1; }); @@ -3701,7 +3692,7 @@ describe('storage', () => { ); } - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any function createFileAsync(fileObject: any) { return fileObject.file.save(fileObject.contents); } diff --git a/test/acl.ts b/test/acl.ts index d5d08d0042..d78f2227eb 100644 --- a/test/acl.ts +++ b/test/acl.ts @@ -14,12 +14,11 @@ import {DecorateRequestOptions, Metadata, util} from '@google-cloud/common'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; -// tslint:disable-next-line:variable-name no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any let Acl: any; -// tslint:disable-next-line:variable-name let AclRoleAccessorMethods: Function; describe('storage/acl', () => { let promisified = false; @@ -32,9 +31,9 @@ describe('storage/acl', () => { }, }; - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/no-var-requires const {Storage} = require('../src'); - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let acl: any; const ERROR = new Error('Error.'); @@ -493,11 +492,11 @@ describe('storage/acl', () => { }); describe('storage/AclRoleAccessorMethods', () => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let aclEntity: any; beforeEach(() => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any aclEntity = new (AclRoleAccessorMethods as any)(); }); diff --git a/test/bucket.ts b/test/bucket.ts index 1bec829762..ce630dddad 100644 --- a/test/bucket.ts +++ b/test/bucket.ts @@ -21,12 +21,13 @@ import { } from '@google-cloud/common'; import arrify = require('arrify'); import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; import * as mime from 'mime-types'; import pLimit from 'p-limit'; import * as path from 'path'; import * as proxyquire from 'proxyquire'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const snakeize = require('snakeize'); import * as stream from 'stream'; import * as through from 'through2'; @@ -59,6 +60,7 @@ class FakeFile { createWriteStream: Function; isSameFile = () => false; constructor(bucket: Bucket, name: string, options?: FileOptions) { + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; this.bucket = bucket; this.name = name; @@ -138,9 +140,9 @@ class FakeAcl { } class FakeIam { - calledWith_: IArguments; - constructor() { - this.calledWith_ = arguments; + calledWith_: Array<{}>; + constructor(...args: Array<{}>) { + this.calledWith_ = args; } } @@ -148,6 +150,7 @@ class FakeServiceObject extends ServiceObject { calledWith_: IArguments; constructor(config: ServiceObjectConfig) { super(config); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } @@ -157,9 +160,9 @@ const fakeSigner = { }; describe('Bucket', () => { - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Bucket: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let bucket: any; const STORAGE = { @@ -999,7 +1002,7 @@ describe('Bucket', () => { return () => {}; }; - bucket.getFiles = (query: {}) => Promise.resolve([[]]); + bucket.getFiles = () => Promise.resolve([[]]); bucket.deleteFiles({}, assert.ifError); }); @@ -1031,7 +1034,7 @@ describe('Bucket', () => { it('should execute callback with error from getting files', done => { const error = new Error('Error.'); - bucket.getFiles = (query: {}) => { + bucket.getFiles = () => { return Promise.reject(error); }; @@ -1045,11 +1048,11 @@ describe('Bucket', () => { const error = new Error('Error.'); const files = [bucket.file('1'), bucket.file('2')].map(file => { - file.delete = (query: {}) => Promise.reject(error); + file.delete = () => Promise.reject(error); return file; }); - bucket.getFiles = (query: {}) => { + bucket.getFiles = () => { return Promise.resolve([files]); }; @@ -1063,11 +1066,11 @@ describe('Bucket', () => { const error = new Error('Error.'); const files = [bucket.file('1'), bucket.file('2')].map(file => { - file.delete = (query: {}) => Promise.reject(error); + file.delete = () => Promise.reject(error); return file; }); - bucket.getFiles = (query: {}) => { + bucket.getFiles = () => { return Promise.resolve([files]); }; @@ -1430,7 +1433,7 @@ describe('Bucket', () => { it('should strip excess slashes from a directory', done => { const directory = 'directory-name///'; bucket.request = (reqOpts: DecorateRequestOptions) => { - assert.strictEqual(reqOpts.qs.prefix, `directory-name/`); + assert.strictEqual(reqOpts.qs.prefix, 'directory-name/'); done(); }; bucket.getFiles({directory}, assert.ifError); @@ -1748,7 +1751,7 @@ describe('Bucket', () => { getSignedUrl: signerGetSignedUrlStub, }; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any urlSignerStub = (sandbox.stub as any)(fakeSigner, 'URLSigner').returns( signer ); @@ -1792,7 +1795,7 @@ describe('Bucket', () => { }); it('should error if action is null', () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any SIGNED_URL_CONFIG.action = null as any; assert.throws(() => { @@ -1808,7 +1811,7 @@ describe('Bucket', () => { }); it('should error for an invalid action', () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any SIGNED_URL_CONFIG.action = 'watch' as any; assert.throws(() => { @@ -1977,28 +1980,17 @@ describe('Bucket', () => { }); it('should not make files public by default', done => { - bucket.acl.add = (opts: {}) => { - return Promise.resolve(); - }; - - bucket.acl.default.add = (opts: {}) => { - return Promise.resolve(); - }; - + bucket.acl.add = () => Promise.resolve(); + bucket.acl.default.add = () => Promise.resolve(); bucket.makeAllFilesPublicPrivate_ = () => { throw new Error('Please, no. I do not want to be called.'); }; - bucket.makePublic(done); }); it('should execute callback with error', done => { const error = new Error('Error.'); - - bucket.acl.add = (opts: {}) => { - return Promise.reject(error); - }; - + bucket.acl.add = () => Promise.reject(error); bucket.makePublic((err: Error) => { assert.strictEqual(err, error); done(); @@ -2050,7 +2042,7 @@ describe('Bucket', () => { ) => { assert.strictEqual(reqOpts.qs.userProject, USER_PROJECT); done(); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any; bucket.request({}, assert.ifError); @@ -2069,7 +2061,7 @@ describe('Bucket', () => { assert.strictEqual(reqOpts.qs, options.qs); assert.strictEqual(reqOpts.qs.userProject, USER_PROJECT); done(); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any; bucket.request(options, assert.ifError); @@ -2088,7 +2080,7 @@ describe('Bucket', () => { ) => { assert.strictEqual(reqOpts.qs.userProject, fakeUserProject); done(); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any; bucket.request(options, assert.ifError); @@ -2261,10 +2253,10 @@ describe('Bucket', () => { }); it('should return early in snippet sandbox', () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (global as any)['GCLOUD_SANDBOX_ENV'] = true; const returnValue = bucket.upload(filepath, assert.ifError); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any delete (global as any)['GCLOUD_SANDBOX_ENV']; assert.strictEqual(returnValue, undefined); }); @@ -2504,7 +2496,7 @@ describe('Bucket', () => { return () => {}; }; - bucket.getFiles = (options: {}) => Promise.resolve([[]]); + bucket.getFiles = () => Promise.resolve([[]]); bucket.makeAllFilesPublicPrivate_({}, assert.ifError); }); @@ -2517,11 +2509,7 @@ describe('Bucket', () => { }; return file; }); - - bucket.getFiles = (options: {}) => { - return Promise.resolve([files]); - }; - + bucket.getFiles = () => Promise.resolve([files]); bucket.makeAllFilesPublicPrivate_({public: true}, (err: Error) => { assert.ifError(err); assert.strictEqual(timesCalled, files.length); @@ -2536,17 +2524,14 @@ describe('Bucket', () => { let timesCalled = 0; const files = [bucket.file('1'), bucket.file('2')].map(file => { - file.makePrivate = (options_: {}) => { + file.makePrivate = () => { timesCalled++; return Promise.resolve(); }; return file; }); - bucket.getFiles = (options_: {}) => { - return Promise.resolve([files]); - }; - + bucket.getFiles = () => Promise.resolve([files]); bucket.makeAllFilesPublicPrivate_(options, (err: Error) => { assert.ifError(err); assert.strictEqual(timesCalled, files.length); @@ -2556,11 +2541,7 @@ describe('Bucket', () => { it('should execute callback with error from getting files', done => { const error = new Error('Error.'); - - bucket.getFiles = (options: {}) => { - return Promise.reject(error); - }; - + bucket.getFiles = () => Promise.reject(error); bucket.makeAllFilesPublicPrivate_({}, (err: Error) => { assert.strictEqual(err, error); done(); @@ -2569,16 +2550,11 @@ describe('Bucket', () => { it('should execute callback with error from changing file', done => { const error = new Error('Error.'); - const files = [bucket.file('1'), bucket.file('2')].map(file => { file.makePublic = () => Promise.reject(error); return file; }); - - bucket.getFiles = (options: {}) => { - return Promise.resolve([files]); - }; - + bucket.getFiles = () => Promise.resolve([files]); bucket.makeAllFilesPublicPrivate_({public: true}, (err: Error) => { assert.strictEqual(err, error); done(); @@ -2587,16 +2563,11 @@ describe('Bucket', () => { it('should execute callback with queued errors', done => { const error = new Error('Error.'); - const files = [bucket.file('1'), bucket.file('2')].map(file => { file.makePublic = () => Promise.reject(error); return file; }); - - bucket.getFiles = (options: {}) => { - return Promise.resolve([files]); - }; - + bucket.getFiles = () => Promise.resolve([files]); bucket.makeAllFilesPublicPrivate_( { public: true, @@ -2620,7 +2591,7 @@ describe('Bucket', () => { return file; }); - bucket.getFiles = (options: {}) => { + bucket.getFiles = () => { const files = successFiles.concat(errorFiles); return Promise.resolve([files]); }; diff --git a/test/channel.ts b/test/channel.ts index 997487506e..aaa975c51f 100644 --- a/test/channel.ts +++ b/test/channel.ts @@ -22,12 +22,11 @@ import { ServiceObjectConfig, } from '@google-cloud/common'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; let promisified = false; const fakePromisify = { - // tslint:disable-next-line:variable-name promisifyAll(Class: Function) { if (Class.name === 'Channel') { promisified = true; @@ -39,6 +38,7 @@ class FakeServiceObject extends ServiceObject { calledWith_: IArguments; constructor(config: ServiceObjectConfig) { super(config); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } @@ -48,9 +48,9 @@ describe('Channel', () => { const ID = 'channel-id'; const RESOURCE_ID = 'resource-id'; - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Channel: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let channel: any; before(() => { diff --git a/test/file.ts b/test/file.ts index cf0f5ad998..72b40e6d90 100644 --- a/test/file.ts +++ b/test/file.ts @@ -21,7 +21,7 @@ import { } from '@google-cloud/common'; import {PromisifyAllOptions} from '@google-cloud/promisify'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as crypto from 'crypto'; import * as dateFormat from 'date-and-time'; import * as duplexify from 'duplexify'; @@ -39,13 +39,13 @@ import * as gaxios from 'gaxios'; import { Bucket, + // eslint-disable-next-line @typescript-eslint/no-unused-vars File, FileOptions, GetFileMetadataOptions, PolicyDocument, SetFileMetadataOptions, GetSignedUrlConfig, - GetSignedPolicyOptions, GenerateSignedPostPolicyV2Options, GenerateSignedPostPolicyV2Callback, } from '../src'; @@ -54,19 +54,16 @@ import { GenerateSignedPostPolicyV4Options, STORAGE_POST_POLICY_BASE_URL, } from '../src/file'; -import {fixedEncodeURIComponent} from '../src/util'; let promisified = false; let makeWritableStreamOverride: Function | null; let handleRespOverride: Function | null; const fakeUtil = Object.assign({}, util, { - handleResp() { - (handleRespOverride || util.handleResp).apply(null, arguments); + handleResp(...args: Array<{}>) { + (handleRespOverride || util.handleResp)(...args); }, - - makeWritableStream() { - const args = arguments; - (makeWritableStreamOverride || util.makeWritableStream).apply(null, args); + makeWritableStream(...args: Array<{}>) { + (makeWritableStreamOverride || util.makeWritableStream)(...args); }, }); @@ -88,27 +85,23 @@ const fakeFs = extend(true, {}, fsCached); const zlibCached = extend(true, {}, zlib); let createGunzipOverride: Function | null; const fakeZlib = extend(true, {}, zlib, { - createGunzip() { - return (createGunzipOverride || zlibCached.createGunzip).apply( - null, - arguments - ); + createGunzip(...args: Array<{}>) { + return (createGunzipOverride || zlibCached.createGunzip)(...args); }, }); let hashStreamValidationOverride: Function | null; +// eslint-disable-next-line @typescript-eslint/no-var-requires const hashStreamValidation = require('hash-stream-validation'); -function fakeHashStreamValidation() { - return (hashStreamValidationOverride || hashStreamValidation).apply( - null, - arguments - ); +function fakeHashStreamValidation(...args: Array<{}>) { + return (hashStreamValidationOverride || hashStreamValidation)(...args); } +// eslint-disable-next-line @typescript-eslint/no-var-requires const osCached = extend(true, {}, require('os')); const fakeOs = extend(true, {}, osCached); -// tslint:disable-next-line: no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any let resumableUploadOverride: any; function fakeResumableUpload() { return () => { @@ -125,7 +118,7 @@ Object.assign(fakeResumableUpload, { createURI = resumableUploadOverride.createURI; } - return createURI.apply(null, args); + return createURI(...args); }, }); Object.assign(fakeResumableUpload, { @@ -134,7 +127,7 @@ Object.assign(fakeResumableUpload, { if (resumableUploadOverride && resumableUploadOverride.upload) { upload = resumableUploadOverride.upload; } - return upload.apply(null, args); + return upload(...args); }, }); @@ -142,12 +135,14 @@ class FakeServiceObject extends ServiceObject { calledWith_: IArguments; constructor(config: ServiceObjectConfig) { super(config); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } -// tslint:disable-next-line: no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any let xdgConfigOverride: any; +// eslint-disable-next-line @typescript-eslint/no-var-requires const xdgBasedirCached = require('xdg-basedir'); const fakeXdgBasedir = extend(true, {}, xdgBasedirCached); Object.defineProperty(fakeXdgBasedir, 'config', { @@ -163,21 +158,21 @@ const fakeSigner = { }; describe('File', () => { - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let File: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let file: any; const FILE_NAME = 'file-name.png'; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let directoryFile: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let specialCharsFile: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let STORAGE: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let BUCKET: any; before(() => { @@ -201,13 +196,13 @@ describe('File', () => { extend(true, fakeFs, fsCached); extend(true, fakeOs, osCached); xdgConfigOverride = null; - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any FakeServiceObject.prototype.request = util.noop as any; STORAGE = { createBucket: util.noop, request: util.noop, - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeAuthenticatedRequest(req: {}, callback: any) { if (callback) { (callback.onAuthenticated || callback)(null, req); @@ -323,15 +318,13 @@ describe('File', () => { it('should set a custom encryption key', done => { const key = 'key'; - const setEncryptionKey = File.prototype.setEncryptionKey; File.prototype.setEncryptionKey = (key_: {}) => { File.prototype.setEncryptionKey = setEncryptionKey; assert.strictEqual(key_, key); done(); }; - - const _file = new File(BUCKET, FILE_NAME, {encryptionKey: key}); + new File(BUCKET, FILE_NAME, {encryptionKey: key}); }); describe('userProject', () => { @@ -358,17 +351,17 @@ describe('File', () => { describe('copy', () => { describe('depricate `keepAcl`', () => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line let STORAGE2: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line let BUCKET2: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let file2: any; beforeEach(() => { STORAGE2 = { createBucket: util.noop, request: util.noop, - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeAuthenticatedRequest(req: {}, callback: any) { if (callback) { (callback.onAuthenticated || callback)(null, req); @@ -614,7 +607,7 @@ describe('File', () => { describe('destination types', () => { function assertPathEquals( - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file: any, expectedPath: string, callback: Function @@ -646,7 +639,7 @@ describe('File', () => { it('should allow a "gs://..." string', done => { const newFileName = 'gs://other-bucket/new-file-name.png'; - const expectedPath = `/rewriteTo/b/other-bucket/o/new-file-name.png`; + const expectedPath = '/rewriteTo/b/other-bucket/o/new-file-name.png'; assertPathEquals(file, expectedPath, done); file.copy(newFileName); }); @@ -714,7 +707,7 @@ describe('File', () => { reqOpts: DecorateRequestOptions, callback: Function ) => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.copy = (newFile_: {}, options: any) => { assert.notStrictEqual(options, fakeOptions); assert.strictEqual(options.userProject, fakeOptions.userProject); @@ -737,7 +730,7 @@ describe('File', () => { reqOpts: DecorateRequestOptions, callback: Function ) => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.copy = (newFile_: {}, options: any) => { assert.strictEqual( options.destinationKmsKeyName, @@ -850,12 +843,9 @@ describe('File', () => { class FakeSuccessfulRequest extends FakeRequest { constructor(req?: DecorateRequestOptions) { super(req); - - const self = this; - setImmediate(() => { const stream = new FakeRequest(); - self.emit('response', stream); + this.emit('response', stream); }); } } @@ -876,11 +866,8 @@ describe('File', () => { class FakeFailedRequest extends FakeRequest { constructor(_req?: DecorateRequestOptions) { super(_req); - - const self = this; - setImmediate(() => { - self.emit('error', error); + this.emit('error', error); }); } } @@ -1120,7 +1107,7 @@ describe('File', () => { it('should emit errors from the request stream', done => { const error = new Error('Error.'); const rawResponseStream = through(); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (rawResponseStream as any).toJSON = () => { return {headers: {}}; }; @@ -1157,7 +1144,7 @@ describe('File', () => { it('should not handle both error and end events', done => { const error = new Error('Error.'); const rawResponseStream = through(); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (rawResponseStream as any).toJSON = () => { return {headers: {}}; }; @@ -1186,11 +1173,9 @@ describe('File', () => { callback(); }; - let errorReceived = false; file .createReadStream({validation: false}) .on('error', (err: Error) => { - errorReceived = true; assert.strictEqual(err, error); rawResponseStream.emit('end'); setImmediate(done); @@ -1425,10 +1410,7 @@ describe('File', () => { file.requestStream = getFakeSuccessfulRequest(data); - file - .createReadStream(fakeOptions) - .on('error', done) - .resume(); + file.createReadStream(fakeOptions).on('error', done).resume(); }); it('should destroy stream from failed metadata fetch', done => { @@ -1460,7 +1442,7 @@ describe('File', () => { it('should emit an error if crc32c validation fails', done => { file.requestStream = getFakeSuccessfulRequest('bad-data'); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (fakeValidationStream as any).test = () => false; file .createReadStream({validation: 'crc32c'}) @@ -1473,7 +1455,7 @@ describe('File', () => { it('should validate with md5', done => { file.requestStream = getFakeSuccessfulRequest(data); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (fakeValidationStream as any).test = () => true; file .createReadStream({validation: 'md5'}) @@ -1484,7 +1466,7 @@ describe('File', () => { it('should emit an error if md5 validation fails', done => { file.requestStream = getFakeSuccessfulRequest('bad-data'); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (fakeValidationStream as any).test = () => false; file .createReadStream({validation: 'md5'}) @@ -1514,7 +1496,7 @@ describe('File', () => { it('should ignore a data mismatch if validation: false', done => { file.requestStream = getFakeSuccessfulRequest(data); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (fakeValidationStream as any).test = () => false; file .createReadStream({validation: false}) @@ -1525,7 +1507,7 @@ describe('File', () => { describe('destroying the through stream', () => { beforeEach(() => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (fakeValidationStream as any).test = () => false; }); @@ -1653,7 +1635,7 @@ describe('File', () => { describe('createResumableUpload', () => { it('should not require options', done => { resumableUploadOverride = { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any createURI(opts: any, callback: Function) { assert.strictEqual(opts.metadata, undefined); callback(); @@ -1681,7 +1663,7 @@ describe('File', () => { file.kmsKeyName = 'kms-key-name'; resumableUploadOverride = { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any createURI(opts: any, callback: Function) { const bucket = file.bucket; const storage = bucket.storage; @@ -1882,7 +1864,7 @@ describe('File', () => { metadata: METADATA, }); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.deepStrictEqual(options.metadata, METADATA); done(); @@ -1894,7 +1876,7 @@ describe('File', () => { it('should alias contentType to metadata object', done => { const contentType = 'text/html'; const writable = file.createWriteStream({contentType}); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.strictEqual(options.metadata.contentType, contentType); done(); @@ -1905,7 +1887,7 @@ describe('File', () => { it('should detect contentType with contentType:auto', done => { const writable = file.createWriteStream({contentType: 'auto'}); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.strictEqual(options.metadata.contentType, 'image/png'); done(); @@ -1916,7 +1898,7 @@ describe('File', () => { it('should set encoding with gzip:true', done => { const writable = file.createWriteStream({gzip: true}); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.strictEqual(options.metadata.contentEncoding, 'gzip'); done(); @@ -1931,7 +1913,7 @@ describe('File', () => { contentType: 'text/html', // (compressible) }); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.strictEqual(options.metadata.contentEncoding, 'gzip'); done(); @@ -1942,7 +1924,7 @@ describe('File', () => { it('should not set encoding with gzip:auto & non-compressible', done => { const writable = file.createWriteStream({gzip: 'auto'}); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.startResumableUpload_ = (stream: {}, options: any) => { assert.strictEqual(options.metadata.contentEncoding, undefined); done(); @@ -2198,7 +2180,7 @@ describe('File', () => { file.generation = 123; resumableUploadOverride = { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any upload(opts: any) { assert.strictEqual(opts.bucket, file.bucket.name); assert.strictEqual(opts.file, file.name); @@ -2310,7 +2292,7 @@ describe('File', () => { describe('with destination', () => { it('should write the file to a destination if provided', done => { tmp.setGracefulCleanup(); - tmp.file(function _tempFileCreated(err, tmpFilePath) { + tmp.file((err, tmpFilePath) => { assert.ifError(err); const fileContents = 'abcdefghijklmnopqrstuvwxyz'; @@ -2337,7 +2319,7 @@ describe('File', () => { it('should execute callback with error', done => { tmp.setGracefulCleanup(); - tmp.file(function _tempFileCreated(err, tmpFilePath) { + tmp.file((err, tmpFilePath) => { assert.ifError(err); const error = new Error('Error.'); @@ -2395,7 +2377,7 @@ describe('File', () => { (err: Error, expirationDate: {}, apiResponse_: {}) => { assert.strictEqual( err.message, - `An expiration time is not available.` + 'An expiration time is not available.' ); assert.strictEqual(expirationDate, null); assert.strictEqual(apiResponse_, apiResponse); @@ -2468,7 +2450,7 @@ describe('File', () => { return Promise.resolve('signature'); }; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.generateSignedPostPolicyV2( CONFIG, (err: Error, signedPolicy: PolicyDocument) => { @@ -2546,7 +2528,7 @@ describe('File', () => { const policy = JSON.parse(signedPolicy.string); assert( - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any policy.conditions.some((condition: any) => { return condition.success_action_redirect === redirectUrl; }) @@ -2571,7 +2553,7 @@ describe('File', () => { const policy = JSON.parse(signedPolicy.string); assert( - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any policy.conditions.some((condition: any) => { return condition.success_action_status === successStatus; }) @@ -2870,7 +2852,7 @@ describe('File', () => { 'hex' ); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.generateSignedPostPolicyV4( CONFIG, (err: Error, res: SignedPostPolicyV4Output) => { @@ -3154,7 +3136,7 @@ describe('File', () => { () => {} ); }, - {message: `Max allowed expiration is seven days (604800 seconds).`} + {message: 'Max allowed expiration is seven days (604800 seconds).'} ); }); }); @@ -3179,7 +3161,7 @@ describe('File', () => { getSignedUrl: signerGetSignedUrlStub, }; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any urlSignerStub = (sandbox.stub as any)(fakeSigner, 'URLSigner').returns( signer ); @@ -3230,7 +3212,7 @@ describe('File', () => { }); it('should error if action is null', () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any SIGNED_URL_CONFIG.action = null as any; assert.throws(() => { @@ -3246,7 +3228,7 @@ describe('File', () => { }); it('should error for an invalid action', () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any SIGNED_URL_CONFIG.action = 'watch' as any; assert.throws(() => { @@ -3260,67 +3242,55 @@ describe('File', () => { 'another-header': 'value', }; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.strictEqual(getSignedUrlArgs[0]['method'], 'POST'); - assert.deepStrictEqual(getSignedUrlArgs[0]['extensionHeaders'], { - 'another-header': 'value', - 'x-goog-resumable': 'start', - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.strictEqual(getSignedUrlArgs[0]['method'], 'POST'); + assert.deepStrictEqual(getSignedUrlArgs[0]['extensionHeaders'], { + 'another-header': 'value', + 'x-goog-resumable': 'start', + }); + done(); + }); }); it('should add response-content-type query parameter', done => { SIGNED_URL_CONFIG.responseType = 'application/json'; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { - 'response-content-type': 'application/json', - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { + 'response-content-type': 'application/json', + }); + done(); + }); }); it('should respect promptSaveAs argument', done => { const filename = 'fname.txt'; SIGNED_URL_CONFIG.promptSaveAs = filename; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { - 'response-content-disposition': - 'attachment; filename="' + filename + '"', - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { + 'response-content-disposition': + 'attachment; filename="' + filename + '"', + }); + done(); + }); }); it('should add response-content-disposition query parameter', done => { const disposition = 'attachment; filename="fname.ext"'; SIGNED_URL_CONFIG.responseDisposition = disposition; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { - 'response-content-disposition': disposition, - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { + 'response-content-disposition': disposition, + }); + done(); + }); }); it('should ignore promptSaveAs if set', done => { @@ -3329,33 +3299,27 @@ describe('File', () => { SIGNED_URL_CONFIG.promptSaveAs = saveAs; SIGNED_URL_CONFIG.responseDisposition = disposition; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { - 'response-content-disposition': disposition, - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { + 'response-content-disposition': disposition, + }); + done(); + }); }); it('should add generation to query parameter', done => { file.generation = '246680131'; - file.getSignedUrl( - SIGNED_URL_CONFIG, - (err: Error | null, _signedUrl: string) => { - assert.ifError(err); - const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; - assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { - generation: file.generation, - }); - done(); - } - ); + file.getSignedUrl(SIGNED_URL_CONFIG, (err: Error | null) => { + assert.ifError(err); + const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args; + assert.deepStrictEqual(getSignedUrlArgs[0]['queryParams'], { + generation: file.generation, + }); + done(); + }); }); }); @@ -3501,7 +3465,7 @@ describe('File', () => { describe('move', () => { describe('copy to destination', () => { function assertCopyFile( - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file: any, expectedDestination: string, callback: Function @@ -3565,7 +3529,7 @@ describe('File', () => { file.copy = (destination: {}, options: {}, callback: Function) => { callback(null, newFile, copyApiResponse); }; - file.delete = ({}, callback: Function) => { + file.delete = (_: {}, callback: Function) => { callback(); }; @@ -3674,7 +3638,7 @@ describe('File', () => { const callback = () => {}; const expectedReturnValue = {}; - file.parent.request = function( + file.parent.request = function ( reqOpts: DecorateRequestOptions, callback_: Function ) { @@ -3838,7 +3802,7 @@ describe('File', () => { }); it('should convert camelCase to snake_case', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.copy = (newFile: {}, options: any) => { assert.strictEqual(options.storageClass, 'CAMEL_CASE'); done(); @@ -3848,7 +3812,7 @@ describe('File', () => { }); it('should convert hyphenate to snake_case', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any file.copy = (newFile: {}, options: any) => { assert.strictEqual(options.storageClass, 'HYPHENATED_CLASS'); done(); @@ -3911,11 +3875,11 @@ describe('File', () => { describe('setEncryptionKey', () => { const KEY = crypto.randomBytes(32); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any const KEY_BASE64 = Buffer.from(KEY as any).toString('base64'); const KEY_HASH = crypto .createHash('sha256') - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .update(KEY_BASE64, 'base64' as any) .digest('base64'); let _file: {}; @@ -3981,7 +3945,7 @@ describe('File', () => { file.kmsKeyName = 'kms-key-name'; resumableUploadOverride = { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any upload(opts: any) { const bucket = file.bucket; const storage = bucket.storage; @@ -4106,7 +4070,7 @@ describe('File', () => { public: true, }; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options_: any) => { assert.strictEqual(options_.metadata, options.metadata); assert.deepStrictEqual(options_.request, { @@ -4126,7 +4090,7 @@ describe('File', () => { }); it('should set predefinedAcl when public: true', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options_: any) => { assert.strictEqual(options_.request.qs.predefinedAcl, 'publicRead'); done(); @@ -4136,7 +4100,7 @@ describe('File', () => { }); it('should set predefinedAcl when private: true', done => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options_: any) => { assert.strictEqual(options_.request.qs.predefinedAcl, 'private'); done(); @@ -4147,7 +4111,7 @@ describe('File', () => { it('should send query.ifGenerationMatch if File has one', done => { const versionedFile = new File(BUCKET, 'new-file.txt', {generation: 1}); - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options: any) => { assert.strictEqual(options.request.qs.ifGenerationMatch, 1); done(); @@ -4158,7 +4122,7 @@ describe('File', () => { it('should send query.kmsKeyName if File has one', done => { file.kmsKeyName = 'kms-key-name'; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options: any) => { assert.strictEqual(options.request.qs.kmsKeyName, file.kmsKeyName); done(); @@ -4171,7 +4135,7 @@ describe('File', () => { const options = { userProject: 'user-project-id', }; - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any makeWritableStreamOverride = (stream: {}, options_: any) => { assert.strictEqual( options_.request.qs.userProject, @@ -4202,7 +4166,7 @@ describe('File', () => { file.startSimpleUpload_(stream); stream.on('error', (err: Error) => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any assert.strictEqual((stream as any).destroyed, true); assert.strictEqual(err, error); done(); @@ -4257,7 +4221,7 @@ describe('File', () => { it('should call the parent setUserProject function', done => { const userProject = 'grape-spaceship-123'; - file.parent.setUserProject = function(userProject_: string) { + file.parent.setUserProject = function (userProject_: string) { assert.strictEqual(this, file); assert.strictEqual(userProject_, userProject); done(); diff --git a/test/hmacKey.ts b/test/hmacKey.ts index ef6ac0fd89..2b54a0229b 100644 --- a/test/hmacKey.ts +++ b/test/hmacKey.ts @@ -15,33 +15,26 @@ import * as sinon from 'sinon'; import * as proxyquire from 'proxyquire'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, beforeEach, afterEach} from 'mocha'; import {util, ServiceObject} from '@google-cloud/common'; -// tslint:disable-next-line: no-any -let sandbox: sinon.SinonSandbox; -// tslint:disable-next-line: no-any +const sandbox = sinon.createSandbox(); +// eslint-disable-next-line @typescript-eslint/no-explicit-any let STORAGE: any; -// tslint:disable-next-line: no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any let hmacKey: any; const ACCESS_ID = 'fake-access-id'; describe('HmacKey', () => { - beforeEach(() => { - sandbox = sinon.createSandbox(); - }); - - afterEach(() => { - sandbox.restore(); - }); + afterEach(() => sandbox.restore()); describe('initialization', () => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let serviceObjectSpy: sinon.SinonSpy; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let commonModule: any; - // tslint:disable-next-line: no-any variable-name + // eslint-disable-next-line @typescript-eslint/no-explicit-any let HmacKey: any; beforeEach(() => { diff --git a/test/iam.ts b/test/iam.ts index 5cdb258886..ee3f43712f 100644 --- a/test/iam.ts +++ b/test/iam.ts @@ -14,16 +14,16 @@ import {DecorateRequestOptions, util} from '@google-cloud/common'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; describe('storage/iam', () => { - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Iam: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let iam: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let BUCKET_INSTANCE: any; let promisified = false; const fakePromisify = { diff --git a/test/index.ts b/test/index.ts index 800d9b67c6..81316157dc 100644 --- a/test/index.ts +++ b/test/index.ts @@ -20,18 +20,18 @@ import { util, } from '@google-cloud/common'; import {PromisifyAllOptions} from '@google-cloud/promisify'; - import arrify = require('arrify'); import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as proxyquire from 'proxyquire'; - +// eslint-disable-next-line @typescript-eslint/no-unused-vars import {Bucket} from '../src'; import {GetFilesOptions} from '../src/bucket'; import sinon = require('sinon'); import {HmacKey} from '../src/hmacKey'; import {HmacKeyResourceResponse} from '../src/storage'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const hmacKeyModule = require('../src/hmacKey'); class FakeChannel { @@ -84,11 +84,11 @@ const fakePromisify = { describe('Storage', () => { const PROJECT_ID = 'project-id'; - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Storage: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let storage: any; - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Bucket: any; before(() => { @@ -137,6 +137,7 @@ describe('Storage', () => { ]); assert.deepStrictEqual( calledWith.packageJson, + // eslint-disable-next-line @typescript-eslint/no-var-requires require('../../package.json') ); }); @@ -727,7 +728,7 @@ describe('Storage', () => { }); describe('getHmacKeys', () => { - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let storageRequestStub: sinon.SinonStub; const SERVICE_ACCOUNT_EMAIL = 'service-account@gserviceaccount.com'; const ACCESS_ID = 'some-access-id'; @@ -822,7 +823,7 @@ describe('Storage', () => { storage.getHmacKeys( query, - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (err: Error, _hmacKeys: [], nextQuery: any) => { assert.ifError(err); assert.deepStrictEqual(nextQuery, expectedNextQuery); diff --git a/test/notification.ts b/test/notification.ts index e7cd8168dd..bfb6696f15 100644 --- a/test/notification.ts +++ b/test/notification.ts @@ -19,7 +19,7 @@ import { util, } from '@google-cloud/common'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; +import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {Bucket} from '../src'; @@ -28,14 +28,15 @@ class FakeServiceObject extends ServiceObject { calledWith_: IArguments; constructor(config: ServiceObjectConfig) { super(config); + // eslint-disable-next-line prefer-rest-params this.calledWith_ = arguments; } } describe('Notification', () => { - // tslint:disable-next-line:variable-name no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let Notification: any; - // tslint:disable-next-line: no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let notification: any; let promisified = false; const fakeUtil = Object.assign({}, util); diff --git a/test/signer.ts b/test/signer.ts index 568e0f4e74..0965f3076c 100644 --- a/test/signer.ts +++ b/test/signer.ts @@ -15,6 +15,7 @@ import * as assert from 'assert'; import * as dateFormat from 'date-and-time'; import * as crypto from 'crypto'; import * as sinon from 'sinon'; +import {describe, it, beforeEach, afterEach} from 'mocha'; import { URLSigner, @@ -51,7 +52,7 @@ describe('signer', () => { beforeEach(() => { authClient = { - sign: async (_blobToSign: string) => 'signature', + sign: async () => 'signature', getCredentials: async () => ({client_email: CLIENT_EMAIL}), }; bucket = {name: BUCKET_NAME}; @@ -92,7 +93,7 @@ describe('signer', () => { describe('version', () => { it('should default to v2 if version is not given', async () => { const v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves({}); @@ -111,7 +112,7 @@ describe('signer', () => { ...CONFIG, }; const v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves({}); @@ -139,7 +140,7 @@ describe('signer', () => { ...CONFIG, }; const v4 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV4') .resolves({}); @@ -157,7 +158,7 @@ describe('signer', () => { }); it('should error for an invalid version', () => { - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any CONFIG.version = 'v42' as any; assert.throws( @@ -170,11 +171,11 @@ describe('signer', () => { describe('expires', () => { it('should parse Date object into expiration seconds', async () => { const parseExpires = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .spy(signer, 'parseExpires'); const v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves({}); @@ -190,7 +191,7 @@ describe('signer', () => { let v2: sinon.SinonStub; beforeEach(() => { v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves({}); }); @@ -239,6 +240,7 @@ describe('signer', () => { }); describe('composing signed URL', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars let v2: sinon.SinonStub; const query = { GoogleAccessId: CLIENT_EMAIL, @@ -248,7 +250,7 @@ describe('signer', () => { beforeEach(() => { v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves(query); }); @@ -274,7 +276,7 @@ describe('signer', () => { const signedUrl = await signer.getSignedUrl(CONFIG); const v2 = sandbox - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves({}); @@ -317,8 +319,8 @@ describe('signer', () => { 'X-Goog-Foo': 'value', 'X-Goog-Bar': 'azAZ!*()*%', }; - const v2 = sandbox - // tslint:disable-next-line no-any + sandbox + // eslint-disable-next-line @typescript-eslint/no-explicit-any .stub(signer, 'getSignedUrlV2') .resolves(query); @@ -843,7 +845,7 @@ describe('signer', () => { }; const canonical = signer.getCanonicalQueryParams(query); - const EXPECTED = `A=foo&B=bar`; + const EXPECTED = 'A=foo&B=bar'; assert.strictEqual(canonical, EXPECTED); }); }); diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 617dc975ba..0000000000 --- a/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "gts/tslint.json" -} From 774ac5c75f02238418cc8ed7242297ea573ca9cb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 12 Apr 2020 17:57:13 +0200 Subject: [PATCH 11/15] fix(deps): update dependency @google-cloud/common to v3 (#1134) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e412a0573..cdc4027d2d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "prelint": "cd samples; npm link ../; npm i" }, "dependencies": { - "@google-cloud/common": "^2.1.1", + "@google-cloud/common": "^3.0.0", "@google-cloud/paginator": "^2.0.0", "@google-cloud/promisify": "^1.0.0", "arrify": "^2.0.0", From c1614d98e3047db379e09299b1014e80d73ed52f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 12 Apr 2020 18:04:07 +0200 Subject: [PATCH 12/15] fix(deps): update dependency @google-cloud/paginator to v3 (#1131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@google-cloud/paginator](https://togithub.com/googleapis/nodejs-paginator) | dependencies | major | [`^2.0.0` -> `^3.0.0`](https://renovatebot.com/diffs/npm/@google-cloud%2fpaginator/2.0.3/3.0.0) | --- ### Release Notes
googleapis/nodejs-paginator ### [`v3.0.0`](https://togithub.com/googleapis/nodejs-paginator/blob/master/CHANGELOG.md#​300-httpswwwgithubcomgoogleapisnodejs-paginatorcomparev203v300-2020-03-25) [Compare Source](https://togithub.com/googleapis/nodejs-paginator/compare/v2.0.3...v3.0.0) ##### ⚠ BREAKING CHANGES - **dep:** upgrade gts 2.0.0 ([#​194](https://togithub.com/googleapis/nodejs-paginator/issues/194)) - **deps:** deprecated node 8 to 10; upgrade typescript ##### Miscellaneous Chores - **dep:** upgrade gts 2.0.0 ([#​194](https://www.github.com/googleapis/nodejs-paginator/issues/194)) ([4eaf9be](https://www.github.com/googleapis/nodejs-paginator/commit/4eaf9bed1fcfd0f10e877ff15c1d0e968e3356c8)) - **deps:** deprecated node 8 to 10; upgrade typescript ([f6434ab](https://www.github.com/googleapis/nodejs-paginator/commit/f6434ab9cacb6ab804c070f19c38b6072ca326b5)) ##### [2.0.3](https://www.github.com/googleapis/nodejs-paginator/compare/v2.0.2...v2.0.3) (2019-12-05) ##### Bug Fixes - **deps:** pin TypeScript below 3.7.0 ([e06e1b0](https://www.github.com/googleapis/nodejs-paginator/commit/e06e1b0a2e2bb1cf56fc806c1703b8b5e468b954)) ##### [2.0.2](https://www.github.com/googleapis/nodejs-paginator/compare/v2.0.1...v2.0.2) (2019-11-13) ##### Bug Fixes - **docs:** add jsdoc-region-tag plugin ([#​155](https://www.github.com/googleapis/nodejs-paginator/issues/155)) ([b983799](https://www.github.com/googleapis/nodejs-paginator/commit/b98379905848fd179c6268aff3e1cfaf2bf76663)) ##### [2.0.1](https://www.github.com/googleapis/nodejs-paginator/compare/v2.0.0...v2.0.1) (2019-08-25) ##### Bug Fixes - **deps:** use the latest extend ([#​141](https://www.github.com/googleapis/nodejs-paginator/issues/141)) ([61b383e](https://www.github.com/googleapis/nodejs-paginator/commit/61b383e))
--- ### Renovate configuration :date: **Schedule**: "after 9am and before 3pm" (UTC). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/nodejs-storage). --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cdc4027d2d..8bd0073804 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "dependencies": { "@google-cloud/common": "^3.0.0", - "@google-cloud/paginator": "^2.0.0", + "@google-cloud/paginator": "^3.0.0", "@google-cloud/promisify": "^1.0.0", "arrify": "^2.0.0", "compressible": "^2.0.12", From 06624a534cd1fdbc38455eee8d89f9f60ba75758 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 13 Apr 2020 18:59:21 +0200 Subject: [PATCH 13/15] fix(deps): update dependency @google-cloud/promisify to v2 (#1127) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bd0073804..733a46cbcb 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "dependencies": { "@google-cloud/common": "^3.0.0", "@google-cloud/paginator": "^3.0.0", - "@google-cloud/promisify": "^1.0.0", + "@google-cloud/promisify": "^2.0.0", "arrify": "^2.0.0", "compressible": "^2.0.12", "concat-stream": "^2.0.0", From b2eee0e272712a3018c797382ef4fe1662f9454a Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 13 Apr 2020 14:57:04 -0700 Subject: [PATCH 14/15] chore: update lint ignore files (#1158) --- .eslintignore | 3 ++- .prettierignore | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintignore b/.eslintignore index 09b31fe735..9340ad9b86 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ **/node_modules -src/**/doc/* +**/coverage +test/fixtures build/ docs/ protos/ diff --git a/.prettierignore b/.prettierignore index f6fac98b0a..9340ad9b86 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,6 @@ -node_modules/* -samples/node_modules/* -src/**/doc/* +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ From 5877cc7bb4227a6caee18203996aead00b69ecd8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 20 Apr 2020 14:35:52 -0700 Subject: [PATCH 15/15] build: use codecov's action, now that it's authless (#1160) --- .github/workflows/ci.yaml | 20 ++++++++++---------- synth.metadata | 11 ++++++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7138a79a95..9465009bac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,11 @@ jobs: - run: node --version - run: npm install - run: npm test + - name: coverage + uses: codecov/codecov-action@v1 + with: + name: actions ${{ matrix.node }} + fail_ci_if_error: true windows: runs-on: windows-latest steps: @@ -27,6 +32,11 @@ jobs: node-version: 12 - run: npm install - run: npm test + - name: coverage + uses: codecov/codecov-action@v1 + with: + name: actions windows + fail_ci_if_error: true lint: runs-on: ubuntu-latest steps: @@ -45,13 +55,3 @@ jobs: node-version: 12 - run: npm install - run: npm run docs-test - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 13 - - run: npm install - - run: npm test - - run: ./node_modules/.bin/c8 report --reporter=text-lcov | npx codecovorg -a ${{ secrets.CODECOV_API_KEY }} -r $GITHUB_REPOSITORY --pipe diff --git a/synth.metadata b/synth.metadata index 538450f7f5..160bf5974c 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,12 +1,17 @@ { - "updateTime": "2020-04-08T13:02:56.471752Z", "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/nodejs-storage.git", + "sha": "b2eee0e272712a3018c797382ef4fe1662f9454a" + } + }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "1df68ed6735ddce6797d0f83641a731c3c3f75b4", - "log": "1df68ed6735ddce6797d0f83641a731c3c3f75b4\nfix: apache license URL (#468)\n\n\nf4a59efa54808c4b958263de87bc666ce41e415f\nfeat: Add discogapic support for GAPICBazel generation (#459)\n\n* feat: Add discogapic support for GAPICBazel generation\n\n* reformat with black\n\n* Rename source repository variable\n\nCo-authored-by: Jeffrey Rennie \n" + "sha": "19465d3ec5e5acdb01521d8f3bddd311bcbee28d" } } ]