mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
tools: refactor lint.py and format.py (#2950)
This commit is contained in:
parent
456b75cbf9
commit
fbfd895bc7
5 changed files with 139 additions and 83 deletions
|
@ -4,28 +4,66 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from util import enable_ansi_colors, find_exts, root_path, run, third_party_path
|
||||
from util import enable_ansi_colors, git_ls_files, root_path, run
|
||||
from util import third_party_path
|
||||
from third_party import python_env
|
||||
|
||||
enable_ansi_colors()
|
||||
|
||||
cpplint = os.path.join(third_party_path, "cpplint", "cpplint.py")
|
||||
eslint = os.path.join(third_party_path, "node_modules", "eslint", "bin",
|
||||
"eslint")
|
||||
def main():
|
||||
enable_ansi_colors()
|
||||
os.chdir(root_path)
|
||||
cpplint()
|
||||
eslint()
|
||||
pylint()
|
||||
|
||||
os.chdir(root_path)
|
||||
run([
|
||||
sys.executable, cpplint, "--filter=-build/include_subdir",
|
||||
"--repository=core/libdeno", "--extensions=cc,h", "--recursive", "core"
|
||||
])
|
||||
|
||||
run([
|
||||
"node", eslint, "--max-warnings=0", "./js/**/*.{ts,js}",
|
||||
"./core/**/*.{ts,js}", "./tests/**/*.{ts,js}"
|
||||
])
|
||||
def cpplint():
|
||||
print "cpplint"
|
||||
script = os.path.join(third_party_path, "cpplint", "cpplint.py")
|
||||
libdeno_dir = os.path.join(root_path, "core", "libdeno")
|
||||
source_files = git_ls_files(libdeno_dir, ["*.cc", "*.h"])
|
||||
run([
|
||||
sys.executable,
|
||||
script,
|
||||
"--quiet",
|
||||
"--filter=-build/include_subdir",
|
||||
"--repository=" + libdeno_dir,
|
||||
"--",
|
||||
] + source_files,
|
||||
env=python_env(),
|
||||
shell=False,
|
||||
quiet=True)
|
||||
|
||||
run([
|
||||
sys.executable, "third_party/python_packages/pylint",
|
||||
"--rcfile=third_party/depot_tools/pylintrc"
|
||||
] + find_exts(["tools", "build_extra"], [".py"], skip=["tools/clang"]),
|
||||
env=python_env())
|
||||
|
||||
def eslint():
|
||||
print "eslint"
|
||||
script = os.path.join(third_party_path, "node_modules", "eslint", "bin",
|
||||
"eslint")
|
||||
# TODO: Files in 'deno_typescript', 'tools' and 'website' directories are
|
||||
# currently not linted, but they should.
|
||||
source_files = git_ls_files(
|
||||
root_path,
|
||||
["*.js", "*.ts", ":!:deno_typescript/", ":!:tools/", ":!:website/"])
|
||||
# Find all *directories* in the main repo that contain .ts/.js files.
|
||||
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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue