diff --git a/.github/linters/.sql-config.json b/.github/linters/.sql-config.json new file mode 100644 index 00000000..09c092d7 --- /dev/null +++ b/.github/linters/.sql-config.json @@ -0,0 +1,4 @@ +{ + "driver": "mysql", + "host": "localhost" +} diff --git a/TEMPLATES/.sql-config.json b/TEMPLATES/.sql-config.json new file mode 100644 index 00000000..09c092d7 --- /dev/null +++ b/TEMPLATES/.sql-config.json @@ -0,0 +1,4 @@ +{ + "driver": "mysql", + "host": "localhost" +} diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 42acb7f4..13db1ee2 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -1017,7 +1017,9 @@ moreThings() ### SQL Config file -- There is no top level _configuration file_ available at this time +- `.github/linters/.sql-config.json` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.sql-json` ### SQL disable single line diff --git a/lib/linter.sh b/lib/linter.sh index 23da8060..06f4e466 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -110,6 +110,9 @@ PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME} # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules +# SQL Vars +SQL_FILE_NAME=".sql-config.json" # Name of the file +SQL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${SQL_FILE_NAME}" # Path to the SQL lint rules # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules @@ -1198,6 +1201,8 @@ GetLinterRules "PYTHON_PYLINT" GetLinterRules "PYTHON_FLAKE8" # Get Ruby rules GetLinterRules "RUBY" +# Get SQL rules +GetLinterRules "SQL" # Get Terraform rules GetLinterRules "TERRAFORM" # Get TypeScript rules @@ -1736,7 +1741,7 @@ if [ "${VALIDATE_SQL}" == "true" ]; then # Lint the SQL files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "SQL" "sql-lint" "sql-lint" ".*\.\(sql\)\$" "${FILE_ARRAY_SQL[@]}" + LintCodebase "SQL" "sql-lint" "sql-lint -c ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "${FILE_ARRAY_SQL[@]}" fi ##################### diff --git a/lib/worker.sh b/lib/worker.sh index d1896434..ae94f966 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -603,7 +603,7 @@ function RunTestCases() { TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" - TestCodebase "SQL" "sql-lint" "sql-lint" ".*\.\(sql\)\$" "sql" + TestCodebase "SQL" "sql-lint" "sql-lint -c ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "sql" TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f" ".*\.\(tf\)\$" "terraform_terrascan" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript"