Skip to content

feat: add ignoreFileExtensions option#228

Merged
rainerhahnekamp merged 7 commits intosoftarc-consulting:mainfrom
rainerhahnekamp:feat/ignore-file-extensions-config
Aug 18, 2025
Merged

feat: add ignoreFileExtensions option#228
rainerhahnekamp merged 7 commits intosoftarc-consulting:mainfrom
rainerhahnekamp:feat/ignore-file-extensions-config

Conversation

@rainerhahnekamp
Copy link
Collaborator

Adds the possbility to ignore files based on their extension and comes with a default of common files that should be ignored.

Fixes

@rainerhahnekamp rainerhahnekamp force-pushed the feat/ignore-file-extensions-config branch from b2820bf to ba40f6d Compare August 16, 2025 23:25
@rainerhahnekamp rainerhahnekamp force-pushed the feat/ignore-file-extensions-config branch from b8875b7 to b09be88 Compare August 18, 2025 09:34
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an ignoreFileExtensions configuration option to Sheriff, enabling users to specify which file extensions should be ignored during import traversal. This addresses performance issues caused by processing non-code files and provides flexibility for project-specific configurations.

  • Introduces the ignoreFileExtensions configuration option with sensible defaults for common non-code files
  • Updates the filesystem traversal logic to skip files with ignored extensions early in the process
  • Adds comprehensive test coverage and documentation for the new feature

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/core/src/lib/config/default-file-extensions.ts Defines default list of file extensions to ignore (images, styles, fonts, etc.)
packages/core/src/lib/config/user-sheriff-config.ts Adds the ignoreFileExtensions property to the user configuration interface
packages/core/src/lib/config/parse-config.ts Implements parsing logic for the new configuration option with function/array support
packages/core/src/lib/file-info/traverse-filesystem.ts Updates filesystem traversal to skip files with ignored extensions
packages/core/src/lib/file-info/generate-unassigned-file-info.ts Passes ignore extensions parameter through the traversal chain
test-projects/angular-iv/tests/ Adds integration tests to verify ignored extensions functionality
docs/ Adds comprehensive documentation and release notes for the new feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ignoreFileExtensions,
};
};

Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function getIgnoreFileExtensions lacks documentation. Consider adding a JSDoc comment explaining its purpose, parameters, and return value, especially since it handles both array and function inputs for the configuration option.

Suggested change
/**
* Returns a normalized array of file extensions to ignore.
*
* @param ignoreFileExtensions - Either an array of file extensions to ignore,
* or a function that receives the default ignore list and returns a new array.
* @returns A deduplicated, lowercased array of file extensions to ignore.
*/

Copilot uses AI. Check for mistakes.
// skip json imports
if (fileName.endsWith('.json')) {
// skip configured ignored extensions early
const fileExtension = fileName.split('.').pop()?.toLowerCase();
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file extension extraction logic using split('.').pop() could fail for files without extensions or complex filenames. Consider using a more robust approach like path.extname() from Node.js or add validation to handle edge cases like files starting with dots or multiple dots.

Suggested change
const fileExtension = fileName.split('.').pop()?.toLowerCase();
const fileExtension = path.extname(fileName).toLowerCase().replace(/^\./, '');

Copilot uses AI. Check for mistakes.
@rainerhahnekamp rainerhahnekamp merged commit cd468a1 into softarc-consulting:main Aug 18, 2025
4 checks passed
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