Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web/debugger.js] Enable the ESLint no-var rule #13333

Merged
merged 2 commits into from May 5, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

These changes were made mostly automatically, using gulp lint --fix, with the following manual changes:

diff --git a/web/debugger.js b/web/debugger.js
index 1cda4066e..6f8b4a9f0 100644
--- a/web/debugger.js
+++ b/web/debugger.js
@@ -264,10 +264,9 @@ const Stepper = (function StepperClosure() {
     }
     if ("length" in args) {
       // array
-      let simpleArgs = [],
-        i,
-        ii;
-      const MAX_ITEMS = 10;
+      const MAX_ITEMS = 10,
+        simpleArgs = [];
+      let i, ii;
       for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
         simpleArgs.push(simplifyArgs(args[i]));
       }
@@ -511,11 +510,8 @@ window.PDFBug = (function PDFBugClosure() {
   return {
     tools: [FontInspector, StepperManager, Stats],
     enable(ids) {
-      let all = false,
-        tools = this.tools;
-      if (ids.length === 1 && ids[0] === "all") {
-        all = true;
-      }
+      const all = ids.length === 1 && ids[0] === "all";
+      const tools = this.tools;
       for (let i = 0; i < tools.length; ++i) {
         const tool = tools[i];
         if (all || ids.includes(tool.id)) {

Also, removes a couple of unnecessary local variables in the `Stepper.breakIt` method.

Finally, this patch also disables the ESLint `no-var` rule, in preparation for the next patch, for a couple of data-structures that need to remain globally available.
These changes were made *mostly* automatically, using `gulp lint --fix`, with the following manual changes:

```diff
diff --git a/web/debugger.js b/web/debugger.js
index 1cda4066e..6f8b4a9f0 100644
--- a/web/debugger.js
+++ b/web/debugger.js
@@ -264,10 +264,9 @@ const Stepper = (function StepperClosure() {
     }
     if ("length" in args) {
       // array
-      let simpleArgs = [],
-        i,
-        ii;
-      const MAX_ITEMS = 10;
+      const MAX_ITEMS = 10,
+        simpleArgs = [];
+      let i, ii;
       for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
         simpleArgs.push(simplifyArgs(args[i]));
       }
@@ -511,11 +510,8 @@ window.PDFBug = (function PDFBugClosure() {
   return {
     tools: [FontInspector, StepperManager, Stats],
     enable(ids) {
-      let all = false,
-        tools = this.tools;
-      if (ids.length === 1 && ids[0] === "all") {
-        all = true;
-      }
+      const all = ids.length === 1 && ids[0] === "all";
+      const tools = this.tools;
       for (let i = 0; i < tools.length; ++i) {
         const tool = tools[i];
         if (all || ids.includes(tool.id)) {
```
@Snuffleupagus Snuffleupagus changed the title [web/debugger.js] Enable the ESLint `no-var rule [web/debugger.js] Enable the ESLint no-var rule May 4, 2021
Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@calixteman calixteman merged commit a00913a into mozilla:master May 5, 2021
@Snuffleupagus Snuffleupagus deleted the debugger-no-var branch May 5, 2021 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants