-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathlint
executable file
·73 lines (56 loc) · 1.95 KB
/
lint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
# Copyright 2019 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Lint our source files."""
import os
import sys
import hterm
import libdot # pylint: disable=wrong-import-order
JS_DIR = hterm.DIR / "js"
# Path to generated deps file that hterm uses for libdot/etc...
DEPS_FILE = os.path.join(hterm.DIR, "dist", "js", "hterm_resources.js")
def _get_default_paths(basedir):
"""Get list of paths to lint by default."""
most_files = sorted(
x
for x in libdot.lint.get_known_sources(basedir)
if x.suffix not in {".js"}
)
# All files in js/*.js excluding generated files.
# Use relpath for nicer default output.
# Sort to ensure hterm.js comes before hterm_other.js, etc.
js_files = sorted(
[hterm.DIR / "index.js"]
+ list(x for x in JS_DIR.glob("*.js") if not x.name.startswith("deps_"))
+ list((hterm.DIR / "third_party").glob("*/*.js"))
)
return [os.path.relpath(x) for x in most_files + js_files]
def mkdeps(_opts):
"""Build the deps we might use when linting."""
if not os.path.exists(DEPS_FILE):
libdot.run([os.path.join(hterm.BIN_DIR, "mkdist")])
def main(argv):
"""The main func!"""
libdot_files = [os.path.relpath(libdot.DIR / "index.js")] + sorted(
os.path.relpath(x)
for x in libdot.DIR.glob("js/*.js")
if "_test" not in x.name and x.name.startswith("lib")
)
closure_args = (
list(libdot.lint.DEFAULT_CLOSURE_ARGS)
+ [
# TODO(vapier): We want to turn this on at some point.
"--jscomp_off=strictMissingProperties",
]
+ libdot_files
)
return libdot.lint.main(
argv,
basedir=hterm.DIR,
get_default_paths=_get_default_paths,
mkdeps=mkdeps,
closure_args=closure_args,
)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))