0

Remove --color from ESLint output when running in presubmit

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}
This commit is contained in:
Dan Beam
2019-11-27 01:17:34 +00:00
committed by Commit Bot
parent 390bc4d74a
commit 35b10c1a1f
3 changed files with 6 additions and 3 deletions

@ -71,6 +71,7 @@ class MockInputApi(object):
self.python_executable = sys.executable
self.platform = sys.platform
self.subprocess = subprocess
self.sys = sys
self.files = []
self.is_committing = False
self.change = MockChange([])

@ -68,7 +68,9 @@ class JSChecker(object):
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

@ -44,11 +44,11 @@ class JsCheckerEsLintTest(unittest.TestCase):
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)