diff --git a/.eslintrc.yaml b/.eslintrc.yaml index c34fe2339..fae38e122 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,31 +1,14 @@ +parserOptions: + ecmaVersion: 2018 + overrides: - files: - - "src/octoprint/static/js/app/**" + - "src/octoprint/static/js/**.js" + - "src/octoprint/plugins/**.js" env: browser: true jquery: true - parserOptions: - ecmaVersion: 5 - rules: - es5/no-arrow-functions: error - es5/no-binary-and-octal-literals: error - es5/no-block-scoping: error - es5/no-classes: error - es5/no-computed-properties: error - es5/no-default-parameters: error - es5/no-destructuring: error - es5/no-exponentiation-operator: error - es5/no-for-of: error - es5/no-generators: error - es5/no-modules: error - es5/no-object-super: error - es5/no-rest-parameters: error - es5/no-shorthand-properties: error - es5/no-spread: error - es5/no-template-literals: error - es5/no-typeof-symbol: error - es5/no-unicode-code-point-escape: error - es5/no-unicode-regex: error + es6: true - files: - "tests/cypress/**" env: @@ -36,5 +19,4 @@ overrides: - "plugin:cypress/recommended" plugins: - - eslint-plugin-es5 - cypress diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75a53eae8..ddb20b3c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,6 @@ repos: - id: eslint additional_dependencies: - eslint@7.19.0 - - eslint-plugin-es5@v1.3.0 - eslint-plugin-cypress@2.11.2 files: \.js$ exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/) diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index bff3b84f6..73ee56c6f 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -288,7 +288,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): # TAG-NUM-gHEX mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) if not mo: - # unparseable. Maybe git-describe is misbehaving? + # unparsable. Maybe git-describe is misbehaving? pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out return pieces diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 72211d3df..02dd8bac5 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -2425,11 +2425,11 @@ class SoftwareUpdatePlugin( ) if check.get("update_script", None): - # we force an exact version & python unequality check, to be able to downgrade + # we force an exact version & python inequality check, to be able to downgrade result["force_exact_version"] = True result["release_compare"] = "python_unequal" elif check.get("pip", None): - # we force python unequality check for pip installs, to be able to downgrade + # we force python inequality check for pip installs, to be able to downgrade result["release_compare"] = "python_unequal" if result.get("pip", None): diff --git a/src/octoprint/schema/config/devel.py b/src/octoprint/schema/config/devel.py index c14f8ee9e..e2e34bb6b 100644 --- a/src/octoprint/schema/config/devel.py +++ b/src/octoprint/schema/config/devel.py @@ -29,7 +29,7 @@ class DevelWebassetsConfig(BaseModel): class DevelCacheConfig(BaseModel): enabled: bool = True - """Whether to enable caching. Defaults to true. Setting it to false will cause the UI to alway be fully rerendered on request to `/` on the server.""" + """Whether to enable caching. Defaults to true. Setting it to false will cause the UI to always be fully rerendered on request to `/` on the server.""" preemptive: bool = True """Whether to enable the preemptive cache.""" diff --git a/src/octoprint/static/js/login/login.js b/src/octoprint/static/js/login/login.js index 61a881723..c9107d2cf 100644 --- a/src/octoprint/static/js/login/login.js +++ b/src/octoprint/static/js/login/login.js @@ -32,11 +32,11 @@ $(function () { OctoPrint.browser .login(username, password, remember) - .done(function () { + .done(() => { ignoreDisconnect = true; window.location.href = REDIRECT_URL; }) - .fail(function () { + .fail(() => { usernameElement.val(USER_ID); passwordElement.val(""); @@ -55,18 +55,18 @@ $(function () { OctoPrint.options.baseurl = BASE_URL; - OctoPrint.socket.onConnected = function () { + OctoPrint.socket.onConnected = () => { buttonElement.prop("disabled", false); offlineElement.removeClass("in"); }; - OctoPrint.socket.onDisconnected = function () { + OctoPrint.socket.onDisconnected = () => { if (ignoreDisconnect) return; buttonElement.prop("disabled", true); offlineElement.addClass("in"); }; - reconnectElement.click(function () { + reconnectElement.click(() => { OctoPrint.socket.reconnect(); }); diff --git a/src/octoprint/static/js/recovery/recovery.js b/src/octoprint/static/js/recovery/recovery.js index 1ce4cbc6e..414dc81ca 100644 --- a/src/octoprint/static/js/recovery/recovery.js +++ b/src/octoprint/static/js/recovery/recovery.js @@ -54,7 +54,7 @@ $(function () { self.backups = ko.observableArray([]); self.excludeFromBackup = ko.observableArray([]); self.backupMaxUploadSize = ko.observable(); - self.backupIsAboveUploadSize = function (data) { + self.backupIsAboveUploadSize = (data) => { return data.size > self.backupMaxUploadSize(); }; @@ -64,8 +64,8 @@ $(function () { self.workLoglines = ko.observableArray([]); self.workTitle = ko.observable(""); - self.request = function () { - OctoPrint.browser.passiveLogin().done(function (resp) { + self.request = () => { + OctoPrint.browser.passiveLogin().done((resp) => { self.username(resp.name); self.permitted(_.includes(resp.needs.role, "admin")); self.known(true); @@ -73,13 +73,13 @@ $(function () { OctoPrint.socket.sendAuth(resp.name, resp.session); }); - OctoPrint.system.getCommandsForSource("core").done(function (resp) { + OctoPrint.system.getCommandsForSource("core").done((resp) => { self.systemCommands(resp); }); - OctoPrint.system.getInfo().done(function (resp) { + OctoPrint.system.getInfo().done((resp) => { var systeminfo = []; - _.forOwn(resp.systeminfo, function (value, key) { + _.forOwn(resp.systeminfo, (value, key) => { systeminfo.push({key: key, value: value}); }); self.systemInfo(systeminfo); @@ -87,25 +87,23 @@ $(function () { OctoPrint.printer .getFullState() - .done(function (resp) { + .done((resp) => { self.printerConnected(true); self.jobInProgress(resp.state.flags.printing); }) - .fail(function (xhr) { + .fail((xhr) => { self.printerConnected(false); self.jobInProgress(false); }); if (OctoPrint.plugins.backup) { - OctoPrint.plugins.backup.get().done(function (resp) { + OctoPrint.plugins.backup.get().done((resp) => { self.backupSupported(true); self.restoreSupported(resp.restore_supported); self.backupMaxUploadSize(resp.max_upload_size); var backups = resp.backups; - backups.sort(function (a, b) { - return b.date - a.date; - }); + backups.sort((a, b) => b.date - a.date); self.backups(backups); }); } else { @@ -115,15 +113,15 @@ $(function () { } }; - self.executeSystemCommand = function (command) { - var process = function () { + self.executeSystemCommand = (command) => { + var process = () => { OctoPrint.system.executeCommand(command.source, command.action); }; if (command.confirm) { showConfirmationDialog({ message: command.confirm, - onproceed: function () { + onproceed: () => { process(); } }); @@ -132,22 +130,22 @@ $(function () { } }; - self.copySystemInfo = function () { + self.copySystemInfo = () => { var text = ""; - _.each(self.systemInfo(), function (entry) { + _.each(self.systemInfo(), (entry) => { text += entry.key + ": " + entry.value + "\r\n"; }); copyToClipboard(text); }; self.cancelPrint = function () { - OctoPrint.job.cancel().done(function () { + OctoPrint.job.cancel().done(() => { self.request(); }); }; self.disconnectPrinter = function () { - OctoPrint.connection.disconnect().done(function () { + OctoPrint.connection.disconnect().done(() => { self.request(); }); }; @@ -160,15 +158,15 @@ $(function () { if (!self.backupSupported()) return; var excluded = self.excludeFromBackup(); - OctoPrint.plugins.backup.createBackup(excluded).done(function () { + OctoPrint.plugins.backup.createBackup(excluded).done(() => { self.excludeFromBackup([]); }); }; - self.restoreBackup = function (backup) { + self.restoreBackup = (backup) => { if (!self.restoreSupported()) return; - var perform = function () { + var perform = () => { self.workInProgress(true); self.workTitle(gettext("Restoring backup...")); self.workLoglines.removeAll(); @@ -192,26 +190,26 @@ $(function () { ); }; - self.logout = function () { - OctoPrint.browser.logout().done(function () { + self.logout = () => { + OctoPrint.browser.logout().done(() => { window.location.href = LOGIN_URL; }); }; - self.reconnect = function () { + self.reconnect = () => { OctoPrint.socket.reconnect(); }; - self.onSocketConnected = function () { + self.onSocketConnected = () => { self.connected(true); self.request(); }; - self.onSocketDisconnected = function () { + self.onSocketDisconnected = () => { self.connected(false); }; - self.onSocketMessage = function (event, data) { + self.onSocketMessage = (event, data) => { console.log("onSocketMessage", event, data); if (event === "plugin" && data.plugin === "backup") { switch (data.data.type) { @@ -302,15 +300,15 @@ $(function () { var viewModel = new RecoveryViewModel(); - OctoPrint.socket.onConnected = function () { + OctoPrint.socket.onConnected = () => { viewModel.onSocketConnected(); }; - OctoPrint.socket.onDisconnected = function () { + OctoPrint.socket.onDisconnected = () => { viewModel.onSocketDisconnected(); }; - OctoPrint.socket.onMessage("*", function (data) { + OctoPrint.socket.onMessage("*", (data) => { viewModel.onSocketMessage(data.event, data.data); }); diff --git a/src/octoprint/static/less/bootstrap/forms.less b/src/octoprint/static/less/bootstrap/forms.less index 330ed3d68..34a667da6 100644 --- a/src/octoprint/static/less/bootstrap/forms.less +++ b/src/octoprint/static/less/bootstrap/forms.less @@ -316,7 +316,7 @@ textarea[class*="span"], .row-fluid .controls-row [class*="span"] { float: left; } -// Explicity set top padding on all checkboxes/radios, not just first-child +// Explicitly set top padding on all checkboxes/radios, not just first-child .controls-row .checkbox[class*="span"], .controls-row .radio[class*="span"] { padding-top: 5px; diff --git a/src/octoprint/static/less/bootstrap/navbar.less b/src/octoprint/static/less/bootstrap/navbar.less index b31cf155b..fae29b27e 100644 --- a/src/octoprint/static/less/bootstrap/navbar.less +++ b/src/octoprint/static/less/bootstrap/navbar.less @@ -127,7 +127,7 @@ .input-append, .input-prepend { margin-top: 5px; - white-space: nowrap; // preven two items from separating within a .navbar-form that has .pull-left + white-space: nowrap; // prevent two items from separating within a .navbar-form that has .pull-left input { margin-top: 0; // remove the margin on top since it's on the parent } diff --git a/src/octoprint/static/less/bootstrap/thumbnails.less b/src/octoprint/static/less/bootstrap/thumbnails.less index 0e3d112e3..ef07a1403 100644 --- a/src/octoprint/static/less/bootstrap/thumbnails.less +++ b/src/octoprint/static/less/bootstrap/thumbnails.less @@ -2,7 +2,7 @@ // Thumbnails // -------------------------------------------------- -// Note: `.thumbnails` and `.thumbnails > li` are overriden in responsive files +// Note: `.thumbnails` and `.thumbnails > li` are overridden in responsive files // Make wrapper ul behave like the grid .thumbnails { @@ -17,7 +17,7 @@ // Float li to make thumbnails appear in a row .thumbnails > li { - float: left; // Explicity set the float since we don't require .span* classes + float: left; // Explicitly set the float since we don't require .span* classes margin-bottom: @baseLineHeight; margin-left: @gridGutterWidth; } diff --git a/src/octoprint/util/pip.py b/src/octoprint/util/pip.py index ff25391e1..205185c27 100644 --- a/src/octoprint/util/pip.py +++ b/src/octoprint/util/pip.py @@ -473,7 +473,7 @@ class PipCaller(CommandlineCaller): if not output.startswith("pip"): self._logger.warning( - "pip command returned unparseable output, can't determine version: {}".format( + "pip command returned unparsable output, can't determine version: {}".format( output ) ) @@ -481,7 +481,7 @@ class PipCaller(CommandlineCaller): split_output = list(map(lambda x: x.strip(), output.split())) if len(split_output) < 2: self._logger.warning( - "pip command returned unparseable output, can't determine version: {}".format( + "pip command returned unparsable output, can't determine version: {}".format( output ) ) diff --git a/versioneer.py b/versioneer.py index eb4cb6f1d..63428fa14 100644 --- a/versioneer.py +++ b/versioneer.py @@ -791,7 +791,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): # TAG-NUM-gHEX mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe) if not mo: - # unparseable. Maybe git-describe is misbehaving? + # unparsable. Maybe git-describe is misbehaving? pieces["error"] = ("unable to parse git-describe output: '%%s'" %% describe_out) return pieces @@ -1380,7 +1380,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): # TAG-NUM-gHEX mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) if not mo: - # unparseable. Maybe git-describe is misbehaving? + # unparsable. Maybe git-describe is misbehaving? pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out return pieces