Skip to content

feat(plugin-js): add no-config-file-tests rule - #92

Merged
nekomeowww merged 2 commits into
alint-dev:mainfrom
arvinxx:arvinxx/feat/no-config-file-tests
Sep 28, 2026
Merged

nekomeowww merged 2 commits into
alint-dev:mainfrom
arvinxx:arvinxx/feat/no-config-file-tests

Conversation

@arvinxx

@arvinxx arvinxx commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Configuration keeps growing standalone test suites: eslint.config.ts gets an eslint.config.test.ts that imports the config object and asserts the rule list. The test restates what the configuration already declares, so every intentional configuration change fails it — and a failing copy is easy to read as evidence that the configuration change is wrong. This came up in Discord while reviewing exactly such a diff ("eslint 改个 rule 都加上 test case 了").

What this adds

js/no-config-file-tests, a model-backed, cacheable rule in @alint-js/plugin-js:

  • reviews test files only — a path that is not a test file (*.test.*, *.spec.*, __tests__/) is skipped before the model call, so a broad files: glob does not pay for every source file
  • reports a test file whose subject is repository configuration (linter, compiler, bundler, test-runner, release or tool config, package.json) rather than production behavior
  • suppresses tests for logic the repository owns (custom lint rules, custom bundler plugins, configuration merge or normalization helpers), tests that run the configured tool over a fixture, and configuration that carries policy the test has to prove (ignore lists kept in sync with another file, permission lists, cross-file invariants)

Registered but not added to recommended: it only applies to test files, and which globs reach them is the user's call. The README documents it with an opt-in snippet.

Verification

  • pnpm -F @alint-js/plugin-js typecheck
  • pnpm -F @alint-js/plugin-js exec vitest run — 13 passed, 3 new
  • pnpm typecheck and pnpm exec eslint --cache . at the repo root

Review notes

  • Name: js/no-config-file-tests. Happy to rename.
  • This repo's own alint.config.ts ignores **/*.test.ts, so the rule cannot fire here until test files are part of the run. I left that config alone on purpose — it decides how much of the repo alint sees.
  • Windows separators are normalized before the test-file match. tests/ or test/ directories without a *.test.* suffix are not treated as test files, so fixture trees stay out of scope.

Requested in Discord; drafted by the Discord assistant, so please treat it as a proposal rather than a finished decision.

arvinxx and others added 2 commits September 28, 2026 15:37
Configuration is declarative, so a standalone test that restates it keeps a second copy of values the configuration already states: every intentional configuration change fails the test, and the failing copy reads as evidence that the change is wrong.

The rule reviews test files only. Non-test files are skipped before the model call, so a broad `files:` glob does not pay for every source file, and it is registered without changing `recommended`.

Prompt suppresses tests for logic the repository owns, tests that run the configured tool over a fixture, and configuration that carries policy the test must prove.
@nekomeowww
nekomeowww merged commit 3162d56 into alint-dev:main Sep 28, 2026
2 checks passed
@arvinxx
arvinxx deleted the arvinxx/feat/no-config-file-tests branch September 28, 2026 17: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.

2 participants