Add `file_name_declarations_location` option for `file_types_order`
Open
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Feature or Enhancement Proposal
Please add a file_name_declarations_location option for file_types_order that accepts values:
require_start: All declarations for a type whose names match the file name must be before all other declarations. These declarations must be relatively ordered in the same order as other declarations (e.g., for a file namedX+Y.swift), all declarations forXshould be before declarations for all other types; Iifstructis beforeextension, thenstruct Xmust be beforeextension X, beforestruct *, beforeextension *(where*is any type other thanX).consistent_start: Similar torequire_start, except that all declarations that match the file name may be before other declarations, or may be in their normal place; i.e. it's all or nothing.allow_start: Similar toconsistent_start, except that declarations that match the file name on an individual basis may be before other declarations, or may be in their normal place.default(default): File name declarations are treated the same as all other declarations.
Please also add:
- An
declarations_generic_over_file_name_locationoption forfile_types_orderthat applies similar rules to declarations generic over the file name, like[X],X?,Set<X>, etc. It accepts the same values asfile_name_declarations_location, plus:file_name_declarations_location: Applies the value fromfile_name_declarations_locationto declarations generic over the file name. Either this ordefaultwould be default; most likely the latter.
relative_generic_locationthat accepts values:by_type: e.g., struct X, then extension X, then struct Y, then extension Y, etc.by_declaration_kind: e.g., struct X, then struct Y, then extension X, then extension Y.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing file_types_order rule and its configuration and test coverage. Compare the requested file-name, generic, and relative ordering modes with the current behavior, then define how each option should be represented and validated. Done means the new options work for the listed declaration-order examples and are covered by tests and configuration documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100