presubmit_canned_checks.py: Ignore long TypeScript imports.

Change-Id: If9e133002e2cdcff42917a487a677f3ed73d4d3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2241184
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
changes/84/2241184/2
Leandro Lovisolo 5 years ago committed by LUCI CQ
parent 77463bb188
commit 44de5e3f65

@ -417,6 +417,8 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
JAVA_EXCEPTIONS = ('import ', 'package ')
JS_FILE_EXTS = ('js',)
JS_EXCEPTIONS = ("GEN('#include", 'import ')
TS_FILE_EXTS = ('ts',)
TS_EXCEPTIONS = ('import ')
OBJC_FILE_EXTS = ('h', 'm', 'mm')
OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include',
'#pragma')
@ -428,6 +430,7 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
(HTML_FILE_EXTS, HTML_EXCEPTIONS),
(JAVA_FILE_EXTS, JAVA_EXCEPTIONS),
(JS_FILE_EXTS, JS_EXCEPTIONS),
(TS_FILE_EXTS, TS_EXCEPTIONS),
(OBJC_FILE_EXTS, OBJC_EXCEPTIONS),
(PY_FILE_EXTS, PY_EXCEPTIONS),
]

@ -2148,6 +2148,12 @@ the current line as well!
'foo.js', "// We should import something long, eh?",
'foo.js', presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckTSLongImports(self):
check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 10)
self.ContentTest(check, "import {Name, otherName} from './dir/file';",
'foo.ts', "// We should import something long, eh?",
'foo.ts', presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckObjCExceptionLongLines(self):
check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80)
self.ContentTest(check, '#import ' + 'A ' * 150, 'foo.mm',

Loading…
Cancel
Save