From ba079453bf57d522f1adac45506d756b39673a45 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 5 Oct 2020 13:30:20 +0200 Subject: [PATCH] Enable the ESLint `no-debugger` and `no-alert` rules The `debugger`-statement would only, potentially, make sense during development and we thus want to prevent it from being accidentally included when landing code. The `alert`, `confirm`, and `prompt` functions should generally be avoided, with the few intended cases manually allowed. Please find additional details about the ESLint rules at: - https://eslint.org/docs/rules/no-debugger - https://eslint.org/docs/rules/no-alert --- .eslintrc | 2 ++ examples/.eslintrc | 1 + web/app.js | 1 + web/chromecom.js | 1 + 4 files changed, 5 insertions(+) diff --git a/.eslintrc b/.eslintrc index 804ca9e65..86df7143f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -45,6 +45,7 @@ "no-async-promise-executor": "error", "no-cond-assign": ["error", "except-parens"], "no-constant-condition": ["error", { "checkLoops": false, }], + "no-debugger": "error", "no-dupe-args": "error", "no-dupe-else-if": "error", "no-dupe-keys": "error", @@ -79,6 +80,7 @@ "dot-notation": "error", "eqeqeq": ["error", "always"], "grouped-accessor-pairs": ["error", "getBeforeSet"], + "no-alert": "error", "no-caller": "error", "no-else-return": "error", "no-empty-pattern": "error", diff --git a/examples/.eslintrc b/examples/.eslintrc index 6e29d3c74..8c4df5059 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -19,6 +19,7 @@ }, "rules": { + "no-alert": "off", "object-shorthand": ["error", "never"] } } diff --git a/web/app.js b/web/app.js index df777d4f6..043cad817 100644 --- a/web/app.js +++ b/web/app.js @@ -1667,6 +1667,7 @@ const PDFViewerApplication = { "Warning: The PDF is not fully loaded for printing." ) .then(notReadyMessage => { + // eslint-disable-next-line no-alert window.alert(notReadyMessage); }); return; diff --git a/web/chromecom.js b/web/chromecom.js index b160bdf74..c18d73a04 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -219,6 +219,7 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) { "\nSelected: " + file.name + "\nDo you want to open the selected file?"; + // eslint-disable-next-line no-alert if (!confirm(msg)) { this.value = ""; return;