Skip to content

Commit

Permalink
fix: Ignore global ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
GZolla committed Nov 28, 2024
1 parent 35ba3b0 commit 04ea0ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ts-check
const defaultGroups = {
'accessor-pairs': [{ 'accessorPair': true, 'sort': 'alphabetical' }],
'accessors': [{ 'kind': 'get', 'accessorPair': false, 'sort': 'alphabetical' }, { 'kind': 'set', 'accessorPair': false, 'sort': 'alphabetical' }],
Expand Down Expand Up @@ -36,16 +35,23 @@ export const getSortMemberRules = (order, groups) => {
};
};

function isGlobalIgnores(config) {
const keys = Object.keys(config);
return keys.length === 1 && keys[0] === 'ignores';
}

export function setDirectoryConfigs(globalConfig, directoryConfigs) {
const configs = globalConfig.map(c => ({ ...c }));
for (const dir in directoryConfigs) {
const pattern = `${dir}/**/*`;
for (const baseConfig of configs) {
if (isGlobalIgnores(baseConfig)) continue;
if (!(baseConfig.ignores)) baseConfig.ignores = [];
baseConfig.ignores.push(pattern);
}

for (const dirConfig of directoryConfigs[dir]) {
if (isGlobalIgnores(dirConfig)) continue;
const files = dirConfig.files ? dirConfig.files.map(f => `${dir}/${f}`) : [pattern];
configs.push({
...dirConfig,
Expand All @@ -59,6 +65,7 @@ export function setDirectoryConfigs(globalConfig, directoryConfigs) {

export function addExtensions(config, extensions) {
return config.map(c => {
if (isGlobalIgnores(c)) return c;
const newFiles = [];
for (const f of (c.files ?? ['**/*'])) {
if (f.includes('.')) newFiles.push(f);
Expand Down

0 comments on commit 04ea0ae

Please sign in to comment.