Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Merge reviewed PR2835 qualified configuration protections

affaan-mda2edcb740e4
diff --cc scripts/hooks/config-protection.js
index 9250ee5b8,e82076575..6e9350d4d
--- a/scripts/hooks/config-protection.js
+++ b/scripts/hooks/config-protection.js
@@@ -57,42 -57,45 +57,76 @@@ const PROTECTED_FILES = new Set(
'.stylelintrc',
'.stylelintrc.json',
'.stylelintrc.yml',
+ '.stylelintrc.yaml',
+ '.stylelintrc.js',
+ '.stylelintrc.cjs',
+ '.stylelintrc.mjs',
+ // Stylelint's current spelling; only the legacy `.stylelintrc*` forms were
+ // listed, so a project using the documented `stylelint.config.js` had no
+ // protection at all.
+ 'stylelint.config.js',
+ 'stylelint.config.cjs',
+ 'stylelint.config.mjs',
+ 'stylelint.config.ts',
+ 'stylelint.config.mts',
+ 'stylelint.config.cts',
'.markdownlint.json',
+ '.markdownlint.jsonc',
'.markdownlint.yaml',
- '.markdownlintrc'
+ '.markdownlint.yml',
+ '.markdownlint.cjs',
+ '.markdownlint.mjs',
+ '.markdownlintrc',
+ // markdownlint-cli2 reads its own config names, not `.markdownlint.*`.
+ '.markdownlint-cli2.jsonc',
+ '.markdownlint-cli2.yaml',
+ '.markdownlint-cli2.cjs',
+ '.markdownlint-cli2.mjs',
+ // Ignore files are the cheapest way to make a check pass without touching
+ // the code OR the config: adding one path to .eslintignore silences the
+ // failing file outright. Blocking the config while leaving its ignore list
+ // open left the hook's whole purpose one line away from being defeated.
+ // First-time creation stays allowed by the same existence check below.
+ '.eslintignore',
+ '.prettierignore',
+ '.stylelintignore',
+ '.markdownlintignore'
]);
+ /**
+ * Exact basenames only catch a tool's canonical entry point. Real repos split
+ * flat config across files: a shared `eslint.config.base.mjs` holding the
+ * ignore list and rule severities, imported by per-workspace
+ * `eslint.config.mjs` files. That is the common monorepo shape, and matching
+ * basenames alone protected the leaves while leaving the trunk -- the file that
+ * actually carries the rules -- freely editable.
+ *
+ * These patterns cover `<tool>.config.<qualifier>.<ext>` and
+ * `.<tool>rc.<qualifier>.<ext>` for the linters and formatters listed above.
+ * They are case-insensitive for the same reason the Set lookup above is.
+ *
+ * Deliberately NOT matched: build and test tooling -- `vite.config.ts`,
+ * `vitest.config.ts`, `jest.config.js`, `playwright.config.ts`,
+ * `tsconfig.json`. This hook exists to stop a LINTER config being weakened in
+ * place of fixing the code; editing a bundler or test-runner config is
+ * ordinary work, and sweeping those in would make the hook obstructive.
+ */
+ const PROTECTED_PATTERNS = [
+ // eslint.config.base.mjs, prettier.config.shared.cjs, stylelint.config.local.js ...
+ /^(eslint|prettier|stylelint|commitlint|oxlint|biome)\.config(\.[A-Za-z0-9_-]+)*\.(js|mjs|cjs|ts|mts|cts)$/i,
+ // .eslintrc.base.json, .prettierrc.shared.yml ...
+ /^\.(eslintrc|prettierrc|stylelintrc|markdownlintrc)(\.[A-Za-z0-9_-]+)*\.(js|cjs|mjs|json|jsonc|yml|yaml|toml)$/i,
+ // biome.base.json, biome.shared.jsonc
+ /^biome(\.[A-Za-z0-9_-]+)*\.jsonc?$/i,
+ ];
+
+ function isProtectedName(basename) {
+ const lower = basename.toLowerCase();
+ return PROTECTED_FILES.has(basename)
+ || PROTECTED_FILES.has(lower)
+ || PROTECTED_PATTERNS.some((re) => re.test(basename));
+ }
+
function parseInput(inputOrRaw) {
if (typeof inputOrRaw === 'string') {
try {