2024-08-07 09:36:16 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# shellcheck disable=SC2034 # Disable ununsed variables warning because we
|
|
|
|
# source this script and use these variables as globals
|
|
|
|
|
|
|
|
# "check only" mode options for linters that that we reuse across several languages
|
|
|
|
PRETTIER_CHECK_ONLY_MODE_OPTIONS=(--check)
|
|
|
|
RUSTFMT_CHECK_ONLY_MODE_OPTIONS=(--check)
|
2024-08-16 10:23:52 -04:00
|
|
|
DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--verify-no-changes)
|
2024-08-07 09:36:16 -04:00
|
|
|
|
|
|
|
# Define configuration options to enable "check only" mode.
|
|
|
|
# Some linters and formatters only support a "check only" mode so there's no
|
|
|
|
# need to define a "check only" mode option for those.
|
|
|
|
CLANG_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run)
|
2024-08-16 10:23:52 -04:00
|
|
|
CSHARP_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
CSS_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-16 10:23:52 -04:00
|
|
|
DOTNET_SLN_FORMAT_ANALYZERS_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
DOTNET_SLN_FORMAT_STYLE_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
DOTNET_SLN_FORMAT_WHITESPACE_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
GOOGLE_JAVA_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run --set-exit-if-changed)
|
2024-08-15 05:46:02 -04:00
|
|
|
GRAPHQL_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
HTML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
JAVASCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
JSON_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-16 11:15:05 -04:00
|
|
|
JSONC_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
JSX_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
MARKDOWN_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
PYTHON_BLACK_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
|
|
|
|
PYTHON_ISORT_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
|
|
|
|
RUST_2015_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
RUST_2018_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
RUST_2021_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
SCALAFMT_CHECK_ONLY_MODE_OPTIONS=(--test)
|
|
|
|
SHELL_SHFMT_CHECK_ONLY_MODE_OPTIONS=(--diff)
|
|
|
|
SNAKEMAKE_SNAKEFMT_CHECK_ONLY_MODE_OPTIONS=(--check --compact-diff)
|
|
|
|
SQLFLUFF_CHECK_ONLY_MODE_OPTIONS=(lint)
|
|
|
|
TERRAFORM_FMT_CHECK_ONLY_MODE_OPTIONS=(-check -diff)
|
|
|
|
TYPESCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
VUE_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
|
|
|
YAML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
|
|
|
|
# Fix mode options for linters that that we reuse across several languages
|
|
|
|
ESLINT_FIX_MODE_OPTIONS=(--fix)
|
|
|
|
GOLANGCI_LINT_FIX_MODE_OPTIONS=(--fix)
|
|
|
|
PRETTIER_FIX_MODE_OPTIONS=(--write)
|
|
|
|
STANDARD_FIX_MODE_OPTIONS=(--fix)
|
|
|
|
|
|
|
|
# Define configuration options to enable "fix mode".
|
|
|
|
# Not all linters and formatters support this.
|
|
|
|
ANSIBLE_FIX_MODE_OPTIONS=(--fix)
|
2024-08-12 06:31:38 -04:00
|
|
|
CLANG_FORMAT_FIX_MODE_OPTIONS=(-i)
|
2024-08-07 09:36:16 -04:00
|
|
|
CSS_FIX_MODE_OPTIONS=(--fix)
|
2024-08-15 05:46:02 -04:00
|
|
|
CSS_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-12 06:31:38 -04:00
|
|
|
ENV_FIX_MODE_OPTIONS=(fix --no-backup)
|
2024-08-07 09:36:16 -04:00
|
|
|
GO_FIX_MODE_OPTIONS=("${GOLANGCI_LINT_FIX_MODE_OPTIONS[@]}")
|
|
|
|
GO_MODULES_FIX_MODE_OPTIONS=("${GOLANGCI_LINT_FIX_MODE_OPTIONS[@]}")
|
2024-08-12 06:31:38 -04:00
|
|
|
GOOGLE_JAVA_FORMAT_FIX_MODE_OPTIONS=(--replace)
|
2024-08-15 05:46:02 -04:00
|
|
|
GRAPHQL_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
GROOVY_FIX_MODE_OPTIONS=(--fix)
|
2024-08-15 05:46:02 -04:00
|
|
|
HTML_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
JAVASCRIPT_ES_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
|
|
|
JAVASCRIPT_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
|
|
|
JAVASCRIPT_STANDARD_FIX_MODE_OPTIONS=("${STANDARD_FIX_MODE_OPTIONS[@]}")
|
|
|
|
JSON_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
JSON_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
JSONC_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
2024-08-16 11:15:05 -04:00
|
|
|
JSONC_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
JSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
JSX_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
MARKDOWN_FIX_MODE_OPTIONS=(--fix)
|
2024-08-15 05:46:02 -04:00
|
|
|
MARKDOWN_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-12 06:31:38 -04:00
|
|
|
NATURAL_LANGUAGE_FIX_MODE_OPTIONS=(--fix)
|
2024-08-07 09:36:16 -04:00
|
|
|
POWERSHELL_FIX_MODE_OPTIONS=(-Fix)
|
|
|
|
PROTOBUF_FIX_MODE_OPTIONS=(-fix)
|
2024-08-12 06:31:38 -04:00
|
|
|
PYTHON_ISORT_FIX_MODE_OPTIONS=(--overwrite-in-place)
|
2024-08-07 09:36:16 -04:00
|
|
|
PYTHON_RUFF_FIX_MODE_OPTIONS=(--fix)
|
|
|
|
RUBY_FIX_MODE_OPTIONS=(--autocorrect)
|
2024-08-12 06:31:38 -04:00
|
|
|
RUST_CLIPPY_FIX_MODE_OPTIONS=(--fix --allow-dirty --allow-staged)
|
2024-08-07 09:36:16 -04:00
|
|
|
SHELL_SHFMT_FIX_MODE_OPTIONS=(--write)
|
|
|
|
SQLFLUFF_FIX_MODE_OPTIONS=(fix)
|
|
|
|
TSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
|
|
|
TYPESCRIPT_ES_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
|
|
|
|
TYPESCRIPT_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
|
|
|
TYPESCRIPT_STANDARD_FIX_MODE_OPTIONS=("${STANDARD_FIX_MODE_OPTIONS[@]}")
|
2024-08-15 05:46:02 -04:00
|
|
|
VUE_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
|
|
|
YAML_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
|
2024-08-07 09:36:16 -04:00
|
|
|
|
|
|
|
# sqlfluff is a special case because it needs a different subcommand and
|
|
|
|
# subcommand options
|
|
|
|
SQLFLUFF_SHARED_SUBCOMMAND_OPTIONS=(--config "${SQLFLUFF_LINTER_RULES}")
|
|
|
|
SQLFLUFF_CHECK_ONLY_MODE_OPTIONS+=("${SQLFLUFF_SHARED_SUBCOMMAND_OPTIONS[@]}")
|
|
|
|
SQLFLUFF_FIX_MODE_OPTIONS+=("${SQLFLUFF_SHARED_SUBCOMMAND_OPTIONS[@]}")
|
|
|
|
|
|
|
|
# If there's no input argument, GNU Parallel adds a default {} at the end of the
|
|
|
|
# command it runs. In a few cases, such as ANSIBLE, GO_MODULES, and RUST_CLIPPY,
|
|
|
|
# consume the {} element by artifically adding it to the command to run because
|
|
|
|
# we need the input to set the working directory, but we don't need it appended
|
|
|
|
# at the end of the command.
|
|
|
|
# Setting the -n 0 GNU Parallel would not help in this case, because the input
|
|
|
|
# will not be passed to the --workdir option as well.
|
|
|
|
INPUT_CONSUME_COMMAND=("&& echo \"Linted: {}\"")
|
2024-08-14 08:54:16 -04:00
|
|
|
|
|
|
|
GITLEAKS_LOG_LEVEL_OPTIONS=("--log-level")
|