Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .felixrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fixers": ["eslint", "prettier"],
"fixers": ["eslint", "prettier", "wc"],
"paths": ["src/**", "examples/**", "tests/**", "*.md", "jest.config.js", "test-felix.js"],
"ignore": ["node_modules/**", "dist/**", "build/**", ".git/**", "coverage/**", "test-files/**", "package.json", "package-lock.json", ".github/**"],
"_comment": "Using custom commands to demonstrate the feature. In production, ensure 'npm ci' runs before Felix.",
Expand All @@ -10,5 +10,10 @@
"prettier": {
"command": ["npm", "run", "format:fix"],
"appendPaths": false
},
"wc": {
"command": ["wc", "-l"],
"ignore": [".felixrc.json"],
"paths": ["."]
}
}
25 changes: 22 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30021,6 +30021,12 @@ class ConfigManager {
getIgnorePatterns() {
return this.config.ignore || ['node_modules/**', 'dist/**', 'build/**', '.git/**'];
}
getFixerIgnorePatterns(fixerName) {
const globalIgnores = this.getIgnorePatterns();
const fixerConfig = this.getFixerConfig(fixerName);
const localIgnores = Array.isArray(fixerConfig.ignore) ? fixerConfig.ignore : [];
return [...globalIgnores, ...localIgnores];
}
getFixerConfig(fixerName) {
return this.config[fixerName] || {};
}
Expand Down Expand Up @@ -30602,6 +30608,8 @@ To apply these fixes, remove the \`dry_run: true\` option from your workflow.`;
return this.config.getPaths();
}
filterFilesByFixer(files, fixerName, fixerConfig, configuredPaths) {
// Gather ignore patterns (global + fixer-level)
const ignorePatterns = this.config.getFixerIgnorePatterns(fixerName);
// Get the extensions this fixer handles
let extensions = [];
switch (fixerName) {
Expand Down Expand Up @@ -30644,16 +30652,27 @@ To apply these fixes, remove the \`dry_run: true\` option from your workflow.`;
extensions = fixerConfig.extensions || ['.md', '.markdown'];
break;
default:
return files;
extensions = fixerConfig.extensions || [];
break;
}
const isIgnored = (filePath) => {
return ignorePatterns.some(pattern => (0, minimatch_1.minimatch)(filePath, pattern));
};
if (this.inputs.debug) {
core.info(`🔍 Debug: Filtering ${files.length} files for ${fixerName}`);
core.info(`🔍 Debug: Extensions: ${extensions.join(', ')}`);
core.info(`🔍 Debug: Ignore patterns (${ignorePatterns.length}): ${ignorePatterns.join(', ')}`);
core.info(`🔍 Debug: Configured paths: ${configuredPaths.join(', ')}`);
}
const filteredFiles = files.filter(file => {
const ext = path.extname(file).toLowerCase();
if (!extensions.includes(ext)) {
if (isIgnored(file)) {
if (this.inputs.debug) {
core.info(`🔍 Debug: Excluded ${file}: matches ignore patterns`);
}
return false;
}
if (extensions.length > 0 && !extensions.includes(ext)) {
if (this.inputs.debug) {
core.info(`🔍 Debug: Excluded ${file}: extension ${ext} not in allowed extensions`);
}
Expand Down Expand Up @@ -31305,7 +31324,7 @@ class PrettierFixer extends base_1.BaseFixer {
if (!this.configManager) {
return paths;
}
const ignorePatterns = this.configManager.getIgnorePatterns();
const ignorePatterns = this.configManager.getFixerIgnorePatterns(this.name);
return paths.filter(path => {
const cleanPath = path.endsWith('/') ? path.slice(0, -1) : path;
// Check if this path matches any ignore pattern
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@
return this.config.ignore || ['node_modules/**', 'dist/**', 'build/**', '.git/**']
}

getFixerIgnorePatterns(fixerName: string): string[] {
const globalIgnores = this.getIgnorePatterns()
const fixerConfig = this.getFixerConfig(fixerName)
const localIgnores = Array.isArray(fixerConfig.ignore) ? fixerConfig.ignore : []
return [...globalIgnores, ...localIgnores]
}

getFixerConfig(fixerName: string): any {

Check warning on line 80 in src/config.ts

View workflow job for this annotation

GitHub Actions / dogfood

Unexpected any. Specify a different type
return this.config[fixerName as keyof FelixConfig] || {}
}

Expand Down
22 changes: 20 additions & 2 deletions src/felix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
}

// Skip if PR has skip label
if (pr?.labels?.some((label: any) => label.name === this.inputs.skipLabel)) {

Check warning on line 147 in src/felix.ts

View workflow job for this annotation

GitHub Actions / dogfood

Unexpected any. Specify a different type
core.info(`PR has skip label: ${this.inputs.skipLabel}`)
return true
}
Expand Down Expand Up @@ -538,7 +538,7 @@
})

const changedFiles = files
.map((f: any) => f.filename)

Check warning on line 541 in src/felix.ts

View workflow job for this annotation

GitHub Actions / dogfood

Unexpected any. Specify a different type
.filter((file: string) => {
// Skip deleted files
try {
Expand Down Expand Up @@ -604,9 +604,12 @@
private filterFilesByFixer(
files: string[],
fixerName: string,
fixerConfig: any,

Check warning on line 607 in src/felix.ts

View workflow job for this annotation

GitHub Actions / dogfood

Unexpected any. Specify a different type
configuredPaths: string[]
): string[] {
// Gather ignore patterns (global + fixer-level)
const ignorePatterns = this.config.getFixerIgnorePatterns(fixerName)

// Get the extensions this fixer handles
let extensions: string[] = []

Expand Down Expand Up @@ -650,19 +653,34 @@
extensions = fixerConfig.extensions || ['.md', '.markdown']
break
default:
return files
extensions = fixerConfig.extensions || []
break
}

const isIgnored = (filePath: string): boolean => {
return ignorePatterns.some(pattern => minimatch(filePath, pattern))
}

if (this.inputs.debug) {
core.info(`🔍 Debug: Filtering ${files.length} files for ${fixerName}`)
core.info(`🔍 Debug: Extensions: ${extensions.join(', ')}`)
core.info(
`🔍 Debug: Ignore patterns (${ignorePatterns.length}): ${ignorePatterns.join(', ')}`
)
core.info(`🔍 Debug: Configured paths: ${configuredPaths.join(', ')}`)
}

const filteredFiles = files.filter(file => {
const ext = path.extname(file).toLowerCase()

if (!extensions.includes(ext)) {
if (isIgnored(file)) {
if (this.inputs.debug) {
core.info(`🔍 Debug: Excluded ${file}: matches ignore patterns`)
}
return false
}

if (extensions.length > 0 && !extensions.includes(ext)) {
if (this.inputs.debug) {
core.info(`🔍 Debug: Excluded ${file}: extension ${ext} not in allowed extensions`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/fixers/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PrettierFixer extends BaseFixer {
return paths
}

const ignorePatterns = this.configManager.getIgnorePatterns()
const ignorePatterns = this.configManager.getFixerIgnorePatterns(this.name)
return paths.filter(path => {
const cleanPath = path.endsWith('/') ? path.slice(0, -1) : path

Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ export interface FelixConfig {
paths?: string[]
command?: string[]
appendPaths?: boolean
ignore?: string[]
}
prettier?: {
configFile?: string
extensions?: string[]
paths?: string[]
command?: string[]
appendPaths?: boolean
ignore?: string[]
}
markdownlint?: {
configFile?: string
paths?: string[]
command?: string[]
appendPaths?: boolean
ignore?: string[]
}
}

Expand Down
Loading