blob: 2d255fe6b330f4c0b27a451d1d50391aa2b586af [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091# Copyright 2017 The Chromium Authors
dbeamccf7fef2017-05-17 22:24:292# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
dpapade9f53c82024-10-09 23:41:136PRESUBMIT_VERSION = '2.0.0'
7
8
dbeamccf7fef2017-05-17 22:24:299def CheckChangeOnUpload(*args):
10 return _CommonChecks(*args)
11
12
13def CheckChangeOnCommit(*args):
14 return _CommonChecks(*args)
15
16
17def _CommonChecks(input_api, output_api):
Dan Harringtond8a17cb2021-06-23 19:36:5418 tests = ['test_suite.py']
dbeamccf7fef2017-05-17 22:24:2919
Takuto Ikutae108f102023-06-01 21:38:3020 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests)
dpapade9f53c82024-10-09 23:41:1321
22
23def CheckEsLintConfigChanges(input_api, output_api):
24 """Suggest using "git cl presubmit --files" when the global configuration
25 file eslint.config.mjs file is modified. This is important because
26 modifications to this file can trigger ESLint errors in any .js or .ts
27 files in the repository, leading to hidden presubmit errors."""
28 results = []
29
30 eslint_filter = lambda f: input_api.FilterSourceFile(
31 f, files_to_check=[r'tools/web_dev_style/eslint.config.mjs$'])
32 for f in input_api.AffectedFiles(include_deletes=False,
33 file_filter=eslint_filter):
34 results.append(
35 output_api.PresubmitNotifyResult(
36 '%(file)s modified. Consider running \'git cl presubmit '
37 '--files "*.js;*.ts"\' in order to check and fix the affected '
38 'files before landing this change.' % {'file': f.LocalPath()}))
39 return results