mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Add editorconfig-checker
see: https://github.com/editorconfig-checker/editorconfig-checker/
This commit is contained in:
parent
f948639bf1
commit
9a838766cb
10 changed files with 118 additions and 1 deletions
3
.automation/test/editorconfig-checker/.editorconfig
Normal file
3
.automation/test/editorconfig-checker/.editorconfig
Normal file
|
@ -0,0 +1,3 @@
|
|||
[*.ext]
|
||||
indent_style = space
|
||||
indent_size = 4
|
13
.automation/test/editorconfig-checker/README.md
Normal file
13
.automation/test/editorconfig-checker/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# EDITORCONFIG_CHECKER Test Cases
|
||||
This folder holds the test cases for **EDITORCONFIG_CHECKER**.
|
||||
|
||||
## Additional Docs
|
||||
No Additional information is needed for this test case.
|
||||
|
||||
## Good Test Cases
|
||||
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
||||
|
||||
## Bad Test Cases
|
||||
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
|
@ -0,0 +1,3 @@
|
|||
some line
|
||||
some line
|
||||
some line
|
|
@ -0,0 +1,3 @@
|
|||
some line
|
||||
some line
|
||||
some line
|
18
.github/linters/.ecrc
vendored
Normal file
18
.github/linters/.ecrc
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"Verbose": false,
|
||||
"Debug": false,
|
||||
"IgnoreDefaults": false,
|
||||
"SpacesAftertabs": false,
|
||||
"NoColor": false,
|
||||
"Exclude": [],
|
||||
"AllowedContentTypes": [],
|
||||
"PassedFiles": [],
|
||||
"Disable": {
|
||||
"EndOfLine": false,
|
||||
"Indentation": false,
|
||||
"InsertFinalNewline": false,
|
||||
"TrimTrailingWhitespace": false,
|
||||
"IndentSize": false,
|
||||
"MaxLineLength": false
|
||||
}
|
||||
}
|
|
@ -159,6 +159,12 @@ RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KON
|
|||
RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && chmod a+x ktlint \
|
||||
&& mv "ktlint" /usr/bin/
|
||||
|
||||
################################
|
||||
# Install editorconfig-checker #
|
||||
################################
|
||||
RUN wget -qO- "https://github.com/editorconfig-checker/editorconfig-checker/releases/latest/download/ec-linux-amd64.tar.gz" | tar -xzf - \
|
||||
&& mv "bin/ec-linux-amd64" /usr/bin/editorconfig-checker
|
||||
|
||||
###########################################
|
||||
# Load GitHub Env Vars for GitHub Actions #
|
||||
###########################################
|
||||
|
@ -193,6 +199,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
|||
VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \
|
||||
VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \
|
||||
VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \
|
||||
VALIDATE_EDITORCONFIG=${VALIDATE_EDITORCONFIG} \
|
||||
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
|
||||
RUN_LOCAL=${RUN_LOCAL} \
|
||||
TEST_CASE_RUN=${TEST_CASE_RUN} \
|
||||
|
|
|
@ -39,6 +39,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) |
|
||||
| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) |
|
||||
| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) |
|
||||
| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) |
|
||||
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
||||
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
||||
| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
||||
|
@ -179,6 +180,7 @@ and won't run anything unexpected.
|
|||
| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_EDITORCONFIG** | `true` | Flag to enable or disable the linting process with the editorconfig. |
|
||||
| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). |
|
||||
| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. |
|
||||
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
|
||||
|
|
|
@ -36,6 +36,7 @@ For some linters it is also possible to override rules on a case by case level w
|
|||
- [Kotlin](#kotlin)
|
||||
- [OpenAPI](#openapi)
|
||||
- [Protocol Buffers](#protocol-buffers)
|
||||
- [EDITORCONFIG-CHECKER](#editorconfig-checker)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
|
@ -742,4 +743,36 @@ lint:
|
|||
### clj-kondo disable entire file
|
||||
```clojure
|
||||
{:output {:exclude-files ["path/to/file"]}}
|
||||
|
||||
## EDITORCONFIG-CHECKER
|
||||
- [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
### editorconfig-checker Config file
|
||||
- `.github/linters/.ecrc`
|
||||
- This linter will also use the [`.editorconfig`](https://editorconfig.org/) of your project
|
||||
|
||||
### editorconfig-checker disable single line
|
||||
-
|
||||
```js
|
||||
<LINE> // editorconfig-checker-disable-line
|
||||
```
|
||||
|
||||
### editorconfig-checker disable code block
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
### editorconfig-checker disable entire file
|
||||
-
|
||||
```js
|
||||
// editorconfig-checker-disable-file
|
||||
```
|
||||
- You can disable entire files with the `Exclude` property in `.ecrc`
|
||||
```json
|
||||
{
|
||||
"Exclude": [
|
||||
"path/to/file",
|
||||
"^regular\\/expression\\.ext$"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
@ -129,6 +129,7 @@ VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to vali
|
|||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
||||
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
||||
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
||||
|
||||
|
@ -743,6 +744,7 @@ Footer() {
|
|||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
############################### MAIN ###########################################
|
||||
################################################################################
|
||||
|
@ -1069,6 +1071,18 @@ if [ "$VALIDATE_KOTLIN" == "true" ]; then
|
|||
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}"
|
||||
fi
|
||||
|
||||
########################
|
||||
# EDITORCONFIG LINTING #
|
||||
########################
|
||||
echo ed: "$VALIDATE_EDITORCONFIG"
|
||||
if [ "$VALIDATE_EDITORCONFIG" == "true" ]; then
|
||||
####################################
|
||||
# Lint the files with editorconfig #
|
||||
####################################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILE_ARRAY_ENV[@]}"
|
||||
fi
|
||||
|
||||
##################
|
||||
# DOCKER LINTING #
|
||||
##################
|
||||
|
|
|
@ -71,6 +71,7 @@ function GetValidationInfo() {
|
|||
VALIDATE_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}')
|
||||
VALIDATE_PROTOBUF=$(echo "$VALIDATE_PROTOBUF" | awk '{print tolower($0)}')
|
||||
VALIDATE_OPENAPI=$(echo "$VALIDATE_OPENAPI" | awk '{print tolower($0)}')
|
||||
VALIDATE_EDITORCONFIG=$(echo "$VALIDATE_EDITORCONFIG" | awk '{print tolower($0)}')
|
||||
|
||||
################################################
|
||||
# Determine if any linters were explicitly set #
|
||||
|
@ -100,7 +101,8 @@ function GetValidationInfo() {
|
|||
$VALIDATE_CLOJURE || -n \
|
||||
$VALIDATE_PROTOBUF || -n \
|
||||
$VALIDATE_OPENAPI || -n \
|
||||
$VALIDATE_KOTLIN ]]; then
|
||||
$VALIDATE_KOTLIN || -n \
|
||||
$VALIDATE_EDITORCONFIG ]]; then
|
||||
ANY_SET="true"
|
||||
fi
|
||||
|
||||
|
@ -454,6 +456,20 @@ function GetValidationInfo() {
|
|||
VALIDATE_CLOJURE="true"
|
||||
fi
|
||||
|
||||
############################################
|
||||
# Validate if we should check editorconfig #
|
||||
############################################
|
||||
if [[ $ANY_SET == "true" ]]; then
|
||||
# Some linter flags were set - only run those set to true
|
||||
if [[ -z $VALIDATE_EDITORCONFIG ]]; then
|
||||
# EDITORCONFIG flag was not set - default to false
|
||||
VALIDATE_EDITORCONFIG="false"
|
||||
fi
|
||||
else
|
||||
# No linter flags were set - default all to true
|
||||
VALIDATE_EDITORCONFIG="true"
|
||||
fi
|
||||
|
||||
#######################################
|
||||
# Print which linters we are enabling #
|
||||
#######################################
|
||||
|
@ -582,6 +598,11 @@ function GetValidationInfo() {
|
|||
else
|
||||
PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...")
|
||||
fi
|
||||
if [[ $VALIDATE_EDITORCONFIG == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [EDITORCONFIG] files in code base...")
|
||||
else
|
||||
PRINT_ARRAY+=("- Excluding [EDITORCONFIG] files in code base...")
|
||||
fi
|
||||
|
||||
##############################
|
||||
# Validate Ansible Directory #
|
||||
|
|
Loading…
Reference in a new issue