Skip to content

build: lint JavaScript and JSON from one eslint config - #35

Merged
BrandonLWhite merged 1 commit into
mainfrom
feat/unified-eslint-config
Sep 2, 2026
Merged

BrandonLWhite merged 1 commit into
mainfrom
feat/unified-eslint-config

Conversation

@BrandonLWhite

Copy link
Copy Markdown
Member

Summary

Follow-up to #28. super-linter shares one config variable (JAVASCRIPT_ES_LINTER_RULES) across its JAVASCRIPT_ES, JSON, JSONC and VUE linters, so pointing it at this repo's eslint.config.mjs would have silently stopped JSON linting — our config had no JSON language support, and an invalid .json file came back File ignored because no matching configuration was supplied with exit 0. #28 worked around that by disabling VALIDATE_JAVASCRIPT_ES, which left super-linter linting JSON with its own bundled config.

This makes one config cover both, so npm run lint and super-linter enforce the same rules over the same files.

Actions

  • Added @eslint/json and JSON + JSONC language blocks to eslint.config.mjs.
  • Scoped the JavaScript configs to js/mjs/cjs. js.configs.recommended, eslint-plugin-jest and eslint-plugin-prettier declare no files of their own, so their rules would otherwise be applied to JSON files.
  • Added .github/linters/eslint.config.mjs, re-exporting the root config, because JAVASCRIPT_ES_CONFIG_FILE resolves under LINTER_RULES_PATH (.github/linters) and not the repo root.
  • Removed VALIDATE_JAVASCRIPT_ES: false from linter.yml.
  • Turned off json/no-empty-keys for package-lock.json only — npm's packages map uses "" for the root project. The other three JSON rules still apply to it, rather than skipping the file.

Verification

  • JS rule parity: eslint --print-config src/main.js is byte-identical in effect before and after — 82 active rules, none lost, none added.
  • Coverage went up: 15 files linted → 17, now including package.json and package-lock.json.
  • It actually lints (not a silent no-op): with 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>):
    • injected duplicate JSON key → json/no-duplicate-keys, exit 1
    • injected duplicate JS binding → parse error, exit 1
    • unmodified repo files → exit 0, no warnings
  • npm run lint, npm run format:check, npm run ci-test (4 suites / 10 tests) all clean; npm run package leaves dist/ unchanged.
  • zizmor (v1.25.2, matching the container) still reports no findings.

🤖 Generated with Claude Code

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>
@BrandonLWhite
BrandonLWhite merged commit 1e1310d into main Sep 2, 2026
33 checks passed
@BrandonLWhite
BrandonLWhite deleted the feat/unified-eslint-config branch September 2, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant