build: lint JavaScript and JSON from one eslint config - #35
Merged
Merged
Conversation
super-linter shares JAVASCRIPT_ES_LINTER_RULES across its JAVASCRIPT_ES, JSON, JSONC and VUE linters, so a single config has to cover JS and JSON before super-linter can be pointed at ours. #28 worked around that by disabling VALIDATE_JAVASCRIPT_ES and letting ci.yml's `npm run lint` be the authority for JS, which left super-linter using its own bundled config (eslint-plugin-react rules and all) for JSON. Added @eslint/json and scoped the JavaScript configs to js/mjs/cjs. None of js.configs.recommended, eslint-plugin-jest or eslint-plugin-prettier declare `files` of their own, so without that scoping their rules would be applied to the JSON files too. .github/linters/eslint.config.mjs re-exports the root config, because JAVASCRIPT_ES_CONFIG_FILE resolves under LINTER_RULES_PATH rather than the repo root. VALIDATE_JAVASCRIPT_ES goes back to its default, so super-linter and `npm run lint` now enforce the same rules over the same files. json/no-empty-keys is off for package-lock.json only: npm's `packages` map uses "" for the root project. The file is still checked by the other three JSON rules. Verified `eslint --print-config src/main.js` is unchanged - 82 active rules before and after, none lost or added. eslint 9.39.4, the version in the super-linter container, loads this config through the shim and reports real JS and JSON errors with exit 1, so it is linting rather than silently matching nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #28. super-linter shares one config variable (
JAVASCRIPT_ES_LINTER_RULES) across itsJAVASCRIPT_ES,JSON,JSONCandVUElinters, so pointing it at this repo'seslint.config.mjswould have silently stopped JSON linting — our config had no JSON language support, and an invalid.jsonfile came backFile ignored because no matching configuration was suppliedwith exit 0. #28 worked around that by disablingVALIDATE_JAVASCRIPT_ES, which left super-linter linting JSON with its own bundled config.This makes one config cover both, so
npm run lintand super-linter enforce the same rules over the same files.Actions
@eslint/jsonand JSON + JSONC language blocks toeslint.config.mjs.js/mjs/cjs.js.configs.recommended,eslint-plugin-jestandeslint-plugin-prettierdeclare nofilesof their own, so their rules would otherwise be applied to JSON files..github/linters/eslint.config.mjs, re-exporting the root config, becauseJAVASCRIPT_ES_CONFIG_FILEresolves underLINTER_RULES_PATH(.github/linters) and not the repo root.VALIDATE_JAVASCRIPT_ES: falsefromlinter.yml.json/no-empty-keysforpackage-lock.jsononly — npm'spackagesmap uses""for the root project. The other three JSON rules still apply to it, rather than skipping the file.Verification
eslint --print-config src/main.jsis byte-identical in effect before and after — 82 active rules, none lost, none added.package.jsonandpackage-lock.json.eslint 9.39.4, the version inside the super-linter container, invoked as super-linter does (eslint -c .github/linters/eslint.config.mjs <abs path>):json/no-duplicate-keys, exit 1npm run lint,npm run format:check,npm run ci-test(4 suites / 10 tests) all clean;npm run packageleavesdist/unchanged.🤖 Generated with Claude Code