Bug 1358540 - Change the *.lint files to be *.lint.py to better support editor integration & flake8 linting. r=smacleod
☠☠ backed out by 4653b1d21e87 ☠ ☠
authorMark Banner <standard8@mozilla.com>
Fri, 21 Apr 2017 17:31:15 +0100
changeset 402857 eec770d062b42f8c12f01391b4e715a7f082b2cf
parent 402853 a12d2e2fb05a5f04a446939f6c332780911fd37e
child 402858 93bf1142be38aa8855cf9d6f2b25cd55b0d2a2c6
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1358540
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1358540 - Change the *.lint files to be *.lint.py to better support editor integration & flake8 linting. r=smacleod MozReview-Commit-ID: 4KK2GZK7xul
python/mozlint/mozlint/cli.py
python/mozlint/mozlint/parser.py
python/mozlint/mozlint/result.py
tools/lint/eslint.lint
tools/lint/eslint.lint.py
tools/lint/flake8.lint
tools/lint/flake8.lint.py
tools/lint/mach_commands.py
tools/lint/wpt.lint
tools/lint/wpt.lint.py
tools/lint/wpt_manifest.lint
tools/lint/wpt_manifest.lint.py
--- a/python/mozlint/mozlint/cli.py
+++ b/python/mozlint/mozlint/cli.py
@@ -81,20 +81,23 @@ class MozlintParser(ArgumentParser):
 def find_linters(linters=None):
     lints = []
     for search_path in SEARCH_PATHS:
         if not os.path.isdir(search_path):
             continue
 
         files = os.listdir(search_path)
         for f in files:
-            name, ext = os.path.splitext(f)
-            if ext != '.lint':
+            name = os.path.basename(f)
+
+            if not name.endswith('.lint.py'):
                 continue
 
+            name = name.rsplit('.', 2)[0]
+
             if linters and name not in linters:
                 continue
 
             lints.append(os.path.join(search_path, f))
     return lints
 
 
 def run(paths, linters, fmt, rev, outgoing, workdir, **lintargs):
--- a/python/mozlint/mozlint/parser.py
+++ b/python/mozlint/mozlint/parser.py
@@ -7,17 +7,17 @@ import os
 import sys
 import uuid
 
 from .types import supported_types
 from .errors import LinterNotFound, LinterParseError
 
 
 class Parser(object):
-    """Reads and validates `.lint` files."""
+    """Reads and validates `.lint.py` files."""
     required_attributes = (
         'name',
         'description',
         'type',
         'payload',
     )
 
     def __call__(self, path):
@@ -72,14 +72,14 @@ class Parser(object):
 
         :param path: Path to the linter.
         :returns: Linter definition (dict)
         :raises: LinterNotFound, LinterParseError
         """
         if not os.path.isfile(path):
             raise LinterNotFound(path)
 
-        if not path.endswith('.lint'):
-            raise LinterParseError(path, "Invalid filename, linters must end with '.lint'!")
+        if not path.endswith('.lint.py'):
+            raise LinterParseError(path, "Invalid filename, linters must end with '.lint.py'!")
 
         linter = self._load_linter(path)
         self._validate(linter)
         return linter
--- a/python/mozlint/mozlint/result.py
+++ b/python/mozlint/mozlint/result.py
@@ -66,17 +66,17 @@ class ResultEncoder(JSONEncoder):
 
 
 def from_linter(lintobj, **kwargs):
     """Create a :class:`~result.ResultContainer` from a LINTER definition.
 
     Convenience method that pulls defaults from a LINTER
     definition and forwards them.
 
-    :param lintobj: LINTER obj as defined in a .lint file
+    :param lintobj: LINTER obj as defined in a .lint.py file
     :param kwargs: same as :class:`~result.ResultContainer`
     :returns: :class:`~result.ResultContainer` object
     """
     attrs = {}
     for attr in ResultContainer.__slots__:
         attrs[attr] = kwargs.get(attr, lintobj.get(attr))
 
     if not attrs['linter']:
rename from tools/lint/eslint.lint
rename to tools/lint/eslint.lint.py
--- a/tools/lint/eslint.lint
+++ b/tools/lint/eslint.lint.py
@@ -73,17 +73,17 @@ def eslint_setup():
     # npm sometimes fails to respect cwd when it is run using check_call so
     # we manually switch folders here instead.
     os.chdir(get_project_root())
 
     npm_path = get_node_or_npm_path("npm")
     if not npm_path:
         return 1
 
-    extra_parameters = [ "--loglevel=error" ]
+    extra_parameters = ["--loglevel=error"]
 
     # Install ESLint and external plugins
     cmd = [npm_path, "install"]
     cmd.extend(extra_parameters)
     print("Installing eslint for mach using \"%s\"..." % (" ".join(cmd)))
     if not call_process("eslint", cmd):
         return 1
 
rename from tools/lint/flake8.lint
rename to tools/lint/flake8.lint.py
--- a/tools/lint/flake8.lint
+++ b/tools/lint/flake8.lint.py
@@ -109,17 +109,17 @@ def get_flake8_binary():
 
 
 def _run_pip(*args):
     """
     Helper function that runs pip with subprocess
     """
     try:
         subprocess.check_output(['pip'] + list(args),
-                                      stderr=subprocess.STDOUT)
+                                stderr=subprocess.STDOUT)
         return True
     except subprocess.CalledProcessError as e:
         print(e.output)
         return False
 
 
 def reinstall_flake8():
     """
--- a/tools/lint/mach_commands.py
+++ b/tools/lint/mach_commands.py
@@ -41,17 +41,17 @@ class MachCommands(MachCommandBase):
         cli.SEARCH_PATHS.append(here)
         self._activate_virtualenv()
         return cli.run(*runargs, **lintargs)
 
     @Command('eslint', category='devenv',
              description='Run eslint or help configure eslint for optimal development.')
     @CommandArgument('paths', default=None, nargs='*',
                      help="Paths to file or directories to lint, like "
-                          "'browser/components/loop' Defaults to the "
+                          "'browser/' Defaults to the "
                           "current directory if not given.")
     @CommandArgument('-s', '--setup', default=False, action='store_true',
                      help='Configure eslint for optimal development.')
     @CommandArgument('-b', '--binary', default=None,
                      help='Path to eslint binary.')
     @CommandArgument('--fix', default=False, action='store_true',
                      help='Request that eslint automatically fix errors, where possible.')
     @CommandArgument('extra_args', nargs=argparse.REMAINDER,
rename from tools/lint/wpt.lint
rename to tools/lint/wpt.lint.py
rename from tools/lint/wpt_manifest.lint
rename to tools/lint/wpt_manifest.lint.py
--- a/tools/lint/wpt_manifest.lint
+++ b/tools/lint/wpt_manifest.lint.py
@@ -1,22 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import imp
-import json
 import os
-import sys
-
-from mozprocess import ProcessHandler
-
-from mozlint import result
 
 
 def lint(files, logger, **kwargs):
     wpt_dir = os.path.join(kwargs["root"], "testing", "web-platform")
     manifestupdate = imp.load_source("manifestupdate",
                                      os.path.join(wpt_dir, "manifestupdate.py"))
     manifestupdate.update(logger, wpt_dir, True)