blob: fb1d431e5051a72538c678d8f50333cae7b92867 [file] [log] [blame]
#!/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_deps.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.
# Use relpath for nicer default output.
# Sort to ensure hterm.js comes before hterm_other.js, etc.
js_files = sorted(x for x in JS_DIR.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!"""
closure_args = list(libdot.lint.DEFAULT_CLOSURE_ARGS) + [
# TODO(vapier): We want to turn this on at some point.
"--jscomp_off=strictMissingProperties",
os.path.relpath(DEPS_FILE),
]
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:]))