Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1109)

Side by Side Diff: common/eslint/bin/run_eslint

Issue 2361623007: Add a run_eslint wrapper script (Closed)
Patch Set: Synced to head Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « catapult_build/js_checks.py ('k') | common/eslint/bin/run_tests » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import os
8 import sys
9
10
11 _CATAPULT_PATH = os.path.abspath(
12 os.path.join(os.path.dirname(__file__),
13 os.path.pardir, os.path.pardir, os.path.pardir))
14
15
16 _ESLINT_PATH = os.path.abspath(
17 os.path.join(os.path.dirname(__file__), os.path.pardir))
18
19
20 DIRECTORIES_TO_LINT = [
21 os.path.join(_CATAPULT_PATH, 'dashboard', 'dashboard'),
22 os.path.join(_CATAPULT_PATH, 'tracing', 'tracing')
23 ]
24
25
26 def _AddToPathIfNeeded(path):
27 if path not in sys.path:
28 sys.path.insert(0, path)
29
30
31 if __name__ == '__main__':
32 _AddToPathIfNeeded(_ESLINT_PATH)
33 import eslint
34
35 parser = argparse.ArgumentParser(
36 description='Wrapper script to run eslint on Catapult code')
37 parser.add_argument('--files', '-f', default=None, nargs='+', metavar='FILE',
38 help='List of files to lint')
39 parser.add_argument('--all', default=None, action='store_true',
40 help='Runs eslint on all applicable Catapult code')
41
42 args = parser.parse_args(sys.argv[1:])
43 if ((args.files is not None and args.all is not None) or
44 (args.files is None and args.all is None)):
45 print 'Either --files or --all must be used, but not both.\n'
46 parser.print_help()
47 sys.exit(1)
48
49 if args.all:
50 print eslint.RunEslintOnDirs(DIRECTORIES_TO_LINT)
51 else:
52 print eslint.RunEslintOnFiles(args.files)
OLDNEW
« no previous file with comments | « catapult_build/js_checks.py ('k') | common/eslint/bin/run_tests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698