mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-11 21:57:14 +03:00
Preserve advisory detector settings
AI assistance was used to reproduce and fix automated review feedback, add regression coverage, and run validation.
This commit is contained in:
@@ -166,7 +166,7 @@ function readRawConfigFile(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
const DETECTOR_CONFIG_KEYS = new Set(['ignoreRules', 'ignoreFiles', 'ignoreValues', 'designSystem']);
|
||||
const DETECTOR_CONFIG_KEYS = new Set(['ignoreRules', 'ignoreFiles', 'ignoreValues', 'designSystem', 'advisoryRules']);
|
||||
|
||||
function hookSection(unified) {
|
||||
return unified && typeof unified === 'object' && !Array.isArray(unified) && unified.hook && typeof unified.hook === 'object' && !Array.isArray(unified.hook)
|
||||
@@ -259,12 +259,18 @@ function mergeDetectorConfig(existing, seed = null) {
|
||||
if (seed?.designSystem && typeof seed.designSystem === 'object' && !Array.isArray(seed.designSystem)) {
|
||||
out.designSystem = { ...seed.designSystem };
|
||||
}
|
||||
if (seed?.advisoryRules === 'include' || seed?.advisoryRules === 'exclude') {
|
||||
out.advisoryRules = seed.advisoryRules;
|
||||
}
|
||||
if (base.designSystem && typeof base.designSystem === 'object' && !Array.isArray(base.designSystem)) {
|
||||
out.designSystem = {
|
||||
...(out.designSystem || {}),
|
||||
enabled: base.designSystem.enabled === false ? false : true,
|
||||
};
|
||||
}
|
||||
if (base.advisoryRules === 'include' || base.advisoryRules === 'exclude') {
|
||||
out.advisoryRules = base.advisoryRules;
|
||||
}
|
||||
if (Array.isArray(base.ignoreRules)) {
|
||||
out.ignoreRules = Array.from(new Set([...out.ignoreRules, ...base.ignoreRules.map(String)]));
|
||||
}
|
||||
|
||||
@@ -994,6 +994,19 @@ describe('hook-admin.mjs', () => {
|
||||
assert.match(out, /local detector\.ignoreFiles/);
|
||||
});
|
||||
|
||||
it('ignore-file --local preserves the local advisory-rule preference', () => {
|
||||
fs.mkdirSync(path.dirname(getLocalConfigPath(cwd)), { recursive: true });
|
||||
fs.writeFileSync(getLocalConfigPath(cwd), JSON.stringify({
|
||||
detector: { advisoryRules: 'include' },
|
||||
}));
|
||||
|
||||
runAdmin(['ignore-file', '/abs/path/personal.html', '--local']);
|
||||
|
||||
const local = JSON.parse(fs.readFileSync(getLocalConfigPath(cwd), 'utf-8')).detector;
|
||||
assert.equal(local.advisoryRules, 'include');
|
||||
assert.deepEqual(local.ignoreFiles, ['/abs/path/personal.html']);
|
||||
});
|
||||
|
||||
it('ignore-file refuses unsupported reasons and unknown flags', () => {
|
||||
assert.throws(
|
||||
() => runAdmin(['ignore-file', 'src/legacy/**', '--reason', 'machine-local path']),
|
||||
|
||||
Reference in New Issue
Block a user