From 968240f5bc12b5b5db99740fffac622f0473b5c1 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Thu, 10 Dec 2020 17:50:18 +0100 Subject: [PATCH] Enable some comments-related ESLint rules --- .eslintrc.js | 2 -- src/deploy/hash-files.js | 6 ++++-- src/deploy/hash-fns.js | 6 ++++-- src/deploy/index.js | 18 ++++++++++++------ src/deploy/upload-files.js | 3 ++- src/deploy/util.js | 6 ++++-- src/index.js | 3 ++- src/methods/index.js | 3 ++- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index bb30819..e470f7d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,11 +6,9 @@ module.exports = { // TODO: enable those rules complexity: 0, 'id-length': 0, - 'line-comment-position': 0, 'max-nested-callbacks': 0, 'max-statements': 0, 'no-await-in-loop': 0, - 'no-inline-comments': 0, 'no-magic-numbers': 0, 'no-param-reassign': 0, 'no-shadow': 0, diff --git a/src/deploy/hash-files.js b/src/deploy/hash-files.js index aa04375..b2db776 100644 --- a/src/deploy/hash-files.js +++ b/src/deploy/hash-files.js @@ -20,8 +20,10 @@ const hashFiles = async (dir, configPath, opts) => { const fileNormalizer = fileNormalizerCtor(opts) // Written to by manifestCollector - const files = {} // normalizedPath: hash (wanted by deploy API) - const filesShaMap = {} // hash: [fileObj, fileObj, fileObj] + // normalizedPath: hash (wanted by deploy API) + const files = {} + // hash: [fileObj, fileObj, fileObj] + const filesShaMap = {} const manifestCollector = manifestCollectorCtor(files, filesShaMap, opts) await pump(fileStream, filter, hasher, fileNormalizer, manifestCollector) diff --git a/src/deploy/hash-fns.js b/src/deploy/hash-fns.js index f7e7f50..4ebc8dd 100644 --- a/src/deploy/hash-fns.js +++ b/src/deploy/hash-fns.js @@ -39,8 +39,10 @@ const hashFns = async (dir, opts) => { const hasher = hasherCtor(opts) // Written to by manifestCollector - const functions = {} // normalizedPath: hash (wanted by deploy API) - const fnShaMap = {} // hash: [fileObj, fileObj, fileObj] + // normalizedPath: hash (wanted by deploy API) + const functions = {} + // hash: [fileObj, fileObj, fileObj] + const fnShaMap = {} const manifestCollector = manifestCollectorCtor(functions, fnShaMap, opts) await pump(functionStream, hasher, manifestCollector) diff --git a/src/deploy/index.js b/src/deploy/index.js index 2c1c264..6687c0b 100644 --- a/src/deploy/index.js +++ b/src/deploy/index.js @@ -15,14 +15,20 @@ const deploySite = async (api, siteId, dir, opts) => { fnDir: null, configPath: null, draft: false, - message: undefined, // API calls this the 'title' + // API calls this the 'title' + message: undefined, tmpDir: tempy.directory(), - deployTimeout: 1.2e6, // local deploy timeout: 20 mins - concurrentHash: 100, // concurrent file hash calls - concurrentUpload: 5, // Number of concurrent uploads + // local deploy timeout: 20 mins + deployTimeout: 1.2e6, + // concurrent file hash calls + concurrentHash: 100, + // Number of concurrent uploads + concurrentUpload: 5, filter: defaultFilter, - syncFileLimit: 100, // number of files - maxRetry: 5, // number of times to retry an upload + // number of files + syncFileLimit: 100, + // number of times to retry an upload + maxRetry: 5, statusCb: () => { /* default to noop */ // statusObj: { diff --git a/src/deploy/upload-files.js b/src/deploy/upload-files.js index 9ad50e7..5e4013f 100644 --- a/src/deploy/upload-files.js +++ b/src/deploy/upload-files.js @@ -81,7 +81,8 @@ const retryUpload = (uploadFn, maxRetry) => .catch((error) => { lastError = error switch (true) { - case error.status >= 400: // observed errors: 408, 401 (4** swallowed), 502 + // observed errors: 408, 401 (4** swallowed), 502 + case error.status >= 400: case error.name === 'FetchError': { return fibonacciBackoff.backoff() } diff --git a/src/deploy/util.js b/src/deploy/util.js index adff491..5362690 100644 --- a/src/deploy/util.js +++ b/src/deploy/util.js @@ -32,7 +32,8 @@ const normalizePath = (relname) => { // poll an async deployId until its done diffing const waitForDiff = async (api, deployId, siteId, timeout) => { - let deploy // capture ready deploy during poll + // capture ready deploy during poll + let deploy const loadDeploy = async () => { const d = await api.getSiteDeploy({ siteId, deployId }) @@ -69,7 +70,8 @@ const waitForDiff = async (api, deployId, siteId, timeout) => { // Poll a deployId until its ready const waitForDeploy = async (api, deployId, siteId, timeout) => { - let deploy // capture ready deploy during poll + // capture ready deploy during poll + let deploy const loadDeploy = async () => { const d = await api.getSiteDeploy({ siteId, deployId }) diff --git a/src/index.js b/src/index.js index daf0aa8..9ad83c6 100644 --- a/src/index.js +++ b/src/index.js @@ -61,7 +61,8 @@ class NetlifyAPI { const { id } = ticket - let authorizedTicket // ticket capture + // ticket capture + let authorizedTicket const checkTicket = async () => { const t = await this.showTicket({ ticketId: id }) if (t.authorized) { diff --git a/src/methods/index.js b/src/methods/index.js index 464a62e..de87915 100644 --- a/src/methods/index.js +++ b/src/methods/index.js @@ -1,4 +1,5 @@ -const fetch = require('node-fetch').default || require('node-fetch') // Webpack will sometimes export default exports in different places +// Webpack will sometimes export default exports in different places +const fetch = require('node-fetch').default || require('node-fetch') const { getOperations } = require('../operations')