blob: 3df3130ab75f82d2f503e3cf28fc546a84f55bd9 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# Copyright 2020 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file or at
4# https://developers.google.com/open-source/licenses/bsd
5
6
7def CheckChange(input_api, output_api):
8 results = []
9 results += input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)
10 results += input_api.canned_checks.CheckChangeHasNoTabs(input_api, output_api)
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020011 # NPM audit presubmit disabled. See: crbug.com/monorail/10572
12 # results += CheckNpmAudit(input_api, output_api)
Copybara854996b2021-09-07 19:36:02 +000013 return results
14
15
16def CheckChangeOnUpload(input_api, output_api):
17 return CheckChange(input_api, output_api)
18
19
20def CheckChangeOnCommit(input_api, output_api):
21 return CheckChange(input_api, output_api)
22
23
24def CheckNpmAudit(input_api, output_api): # pragma: no cover
25 file_filter = lambda f: f.LocalPath().endswith('.js')
26 affected_js_files = input_api.AffectedFiles(
27 include_deletes=False, file_filter=file_filter)
28 if not affected_js_files:
29 return []
30
31 import imp
32 appengine_path = input_api.os_path.dirname(input_api.PresubmitLocalPath())
33 js_checker_path = input_api.os_path.join(appengine_path, 'js_checker.py')
34 js_checker = imp.load_source('JSChecker', js_checker_path)
35
36 return js_checker.JSChecker(input_api, output_api).RunAuditCheck()