Skip to content

Comments

refactor(cli): move file element validation from mappers to linter#9474

Open
hooni0918 wants to merge 1 commit intotuist:mainfrom
hooni0918:refactor/move-file-element-validation-to-linter
Open

refactor(cli): move file element validation from mappers to linter#9474
hooni0918 wants to merge 1 commit intotuist:mainfrom
hooni0918:refactor/move-file-element-validation-to-linter

Conversation

@hooni0918
Copy link

Why

Several manifest mappers (FileElement, ResourceFileElement, CopyFileElement, Workspace) contained file validation logic with FIXME comments stating "This should be done in a linter." The validation was happening during model conversion, logging warnings directly via Logger.current.warning() instead of going through the proper linting system.

This made the validation:

  • Inconsistent with other validations that use LintingIssue
  • Harder to test in isolation
  • Mixed concerns between mapping (conversion) and validation (linting)

What

ManifestLinter changes:

  • Convert ManifestLinting protocol to async to support file system operations
  • Add FileSysteming and RootDirectoryLocating dependencies
  • Implement file element validation methods:
    • lintFileElement() - validates glob patterns and folder references
    • lintResourceFileElement() - validates resource file elements
    • lintCopyFileElement() - validates copy file elements
    • lintGlobPattern() - checks if glob matches any files, warns about directories used as globs
    • lintFolderReference() - checks folder existence and type
    • lintWorkspaceProjects() - validates workspace project paths exist

Mapper changes:

  • Remove TuistLogging imports from FileElement, ResourceFileElement, CopyFileElement, and Workspace mappers
  • Remove Logger.current.warning() calls and FIXME comments
  • Mappers now silently return empty arrays for missing files (linter handles warnings)

ManifestGraphLoader changes:

  • Update to call async linter methods with path parameter

Test plan

  • Add new tests for file element validation in ManifestLinterTests:
    • test_lint_project_fileElementNotFound
    • test_lint_project_folderReferenceNotFound
    • test_lint_project_folderReferenceIsNotDirectory
    • test_lint_project_directoryUsedAsGlob
    • test_lint_project_validFileElement
    • test_lint_project_validFolderReference
  • Convert existing tests to async
  • Run tuist generate on a project with missing file paths and verify warnings appear

Move file/folder validation logic from manifest mappers to ManifestLinter
where it belongs. This removes FIXME comments that indicated the validation
should be done in a linter rather than during mapping.

Changes:
- Make ManifestLinter async with FileSysteming dependency
- Add file element validation methods for glob patterns and folder references
- Add workspace project path validation
- Remove Logger warnings from FileElement, ResourceFileElement,
  CopyFileElement, and Workspace mappers
- Update ManifestGraphLoader to use async linter
- Add tests for new file element linting functionality
@dosubot dosubot bot added the size:L For issues that take up to a day to implement label Feb 14, 2026
@dosubot
Copy link

dosubot bot commented Feb 14, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added domain:cli Issues related to the CLI that don't fall into a particular feature category. type:enhancement New feature or request labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain:cli Issues related to the CLI that don't fall into a particular feature category. size:L For issues that take up to a day to implement type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant