Bug 1230776: Support scripts from HTML files in eslint. r?Mossop draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 05 Dec 2015 13:17:49 -0800
changeset 314432 c0e1a655733ab31773c592b511b9af5934df3b43
parent 314430 fb4801cfdbbf072a071f6a6ef8c1cf13dd6de960
child 511863 89618fbfaccc96e0d3ba15d3b3d89cf669bfb7d0
push id8211
push usermaglione.k@gmail.com
push dateSat, 05 Dec 2015 23:02:10 +0000
reviewersMossop
bugs1230776
milestone45.0a1
Bug 1230776: Support scripts from HTML files in eslint. r?Mossop
.eslintignore
.eslintrc
browser/components/extensions/test/browser/.eslintrc
browser/components/extensions/test/browser/context_tabs_onUpdated_iframe.html
browser/components/extensions/test/browser/context_tabs_onUpdated_page.html
python/mach_commands.py
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,14 +1,18 @@
 # Always ignore node_modules.
 **/node_modules/**/*.*
 
 # Exclude expected objdirs.
 obj*/**
 
+# Temporarily ignore HTML files that still need to be fixed.
+browser/extensions/loop/**/*.html
+devtools/**/*.html
+
 # We ignore all these directories by default, until we get them enabled.
 # If you are enabling a directory, please add directory specific exclusions
 # below.
 accessible/**
 addon-sdk/**
 build/**
 caps/**
 chrome/**
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,9 +1,10 @@
 {
   // When adding items to this file please check for effects on sub-directories.
   "plugins": [
+    "html",
     "mozilla"
   ],
   "env": {
     "es6": true
   },
 }
--- a/browser/components/extensions/test/browser/.eslintrc
+++ b/browser/components/extensions/test/browser/.eslintrc
@@ -2,16 +2,17 @@
   "extends": "../../.eslintrc",
 
   "globals": {
     // DOM window globals
     "CustomEvent": false,
     "document": false,
     "ImageData": false,
     "MouseEvent": false,
+    "setTimeout": false,
     "window": false,
     "XMLHttpRequest": false,
 
     "gBrowser": false,
 
     "sendAsyncMessage": false,
 
     "NetUtil": true,
--- a/browser/components/extensions/test/browser/context_tabs_onUpdated_iframe.html
+++ b/browser/components/extensions/test/browser/context_tabs_onUpdated_iframe.html
@@ -1,17 +1,19 @@
 <html>
   <body>
     <h3>test iframe</h3>
     <script>
+      "use strict";
+
       window.onload = function() {
         window.onhashchange = function() {
           window.parent.postMessage("updated-iframe-url", "*");
-        }
+        };
         // NOTE: without the this setTimeout the location change is not fired
         // even without the "fire only for top level windows" fix
         setTimeout(function() {
-          window.location.hash="updated-iframe-url";
+          window.location.hash = "updated-iframe-url";
         }, 0);
-      }
+      };
     </script>
   </body>
 </html>
--- a/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html
+++ b/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html
@@ -1,16 +1,18 @@
 <html>
   <body>
     <h3>test page</h3>
     <iframe src="about:blank"></iframe>
     <script>
+      "use strict";
+
       window.onmessage = function(evt) {
         if (evt.data === "updated-iframe-url") {
           window.postMessage("frame-updated", "*");
         }
       };
       window.onload = function() {
-        document.querySelector('iframe').setAttribute("src", "context_tabs_onUpdated_iframe.html");
+        document.querySelector("iframe").setAttribute("src", "context_tabs_onUpdated_iframe.html");
       };
     </script>
   </body>
 </html>
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -167,18 +167,18 @@ class MachCommands(MachCommandBase):
     @Command('eslint', category='devenv',
         description='Run eslint or help configure eslint for optimal development.')
     @CommandArgument('-s', '--setup', default=False, action='store_true',
         help='configure eslint for optimal development.')
     @CommandArgument('path', nargs='?', default='.',
         help='Path to files to lint, like "browser/components/loop" '
             'or "mobile/android". '
             'Defaults to the current directory if not given.')
-    @CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx]',
-        help='Filename extensions to lint, default: "[.js,.jsm,.jsx]".')
+    @CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx,.html]',
+        help='Filename extensions to lint, default: "[.js,.jsm,.jsx,.html]".')
     @CommandArgument('-b', '--binary', default=None,
         help='Path to eslint binary.')
     @CommandArgument('args', nargs=argparse.REMAINDER)  # Passed through to eslint.
     def eslint(self, setup, path, ext=None, binary=None, args=[]):
         '''Run eslint.'''
 
         if setup:
             return self.eslint_setup()
@@ -246,16 +246,22 @@ class MachCommands(MachCommandBase):
 
         # Install eslint-plugin-mozilla.
         success = self.callProcess("eslint-plugin-mozilla",
                                    [npmPath, "link"],
                                    "testing/eslint-plugin-mozilla")
         if not success:
             return 1
 
+        # Install eslint-plugin-html.
+        success = self.callProcess("eslint-plugin-html",
+                                   [npmPath, "install", "eslint-plugin-html", "-g"])
+        if not success:
+            return 1
+
         # Install eslint-plugin-react.
         success = self.callProcess("eslint-plugin-react",
                                    [npmPath, "install", "eslint-plugin-react", "-g"])
         if not success:
             return 1
 
         print("\nESLint and approved plugins installed successfully!")