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>
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 595971d..a092f8a 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -417,6 +417,8 @@
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 @@
(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 8b46f5f..7389bd5 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -2148,6 +2148,12 @@
'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',