Skip to content

Commit

Permalink
Bug 1230776: Support scripts from HTML files in eslint. r=gps
Browse files Browse the repository at this point in the history
Also removes related unused variables in mach_commands.py.
  • Loading branch information
kmaglione committed Dec 5, 2015
1 parent 826587e commit 71bd1d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# 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.
Expand Down
34 changes: 15 additions & 19 deletions python/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@
Valid installation paths:
'''.strip()

ESLINT_PROMPT = '''
Would you like to use eslint
'''.strip()

ESLINT_PLUGIN_MOZILLA_PROMPT = '''
eslint-plugin-mozilla is an eslint plugin containing rules that help enforce
JavaScript coding standards in the Mozilla project. Would you like to use this
plugin
'''.strip()

ESLINT_PLUGIN_REACT_PROMPT = '''
eslint-plugin-react is an eslint plugin containing rules that help React
developers follow strict guidelines. Would you like to install it
'''.strip()


@CommandProvider
class MachCommands(MachCommandBase):
Expand Down Expand Up @@ -168,8 +153,8 @@ def _line_handler(line):
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('-e', '--ext', default='[.js,.jsm,.jsx,.xml]',
help='Filename extensions to lint, default: "[.js,.jsm,.jsx]".')
@CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx,.xml,.html]',
help='Filename extensions to lint, default: "[.js,.jsm,.jsx,.xml,.html]".')
@CommandArgument('-b', '--binary', default=None,
help='Path to eslint binary.')
@CommandArgument('args', nargs=argparse.REMAINDER) # Passed through to eslint.
Expand Down Expand Up @@ -197,8 +182,13 @@ def eslint(self, setup, ext=None, binary=None, args=None):
args = args or ['.']

cmd_args = [binary,
'--ext', ext, # This keeps ext as a single argument.
] + args
# Enable the HTML plugin.
# We can't currently enable this in the global config file
# because it has bad interactions with the SublimeText
# ESLint plugin (bug 1229874).
'--plugin', 'html',
'--ext', ext, # This keeps ext as a single argument.
] + args

success = self.run_process(cmd_args,
pass_thru=True, # Allow user to run eslint interactively.
Expand Down Expand Up @@ -241,6 +231,12 @@ def eslint_setup(self, update_only=False):
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"])
Expand Down

0 comments on commit 71bd1d3

Please sign in to comment.