Skip to content

feat: add configurable file extension support via supportedFileExtensions#254

Open
rainerhahnekamp wants to merge 2 commits into
softarc-consulting:mainfrom
rainerhahnekamp:feat/eslint-config-tsx
Open

feat: add configurable file extension support via supportedFileExtensions#254
rainerhahnekamp wants to merge 2 commits into
softarc-consulting:mainfrom
rainerhahnekamp:feat/eslint-config-tsx

Conversation

@rainerhahnekamp

Copy link
Copy Markdown
Collaborator

Summary

  • Introduces supportedFileExtensions in sheriff.config.ts (array or function), defaulting to ts, tsx, mts, cts, giving users control over which file extensions Sheriff traverses when resolving imports
  • ESLint plugin file globs (all, legacy) are now driven by defaultSupportedFileExtensions instead of hardcoded strings
  • Path resolution in get-ts-config-context iterates over supportedFileExtensions instead of hardcoding .ts
  • Emits a [SHERIFF CONFIG MISMATCH] warning when ESLint lints a file whose extension is absent from supportedFileExtensions
  • Fixes init order: config is loaded before generating TS data so extensions are available during path resolution
  • Adds Next.js integration test project covering encapsulation rules on .tsx files
  • Updates docs with supportedFileExtensions reference and guidance on scoping ESLint files patterns to source directories

Test plan

  • All unit tests pass (yarn test)
  • Next.js integration test runs via run-integration-tests.sh
  • Setting supportedFileExtensions: (defaults) => [...defaults, 'js'] in sheriff.config.ts resolves .js path mappings correctly
  • A .tsx file linted by ESLint with tsx in supportedFileExtensions produces no mismatch warning
  • A file with an extension absent from supportedFileExtensions produces the [SHERIFF CONFIG MISMATCH] error

🤖 Generated with Claude Code

rainerhahnekamp and others added 2 commits May 30, 2026 13:48
…ions

Introduces the `supportedFileExtensions` option in `sheriff.config.ts`,
allowing users to define which file extensions Sheriff traverses when
resolving imports. Defaults to `ts`, `tsx`, `mts`, and `cts`.

- ESLint plugin file globs (`all`, `legacy`) are now driven by
  `defaultSupportedFileExtensions` instead of hardcoded strings
- Path resolution in `get-ts-config-context` iterates over supported
  extensions instead of hardcoding `.ts`
- A `[SHERIFF CONFIG MISMATCH]` warning is emitted when ESLint lints a
  file whose extension is absent from `supportedFileExtensions`
- Init order fixed: config is loaded before generating TS data so
  extensions are available during path resolution
- Adds Next.js integration test project covering encapsulation rules on
  `.tsx` files
- Updates docs with `supportedFileExtensions` reference and guidance on
  scoping ESLint `files` patterns to source directories

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Store config separately from fileInfo in violates-dependency-rule and
  violates-encapsulation-rule (FileInfo has no config property)
- Default supportedFileExtensions to defaultSupportedFileExtensions
  instead of [] in getTsConfigContext and generateTsData so callers
  without explicit extensions still resolve .ts paths correctly
- Update parse-config tests to include supportedFileExtensions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant