Skip to content

Commit

Permalink
Remove --color from ESLint output when running in presubmit
Browse files Browse the repository at this point in the history
Fixed: 862792
Change-Id: I250e91a1db5f8df71fff33c17c7a04a9fd6c8739
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937584
Commit-Queue: Dan Beam <dbeam@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719450}
  • Loading branch information
danbeam authored and Commit Bot committed Nov 27, 2019
1 parent 390bc4d commit 35b10c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions PRESUBMIT_test_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self):
self.python_executable = sys.executable
self.platform = sys.platform
self.subprocess = subprocess
self.sys = sys
self.files = []
self.is_committing = False
self.change = MockChange([])
Expand Down
4 changes: 3 additions & 1 deletion tools/web_dev_style/js_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def RunEsLintChecks(self, affected_js_files, format="stylish"):
for f in affected_js_files:
affected_js_files_paths.append(f.AbsoluteLocalPath())

args = ["--color", "--format", format, "--ignore-pattern '!.eslintrc.js'"]
from os import isatty as os_isatty
args = ["--color"] if os_isatty(self.input_api.sys.stdout.fileno()) else []
args += ["--format", format, "--ignore-pattern '!.eslintrc.js'"]
args += affected_js_files_paths

import eslint
Expand Down
4 changes: 2 additions & 2 deletions tools/web_dev_style/js_checker_eslint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def _assertError(self, results_json, rule_id, line):
self.assertEqual(line, message.get('line'))

def testGetElementByIdCheck(self):
results_json = self._runChecks('var a = document.getElementById(\'foo\');')
results_json = self._runChecks("const a = document.getElementById('foo');")
self._assertError(results_json, 'no-restricted-properties', 1)

def testPrimitiveWrappersCheck(self):
results_json = self._runChecks('var a = new Number(1);')
results_json = self._runChecks('const a = new Number(1);')
self._assertError(results_json, 'no-new-wrappers', 1)


Expand Down

0 comments on commit 35b10c1

Please sign in to comment.