Repository: super-linter/super-linter
Pull request #6730: fix: update deprecated default file name for editorconfig
Author: login: anishadas2022
Labels: name: bug
description: Something isn't working
name: O: backlog 🤖
description: Backlog, stale ignores this label
Created: 2025-04-22T15:38:15Z | Merged: 2025-04-29T08:46:22Z

<!-- Start with an H2 because GitHub automatically adds the commit description before the template, -->
<!-- so contributors don't have to manually cut-paste the description after the H1. -->
<!-- Also, include the header in a "prettier ignore" block because it adds a blank line -->
<!-- after the markdownlint-disable-next-line directive, making it useless. -->
<!-- Ref: https://github.com/prettier/prettier/issues/14350 -->
<!-- Ref: https://github.com/prettier/prettier/issues/10128 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line MD041 -->

- Update default file name for `EDITORCONFIG_FILE_NAME` to be changed from `.ecrc` (deprecated) to `.editorconfig-checker.json`.
- Also update relevant references to .ecrc to .editorconfig-checker.json

See [editorconfig-checker documentation](https://github.com/editorconfig-checker/editorconfig-checker?tab=readme-ov-file#configuration) for the default file name change 

Fix #6616 

## Readiness checklist
<!-- prettier-ignore-end -->

In order to have this pull request merged, complete the following tasks.

### Pull request author tasks

- [ ] I checked that all workflows return a success.
- [x] I included all the needed documentation for this change.
- [x] I provided the necessary tests.
- [x] I squashed all the commits into a single commit.
- [x] I followed the
      [Conventional Commit v1.0.0 spec](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I wrote the necessary upgrade instructions in the
      [upgrade guide](../docs/upgrade-guide.md).
- [x] If this pull request is about and existing issue, I added the
      `Fix #ISSUE_NUMBER` or `Close #ISSUE_NUMBER` text to the description of
      the pull request.

### Super-linter maintainer tasks

- [x] Label as `breaking` if this change breaks compatibility with the previous
      released version.
- [x] Label as either: `automation`, `bug`, `documentation`, `enhancement`,
      `infrastructure`.
- [x] Add the pull request to a milestone, eventually creating one, that matches
      with the version that release-please proposes in the
      `preview-release-notes` CI job.


Linked issue #6616: EDITORCONFIG_FILE_NAME points to deprecated filename
### Is there an existing issue for this?

- [x] I have searched the existing issues

### Are you using the latest Super-linter version available?

- [x] I am using the latest Super-linter version.
- [x] I can reproduce the issue running Super-linter using complete version identifier (example: vX.Y.Z), and not just with a partial one (example: vX)

- [x] I am using the super-linter/super-linter action or container image, and not the deprecated github/super-linter action or container image.


### Are you resonably sure that it's a Super-linter issue, and not an issue related to a tool that Super-linter runs?

- [x] I think that this is a Super-linter issue.

### Current Behavior

With default settings and a `.github/linters/.ecrc` file, warning messages now appear:

    The default configuration file name `.ecrc` is deprecated. Use `.editorconfig-checker.json` instead. You can simply rename it



### Expected Behavior

EDITORCONFIG_FILE_NAME should be set to `.editorconfig-checker.json` by default rather than `.ecrc`. 

editorconfig's [readme](https://github.com/editorconfig-checker/editorconfig-checker?tab=readme-ov-file#configuration) states:

> The configuration is done via arguments or it will take the first config file found with the following file names:

> .editorconfig-checker.json. 
.ecrc **(deprecated filename, soon unsupported)**

emphasis mine.

### Super-Linter version

```markdown
v7.3.0
```

### Super-linter configuration

```yaml
# note: 
# /.github/linters/.ecrc must exist
# /.editorconfig must exist

on:
  workflow_call:

jobs:
  lint:
    runs-on: ubuntu-22.04

    permissions:
      contents: write
      packages: read
      statuses: write
      actions: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Lint Code Base
        uses: "super-linter/super-linter@v7" # can be v7.3.0 if you prefer
        env:
          VALIDATE_EDITORCONFIG: true
```

### Relevant log output

```shell
------
Error: -27 00:18:27 [ERROR]   Errors found in EDITORCONFIG
Error: -27 00:18:27 [ERROR]   Stdout contents for EDITORCONFIG:
------
The default configuration file name `.ecrc` is deprecated. Use `.editorconfig-checker.json` instead. You can simply rename it
Error: -27 00:18:30 [ERROR]   Super-linter detected linting errors
super-linter-output/super-linter-summary.md 57ms
```

### Steps To Reproduce

create minimal /.github/linters/.ecrc
create minimal /.editorconfig
run super-linter over a codebase with VALIDATE_EDITORCONFIG: true
see warning 

### Anything else?

https://github.com/editorconfig-checker/editorconfig-checker?tab=readme-ov-file#configuration

Diff:
diff --git a/README.md b/README.md
index bcf780d36c2..241f9af80ca 100644
--- a/README.md
+++ b/README.md
@@ -219,7 +219,7 @@ You can configure Super-linter using the following environment variables:
 | **DEFAULT_WORKSPACE**                           | `/tmp/lint`                                                                  | The location containing files to lint if you are running locally. Defaults to `GITHUB_WORKSPACE` when running in GitHub Actions. There's no need to configure this variable when running on GitHub Actions.                                                                                                                          |
 | **DISABLE_ERRORS**                              | `false`                                                                      | Flag to have the linter complete with exit code 0 even if errors were detected.                                                                                                                                                                                                                                                      |
 | **DOCKERFILE_HADOLINT_FILE_NAME**               | `.hadolint.yaml`                                                             | Filename for [hadolint configuration](https://github.com/hadolint/hadolint) (ex: `.hadolintlintrc.yaml`)                                                                                                                                                                                                                             |
-| **EDITORCONFIG_FILE_NAME**                      | `.ecrc`                                                                      | Filename for [editorconfig-checker configuration](https://github.com/editorconfig-checker/editorconfig-checker)                                                                                                                                                                                                                      |
+| **EDITORCONFIG_FILE_NAME**                      | `.editorconfig-checker.json`                                                 | Filename for [editorconfig-checker configuration](https://github.com/editorconfig-checker/editorconfig-checker)                                                                                                                                                                                                                      |
 | **ENABLE_COMMITLINT_STRICT_MODE**               | `false`                                                                      | If set to `true`, enables [commitlint strict mode](https://commitlint.js.org/reference/cli.html).                                                                                                                                                                                                                                    |
 | **ENABLE_GITHUB_ACTIONS_GROUP_TITLE**           | `false` if `RUN_LOCAL=true`, `true` otherwise                                | Flag to enable [GitHub Actions log grouping](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines).                                                                                                                                                                            |
 | **ENABLE_GITHUB_ACTIONS_STEP_SUMMARY**          | `false` if `RUN_LOCAL=true`, `true` otherwise                                | Flag to enable [GitHub Actions job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) for the Super-linter action. For more information, see [Summary outputs](#summary-outputs).                                                                                |
diff --git a/TEMPLATES/.ecrc b/TEMPLATES/.editorconfig-checker.json
similarity index 100%
rename from TEMPLATES/.ecrc
rename to TEMPLATES/.editorconfig-checker.json
diff --git a/docs/upgrade-guide.md b/docs/upgrade-guide.md
index d9ec6518b01..633a495824f 100644
--- a/docs/upgrade-guide.md
+++ b/docs/upgrade-guide.md
@@ -2,10 +2,23 @@
 
 This document helps you upgrade from a super-linter version to newer ones:
 
+- [Upgrade from v7.3.0 to v7.4.0](#upgrade-from-v730-to-v740)
 - [Upgrade from v6 to v7](#upgrade-from-v6-to-v7)
 - [Upgrade from v6.7.0 to v6.8.0](#upgrade-from-v670-to-v680)
 - [Upgrade from v5 to v6](#upgrade-from-v5-to-v6)
 
+## Upgrade from v7.3.0 to v7.4.0
+
+This section helps you upgrade from super-linter `v7.3.0` to `v7.4.0`.
+
+### editorconfig-checker default configuration filename
+
+[editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker?tab=readme-ov-file#configuration)
+changed the default configuration filename from `.ecrc` to
+`.editorconfig-checker.json`. Super-linter `v7.4.0` changed the default value of
+the `EDITORCONFIG_FILE_NAME` configuration variable to reflect that. If you are
+using an `.ecrc` file, rename it to `.editorconfig-checker.json`.
+
 ## Upgrade from v6 to v7
 
 This section helps you upgrade from super-linter `v6` to `v7`.
diff --git a/lib/functions/validation.sh b/lib/functions/validation.sh
index 1067ff7c85a..119a6d5b7d4 100755
--- a/lib/functions/validation.sh
+++ b/lib/functions/validation.sh
@@ -473,6 +473,26 @@ ValidateCommitlintConfiguration() {
   fi
 }
 
+ValidateEditorconfigCheckerConfigurationFilePath() {
+  local EDITORCONFIG_LINTER_RULES="${1}"
+
+  debug "Validating editorconfig-checker configuration file name"
+
+  if [[ "${VALIDATE_EDITORCONFIG}" == "true" ]]; then
+    local EDITORCONFIG_LINTER_RULES_DIR_NAME
+    EDITORCONFIG_LINTER_RULES_DIR_NAME="$(dirname "${EDITORCONFIG_LINTER_RULES}")"
+    local DEPRECATED_EDITORCONFIG_CONFIGURATION_FILE_NAME=".ecrc"
+
+    local DEPRECATED_EDITORCONFIG_CONFIGURATION_FILE_PATH="${EDITORCONFIG_LINTER_RULES_DIR_NAME}/${DEPRECATED_EDITORCONFIG_CONFIGURATION_FILE_NAME}"
+
+    if [[ -e "${DEPRECATED_EDITORCONFIG_CONFIGURATION_FILE_PATH}" ]]; then
+      fatal "editorconfig-checker configuration file path"
+    fi
+  else
+    debug "editorconfig-checker is disabled. Skipping editorconfig-checker configuration validation"
+  fi
+}
+
 function WarnIfVariableIsSet() {
   local INPUT_VARIABLE="${1}"
   shift
@@ -497,10 +517,48 @@ function WarnIfDeprecatedValueForConfigurationVariableIsSet() {
   VALUE_TO_UPDATE_TO="${1}"
 
   if [[ "${INPUT_VARIABLE_VALUE}" == "${DEPRECATED_VARIABLE_VALUE}" ]]; then
-    warn "${INPUT_VARIABLE_NAME} is set to a deprecated value: ${DEPRECATED_VARIABLE_VALUE}. Set it to ${VALUE_TO_UPDATE_TO} instead. Falling back to ${VALUE_TO_UPDATE_TO}. This warning may turn in a fatal error in the future."
+    warn "${INPUT_VARIABLE_NAME} is set to a deprecated value: ${DEPRECATED_VARIABLE_VALUE}. Set it to ${VALUE_TO_UPDATE_TO} instead. This warning may turn in a fatal error in the future."
   fi
 }
 
+DeprecatedConfigurationFileExists() {
+  local LANGUAGE_NAME="${1}"
+  shift
+  local DEPRECATED_CONFIGURATION_FILE_NAME="${1}"
+  shift
+  local CONFIGURATION_FILE_NAME_TO_UPDATE_TO="${1}"
+
+  local -n LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES"
+  local -n VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE_NAME}"
+
+  debug "Language ${LANGUAGE_NAME}. Check if the deprecated ${DEPRECATED_CONFIGURATION_FILE_NAME} configuration file exists"
+
+  if [[ "${VALIDATE_LANGUAGE}" == "true" ]]; then
+    local LINTER_RULES_DIR_NAME
+    LINTER_RULES_DIR_NAME="$(dirname "${LANGUAGE_LINTER_RULES}")"
+
+    local RET_CODE=$?
+    if [[ "${RET_CODE}" -gt 0 ]]; then
+      error "Error when loading LINTER_RULES_DIR_NAME for ${LANGUAGE_NAME}: ${LINTER_RULES_DIR_NAME}"
+      return 1
+    fi
+
+    local DEPRECATED_CONFIGURATION_FILE_PATH="${LINTER_RULES_DIR_NAME}/${DEPRECATED_CONFIGURATION_FILE_NAME}"
+
+    if [[ -e "${DEPRECATED_CONFIGURATION_FILE_PATH}" ]]; then
+      error "${LANGUAGE_NAME} configuration file (${DEPRECATED_CONFIGURATION_FILE_PATH}) exists and has a deprecated name (${DEPRECATED_CONFIGURATION_FILE_NAME}). Rename it to ${CONFIGURATION_FILE_NAME_TO_UPDATE_TO}"
+      return 1
+    fi
+
+    debug "The deprecated ${DEPRECATED_CONFIGURATION_FILE_NAME} configuration doesn't file exist"
+  else
+    debug "${LANGUAGE_NAME} is disabled. Skipping ${LANGUAGE_NAME} configuration file name validation"
+  fi
+
+  unset -n LANGUAGE_LINTER_RULES
+  unset -n VALIDATE_LANGUAGE
+}
+
 function ValidateDeprecatedVariables() {
 
   # The following variables have been deprecated in v6.0.0
@@ -520,4 +578,14 @@ function ValidateDeprecatedVariables() {
   # The following variables have been deprecated in v7.0.0
   WarnIfVariableIsSet "${SQL_CONFIG_FILE:-}" "SQL_CONFIG_FILE"
   WarnIfVariableIsSet "${VALIDATE_SQL:-}" "VALIDATE_SQL"
+
+  # The following values have been deprecated in v7.4.0
+  WarnIfDeprecatedValueForConfigurationVariableIsSet "${EDITORCONFIG_FILE_NAME:-}" ".ecrc" "EDITORCONFIG_FILE_NAME" ".editorconfig-checker.json"
+}
+
+ValidateDeprecatedConfigurationFiles() {
+  # The following values have been deprecated in v7.4.0
+  if ! DeprecatedConfigurationFileExists "EDITORCONFIG" ".ecrc" ".editorconfig-checker.json"; then
+    fatal "Error while validating EDITORCONFIG configuration file"
+  fi
 }
diff --git a/lib/globals/linterRules.sh b/lib/globals/linterRules.sh
index b56083708c6..6fa04252d7d 100755
--- a/lib/globals/linterRules.sh
+++ b/lib/globals/linterRules.sh
@@ -19,7 +19,7 @@ CLOUDFORMATION_FILE_NAME=".cfnlintrc.yml"
 COFFEESCRIPT_FILE_NAME=".coffee-lint.json"
 CSS_FILE_NAME="${CSS_FILE_NAME:-.stylelintrc.json}"
 DOCKERFILE_HADOLINT_FILE_NAME="${DOCKERFILE_HADOLINT_FILE_NAME:-.hadolint.yaml}"
-EDITORCONFIG_FILE_NAME="${EDITORCONFIG_FILE_NAME:-.ecrc}"
+EDITORCONFIG_FILE_NAME="${EDITORCONFIG_FILE_NAME:-.editorconfig-checker.json}"
 # shellcheck disable=SC2034  # Variable is referenced indirectly
 GITHUB_ACTIONS_FILE_NAME="${GITHUB_ACTIONS_CONFIG_FILE:-actionlint.yml}"
 # shellcheck disable=SC2034  # Variable is referenced indirectly
diff --git a/lib/linter.sh b/lib/linter.sh
index 312bdd0538b..85d87e3b638 100755
--- a/lib/linter.sh
+++ b/lib/linter.sh
@@ -770,6 +770,8 @@ done
 # Load rules for special cases
 GetStandardRules "javascript"
 
+ValidateDeprecatedConfigurationFiles
+
 #############################################################################
 # Validate the environment that depends on linter rules variables being set #
 #############################################################################
diff --git a/test/data/deprecated-linter-rules-test/.ecrc b/test/data/deprecated-linter-rules-test/.ecrc
new file mode 100644
index 00000000000..0967ef424bc
--- /dev/null
+++ b/test/data/deprecated-linter-rules-test/.ecrc
@@ -0,0 +1 @@
+{}
diff --git a/test/inspec/super-linter/controls/super_linter.rb b/test/inspec/super-linter/controls/super_linter.rb
index 27435e3b88f..f6aa7c6d125 100644
--- a/test/inspec/super-linter/controls/super_linter.rb
+++ b/test/inspec/super-linter/controls/super_linter.rb
@@ -504,7 +504,7 @@
     "/action/lib/.automation/.clang-format",
     "/action/lib/.automation/.clj-kondo",
     "/action/lib/.automation/.coffee-lint.json",
-    "/action/lib/.automation/.ecrc",
+    "/action/lib/.automation/.editorconfig-checker.json",
     "/action/lib/.automation/.eslintrc.yml",
     "/action/lib/.automation/.flake8",
     "/action/lib/.automation/.gherkin-lintrc",
diff --git a/test/lib/validationTest.sh b/test/lib/validationTest.sh
index a5281cff9b5..79b5014b10d 100755
--- a/test/lib/validationTest.sh
+++ b/test/lib/validationTest.sh
@@ -51,6 +51,8 @@ function ValidateDeprecatedVariablesTest() {
     ValidateDeprecatedVariables
   VALIDATE_KOTLIN_ANDROID="true" \
     ValidateDeprecatedVariables
+  EDITORCONFIG_FILE_NAME=".ecrc" \
+    ValidateDeprecatedVariables
 
   notice "${FUNCTION_NAME} PASS"
 }
@@ -653,6 +655,27 @@ InitializeRootCommitShaTest() {
   notice "${FUNCTION_NAME} PASS"
 }
 
+DeprecatedConfigurationFileExistsTest() {
+  local FUNCTION_NAME
+  FUNCTION_NAME="${FUNCNAME[0]}"
+  info "${FUNCTION_NAME} start"
+
+  # shellcheck disable=SC2034
+  local EDITORCONFIG_LINTER_RULES="test/data/deprecated-linter-rules-test/.editorconfig-checker.json"
+  # shellcheck disable=SC2034
+  local LANGUAGE_NAME="EDITORCONFIG"
+  # shellcheck disable=SC2034
+  local VALIDATE_EDITORCONFIG="true"
+  local DEPRECATED_CONFIGURATION_FILE_NAME=".ecrc"
+  local DEPRECATED_CONFIGURATION_FILE_PATH
+  DEPRECATED_CONFIGURATION_FILE_PATH="$(dirname "${EDITORCONFIG_LINTER_RULES}")/${DEPRECATED_CONFIGURATION_FILE_NAME}"
+  if DeprecatedConfigurationFileExists "EDITORCONFIG" "${DEPRECATED_CONFIGURATION_FILE_NAME}" "$(basename "${EDITORCONFIG_LINTER_RULES}")"; then
+    fatal "${DEPRECATED_CONFIGURATION_FILE_PATH} should be reported as existing"
+  fi
+
+  notice "${FUNCTION_NAME} PASS"
+}
+
 IsUnsignedIntegerTest
 ValidateDeprecatedVariablesTest
 ValidateGitHubUrlsTest
@@ -667,3 +690,4 @@ ValidateCommitlintConfigurationTest
 InitializeAndValidateGitBeforeShaReferenceFastForwardPushTest
 InitializeAndValidateGitBeforeShaReferenceMergeCommitPushTest
 InitializeRootCommitShaTest
+DeprecatedConfigurationFileExistsTest


Reviews:
user: login: ferrarimarco
body: Thanks for this PR.

Can you please refactor the commit message and the PR description to include a reference to the editorconfig-checker documentation about the default name change? So we don't lose context. Thanks.
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-04-22T20:38:39Z
user: login: ferrarimarco
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-28T11:14:02Z
user: login: ferrarimarco
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-28T11:15:21Z

Review comments:
diff_hunk: @@ -19,7 +19,7 @@ CLOUDFORMATION_FILE_NAME=".cfnlintrc.yml"
 COFFEESCRIPT_FILE_NAME=".coffee-lint.json"
 CSS_FILE_NAME="${CSS_FILE_NAME:-.stylelintrc.json}"
 DOCKERFILE_HADOLINT_FILE_NAME="${DOCKERFILE_HADOLINT_FILE_NAME:-.hadolint.yaml}"
-EDITORCONFIG_FILE_NAME="${EDITORCONFIG_FILE_NAME:-.ecrc}"
path: lib/globals/linterRules.sh
user: login: ferrarimarco
body: As this is implemented, it's a breaking change. Let me think how we can make it a non-breaking change, or at least require explicit user action.
created_at: 2025-04-28T11:14:02Z
author_association: COLLABORATOR
diff_hunk: @@ -19,7 +19,7 @@ CLOUDFORMATION_FILE_NAME=".cfnlintrc.yml"
 COFFEESCRIPT_FILE_NAME=".coffee-lint.json"
 CSS_FILE_NAME="${CSS_FILE_NAME:-.stylelintrc.json}"
 DOCKERFILE_HADOLINT_FILE_NAME="${DOCKERFILE_HADOLINT_FILE_NAME:-.hadolint.yaml}"
-EDITORCONFIG_FILE_NAME="${EDITORCONFIG_FILE_NAME:-.ecrc}"
path: lib/globals/linterRules.sh
user: login: ferrarimarco
body: Otherwise, users that rely on the old value being set, will see their editorconfig-checker configuration silently ignored
created_at: 2025-04-28T11:15:21Z
author_association: COLLABORATOR

PR comments:
user: login: anishadas2022
created_at: 2025-04-23T10:55:54Z
body: > Thanks for this PR.
> 
> Can you please refactor the commit message and the PR description to include a reference to the editorconfig-checker documentation about the default name change? So we don't lose context. Thanks.

Hey, thanks for the review. I've updated the PR and commit descriptions with your suggestions 
author_association: CONTRIBUTOR
user: login: ferrarimarco
created_at: 2025-04-28T11:11:46Z
body: Hi! There are [two linting failures](https://github.com/super-linter/super-linter/actions/runs/14616356008/job/41034360852?pr=6730). Can you please have a look? Thanks!
author_association: COLLABORATOR
user: login: ferrarimarco
created_at: 2025-04-29T08:05:33Z
body: I've updated this PR to include some validation checks, so users can act and update the name of the editorconfig-checker configuration file name.
author_association: COLLABORATOR