コード例 #1
0
ファイル: lint.py プロジェクト: zzl-git/deno
def 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.
    source_files = get_sources(root_path, [
        "*.js",
        "*.ts",
        ":!:cli/tests/swc_syntax_error.ts",
        ":!:std/**/testdata/*",
        ":!:std/**/node_modules/*",
        ":!:cli/compilers/wasm_wrap.js",
        ":!:cli/tests/error_syntax.js",
        ":!:cli/tests/lint/**",
        ":!:cli/dts/**",
        ":!:cli/tsc/*typescript.js",
    ])
    if source_files:
        max_command_len = 30000
        pre_command = ["node", script, "--max-warnings=0", "--"]
        chunks = [[]]
        cmd_len = len(" ".join(pre_command))
        for f in source_files:
            if cmd_len + len(f) > max_command_len:
                chunks.append([f])
                cmd_len = len(" ".join(pre_command))
            else:
                chunks[-1].append(f)
                cmd_len = cmd_len + len(f) + 1
        for c in chunks:
            print_command("eslint", c)
            # Set NODE_PATH so we don't have to maintain a symlink in root_path.
            env = os.environ.copy()
            env["NODE_PATH"] = os.path.join(root_path, "third_party",
                                            "node_modules")
            run(pre_command + c, shell=False, env=env, quiet=True)
コード例 #2
0
ファイル: format.py プロジェクト: yanggeorge/deno
def yapf():
    script = os.path.join(third_party_path, "python_packages", "bin", "yapf")
    source_files = get_sources(root_path, ["*.py"])
    if source_files:
        print_command("yapf", source_files)
        run([sys.executable, script, "-i", "--style=pep8", "--"] +
            source_files,
            env=python_env(),
            shell=False,
            quiet=True)
コード例 #3
0
ファイル: format.py プロジェクト: anthonyhumphreys/edon
def prettier():
    script = os.path.join(third_party_path, "node_modules", "prettier",
                          "bin-prettier.js")
    source_files = get_sources(root_path, ["*.js", "*.json", "*.ts", "*.md"])
    if source_files:
        print_command("prettier", source_files)
        run(["node", script, "--write", "--loglevel=error", "--"] +
            source_files,
            shell=False,
            quiet=True)
コード例 #4
0
ファイル: format.py プロジェクト: yanggeorge/deno
def rustfmt():
    config_file = os.path.join(root_path, ".rustfmt.toml")
    source_files = get_sources(root_path, ["*.rs"])
    if source_files:
        print_command("rustfmt", source_files)
        run([
            "rustfmt",
            "--config-path=" + config_file,
            "--",
        ] + source_files,
            shell=False,
            quiet=True)
コード例 #5
0
def pylint():
    script = os.path.join(third_party_path, "python_packages", "pylint")
    rcfile = os.path.join(root_path, "tools", "pylintrc")
    msg_template = "{path}({line}:{column}) {category}: {msg} ({symbol})"
    source_files = get_sources(root_path, ["*.py"])
    if source_files:
        print_command("pylint", source_files)
        run([
            sys.executable, script, "--rcfile=" + rcfile,
            "--msg-template=" + msg_template, "--"
        ] + source_files,
            env=python_env(),
            shell=False,
            quiet=True)
コード例 #6
0
ファイル: lint.py プロジェクト: anthonyhumphreys/edon
def 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.
    source_files = get_sources(root_path, [
        "*.js", "*.ts", ":!:std/**/testdata/*", ":!:std/**/node_modules/*",
        ":!:cli/compilers/wasm_wrap.js", ":!:cli/tests/error_syntax.js"
    ])
    if source_files:
        print_command("eslint", source_files)
        # Set NODE_PATH so we don't have to maintain a symlink in root_path.
        env = os.environ.copy()
        env["NODE_PATH"] = os.path.join(root_path, "third_party",
                                        "node_modules")
        run(["node", script, "--max-warnings=0", "--"] + source_files,
            shell=False,
            env=env,
            quiet=True)
コード例 #7
0
def dlint():
    executable_path = get_prebuilt_tool_path("dlint")

    # Find all *directories* in the main repo that contain .ts/.js files.
    source_files = get_sources(root_path, [
        "*.js",
        "*.ts",
        ":!:cli/tests/swc_syntax_error.ts",
        ":!:cli/tests/038_checkjs.js",
        ":!:cli/tests/error_008_checkjs.js",
        ":!:std/**/testdata/*",
        ":!:std/**/node_modules/*",
        ":!:cli/bench/node*.js",
        ":!:cli/compilers/wasm_wrap.js",
        ":!:cli/dts/**",
        ":!:cli/tests/encoding/**",
        ":!:cli/tests/error_syntax.js",
        ":!:cli/tests/lint/**",
        ":!:cli/tests/tsc/**",
        ":!:cli/tsc/*typescript.js",
    ])
    if source_files:
        max_command_len = 30000
        pre_command = [executable_path, "run"]
        chunks = [[]]
        cmd_len = len(" ".join(pre_command))
        for f in source_files:
            if cmd_len + len(f) > max_command_len:
                chunks.append([f])
                cmd_len = len(" ".join(pre_command))
            else:
                chunks[-1].append(f)
                cmd_len = cmd_len + len(f) + 1
        for c in chunks:
            print_command("dlint", c)
            run(pre_command + c, shell=False, quiet=True)