From 44de5e3f654c60d04f7572f700afa556247f544a Mon Sep 17 00:00:00 2001 From: Leandro Lovisolo Date: Thu, 11 Jun 2020 18:52:52 +0000 Subject: [PATCH] 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 Commit-Queue: Leandro Lovisolo --- presubmit_canned_checks.py | 3 +++ tests/presubmit_unittest.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 595971db7..a092f8a12 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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), ] diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 8b46f5f69..7389bd5a1 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -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',