Commit 42a51f6a authored by Tim van der Lippe's avatar Tim van der Lippe Committed by LUCI CQ

Enable Javascript formatting by default

This removes the need for explicitly passing `--js` to `git cl format`
to format both JavaScript and TypeScript. It would reduce a significant
amount of mental overhead for formatting code in DevTools frontend,
which is primarily JS/TS.

Fixed: 1007347
Change-Id: Ia35c9af677d12ce9be72fe5fcdd6ceb6cb039c5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2029371Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
parent 4d678727
......@@ -5234,8 +5234,15 @@ def CMDformat(parser, args):
parser.add_option(
'--js',
action='store_true',
default=None,
help='Format javascript code with clang-format. '
'Has no effect if --no-clang-format is set.')
parser.add_option(
'--no-js',
action='store_true',
default=False,
help='Disable JavaScript/TypeScript formatting code with clang-format. '
'Has no effect if --no-clang-format is set.')
parser.add_option('--diff', action='store_true',
help='Print diff to stdout rather than modifying files.')
parser.add_option('--presubmit', action='store_true',
......@@ -5246,6 +5253,10 @@ def CMDformat(parser, args):
raise parser.error('Cannot set both --python and --no-python')
if opts.no_python:
opts.python = False
if opts.js is not None and opts.no_js:
raise parser.error('Cannot set both --js and --no-js')
if opts.no_js:
opts.js = False
# Normalize any remaining args against the current path, so paths relative to
# the current directory are still resolved as expected.
......@@ -5278,7 +5289,8 @@ def CMDformat(parser, args):
# Filter out files deleted by this CL
diff_files = [x for x in diff_files if os.path.isfile(x)]
if opts.js:
js_explicitly_disabled = opts.js is not None and not opts.js
if not js_explicitly_disabled:
CLANG_EXTS.extend(['.js', '.ts'])
clang_diff_files = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment