diff --git a/.eslintignore b/.eslintignore index d9b7ef48..d067a75d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,5 +2,6 @@ dist assets firefox coverage +android/app/build app/locale.js app/capabilities.js \ No newline at end of file diff --git a/.eslintrc.yml b/.eslintrc.yml index 026ab20e..05c84c01 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,6 +4,7 @@ env: extends: - eslint:recommended + - prettier - plugin:node/recommended - plugin:security/recommended @@ -22,13 +23,5 @@ rules: security/detect-non-literal-fs-filename: off security/detect-object-injection: off - eol-last: [error, always] - eqeqeq: error - no-alert: warn - no-console: warn - no-path-concat: error no-unused-vars: [error, {argsIgnorePattern: "^_|err|event|next|reject"}] - no-var: error - one-var: [error, never] - prefer-const: error - quotes: [error, single, {avoidEscape: true}] + require-atomic-updates: warn diff --git a/app/api.js b/app/api.js index ccc7854e..29237c05 100644 --- a/app/api.js +++ b/app/api.js @@ -312,12 +312,13 @@ export function downloadStream(id, keychain) { ////////////////// -function download(id, keychain, onprogress, canceller) { +async function download(id, keychain, onprogress, canceller) { + const auth = await keychain.authHeader(); const xhr = new XMLHttpRequest(); canceller.oncancel = function() { xhr.abort(); }; - return new Promise(async function(resolve, reject) { + return new Promise(function(resolve, reject) { xhr.addEventListener('loadend', function() { canceller.oncancel = function() {}; const authHeader = xhr.getResponseHeader('WWW-Authenticate'); @@ -337,7 +338,6 @@ function download(id, keychain, onprogress, canceller) { onprogress(event.loaded); } }); - const auth = await keychain.authHeader(); xhr.open('get', getApiUrl(`/api/download/blob/${id}`)); xhr.setRequestHeader('Authorization', auth); xhr.responseType = 'blob'; diff --git a/app/streams.js b/app/streams.js index 73d15097..00159a24 100644 --- a/app/streams.js +++ b/app/streams.js @@ -1,4 +1,4 @@ -/* global ReadableStream TransformStream */ +/* global TransformStream */ export function transformStream(readable, transformer, oncancel) { try { diff --git a/package-lock.json b/package-lock.json index 55213a14..7f1df94f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5591,6 +5591,23 @@ } } }, + "eslint-config-prettier": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.0.0.tgz", + "integrity": "sha512-vDrcCFE3+2ixNT5H83g28bO/uYAwibJxerXPj+E7op4qzBCsAV36QfvdAyVOoNxKAH2Os/e01T/2x++V0LPukA==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + }, + "dependencies": { + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + } + } + }, "eslint-plugin-es": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.4.0.tgz", diff --git a/package.json b/package.json index b6add79c..b54210e1 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "css-mqpacker": "^7.0.0", "cssnano": "^4.1.10", "eslint": "^6.1.0", + "eslint-config-prettier": "^6.0.0", "eslint-plugin-mocha": "^6.0.0", "eslint-plugin-node": "^9.1.0", "eslint-plugin-security": "^1.4.0", diff --git a/scripts/get-prod-locales.js b/scripts/get-prod-locales.js index 27c86e26..c6aae630 100755 --- a/scripts/get-prod-locales.js +++ b/scripts/get-prod-locales.js @@ -19,8 +19,8 @@ exec(cmd) const locales = Object.keys(summary) .filter(locale => { const loc = summary[locale]; - const hasMissing = loc.hasOwnProperty('missing'); - const hasErrors = loc.hasOwnProperty('errors'); + const hasMissing = Object.prototype.hasOwnProperty.call(loc, 'missing'); + const hasErrors = Object.prototype.hasOwnProperty.call(loc, 'errors'); return !hasMissing && !hasErrors; }) .sort(); diff --git a/scripts/lint-locales.js b/scripts/lint-locales.js index fbcf84ef..db1a29de 100644 --- a/scripts/lint-locales.js +++ b/scripts/lint-locales.js @@ -33,7 +33,7 @@ function filterErrors(details) { .sort() .map(locale => { const data = details[locale] - .filter(item => item.hasOwnProperty('error')) + .filter(item => Object.prototype.hasOwnProperty.call(item, 'error')) .map(({ error }) => error); return { locale, data }; }) diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml index dd9f4ba4..b1f66d58 100644 --- a/test/.eslintrc.yml +++ b/test/.eslintrc.yml @@ -19,5 +19,7 @@ rules: mocha/no-pending-tests: error mocha/no-return-and-callback: warn mocha/no-skipped-tests: error + mocha/no-setup-in-describe: off + mocha/no-hooks-for-single-case: off no-console: off # ¯\_(ツ)_/¯