2018-07-08 01:56:03 -04:00
|
|
|
#!/usr/bin/env python
|
2019-01-21 14:03:30 -05:00
|
|
|
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-07-08 01:56:03 -04:00
|
|
|
# Does google-lint on c++ files and ts-lint on typescript files
|
|
|
|
|
|
|
|
import os
|
2018-11-30 03:27:41 -05:00
|
|
|
import sys
|
2019-09-12 15:07:21 -04:00
|
|
|
from util import enable_ansi_colors, git_ls_files, libdeno_path, root_path, run
|
2019-09-14 10:25:49 -04:00
|
|
|
from util import third_party_path
|
2019-09-11 16:47:42 -04:00
|
|
|
from third_party import python_env
|
2018-09-02 17:37:14 -04:00
|
|
|
|
2018-07-08 01:56:03 -04:00
|
|
|
|
2019-09-14 10:25:49 -04:00
|
|
|
def main():
|
|
|
|
enable_ansi_colors()
|
|
|
|
os.chdir(root_path)
|
|
|
|
cpplint()
|
|
|
|
eslint()
|
|
|
|
pylint()
|
2018-07-08 01:56:03 -04:00
|
|
|
|
2018-10-05 07:29:55 -04:00
|
|
|
|
2019-09-14 10:25:49 -04:00
|
|
|
def cpplint():
|
|
|
|
print "cpplint"
|
|
|
|
script = os.path.join(third_party_path, "cpplint", "cpplint.py")
|
2019-09-12 15:07:21 -04:00
|
|
|
source_files = git_ls_files(libdeno_path, ["*.cc", "*.h"])
|
2019-09-14 10:25:49 -04:00
|
|
|
run([
|
|
|
|
sys.executable,
|
|
|
|
script,
|
|
|
|
"--quiet",
|
|
|
|
"--filter=-build/include_subdir",
|
2019-09-12 15:07:21 -04:00
|
|
|
"--repository=" + libdeno_path,
|
2019-09-14 10:25:49 -04:00
|
|
|
"--",
|
|
|
|
] + source_files,
|
|
|
|
env=python_env(),
|
|
|
|
shell=False,
|
|
|
|
quiet=True)
|
2018-11-30 03:27:41 -05:00
|
|
|
|
2019-09-14 10:25:49 -04:00
|
|
|
|
|
|
|
def eslint():
|
|
|
|
print "eslint"
|
|
|
|
script = os.path.join(third_party_path, "node_modules", "eslint", "bin",
|
|
|
|
"eslint")
|
|
|
|
# Find all *directories* in the main repo that contain .ts/.js files.
|
2019-09-16 17:25:32 -04:00
|
|
|
source_files = git_ls_files(root_path, ["*.js", "*.ts"])
|
2019-09-14 10:25:49 -04:00
|
|
|
source_dirs = set([os.path.dirname(f) for f in source_files])
|
|
|
|
# Within the source dirs, eslint does its own globbing, taking into account
|
|
|
|
# the exclusion rules listed in '.eslintignore'.
|
|
|
|
source_globs = ["%s/*.{js,ts}" % d for d in source_dirs]
|
|
|
|
run(["node", script, "--max-warnings=0", "--"] + source_globs,
|
|
|
|
shell=False,
|
|
|
|
quiet=True)
|
|
|
|
|
|
|
|
|
|
|
|
def pylint():
|
|
|
|
print "pylint"
|
|
|
|
script = os.path.join(third_party_path, "python_packages", "pylint")
|
|
|
|
rcfile = os.path.join(third_party_path, "depot_tools", "pylintrc")
|
|
|
|
source_files = git_ls_files(root_path, ["*.py", ":!:gclient_config.py"])
|
|
|
|
run([sys.executable, script, "--rcfile=" + rcfile, "--"] + source_files,
|
|
|
|
env=python_env(),
|
|
|
|
shell=False,
|
|
|
|
quiet=True)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|