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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « catapult_build/js_checks.py ('k') | common/eslint/bin/run_tests » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/eslint/bin/run_eslint
diff --git a/common/eslint/bin/run_eslint b/common/eslint/bin/run_eslint
new file mode 100755
index 0000000000000000000000000000000000000000..044787cf5a8bb6179e0ebef35926527f22d3a5df
--- /dev/null
+++ b/common/eslint/bin/run_eslint
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import os
+import sys
+
+
+_CATAPULT_PATH = os.path.abspath(
+ os.path.join(os.path.dirname(__file__),
+ os.path.pardir, os.path.pardir, os.path.pardir))
+
+
+_ESLINT_PATH = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), os.path.pardir))
+
+
+DIRECTORIES_TO_LINT = [
+ os.path.join(_CATAPULT_PATH, 'dashboard', 'dashboard'),
+ os.path.join(_CATAPULT_PATH, 'tracing', 'tracing')
+]
+
+
+def _AddToPathIfNeeded(path):
+ if path not in sys.path:
+ sys.path.insert(0, path)
+
+
+if __name__ == '__main__':
+ _AddToPathIfNeeded(_ESLINT_PATH)
+ import eslint
+
+ parser = argparse.ArgumentParser(
+ description='Wrapper script to run eslint on Catapult code')
+ parser.add_argument('--files', '-f', default=None, nargs='+', metavar='FILE',
+ help='List of files to lint')
+ parser.add_argument('--all', default=None, action='store_true',
+ help='Runs eslint on all applicable Catapult code')
+
+ args = parser.parse_args(sys.argv[1:])
+ if ((args.files is not None and args.all is not None) or
+ (args.files is None and args.all is None)):
+ print 'Either --files or --all must be used, but not both.\n'
+ parser.print_help()
+ sys.exit(1)
+
+ if args.all:
+ print eslint.RunEslintOnDirs(DIRECTORIES_TO_LINT)
+ else:
+ print eslint.RunEslintOnFiles(args.files)
« 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