Repository navigation
fix(lines-around-comment): allow comments at the start of namespace blocks - #31
Merged
Merged
Conversation
…locks The rule required a blank line before a comment at the start of a `namespace`/`module` block, which `prettier/prettier` removes, so both rules could not pass at once. Enable the base rule's `allowModuleStart` option in the recommended config. Closes #28
|
|
d3lm
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28.
@blitz/lines-around-commentrequires a blank line before a comment at the start of anamespace/moduleblock, andprettier/prettierdeletes that blank line, so code like this can't pass both rules:The
@blitzrule only handles comments at the start/end of enums, switches, arrays, objects, and type literals itself (START_END_NODES). Comments in aTSModuleBlockfall through to the wrapped@stylistic/ts/lines-around-commentrule, which already supportsallowModuleStart. The recommended config never enabled it, so this PR setsallowModuleStart: truenext to the otherallow*Startoptions. TypeScript files get the same options throughtsRules(). Comments elsewhere in a namespace still need a blank line before them.Alternatives considered:
TSModuleBlocktoSTART_END_NODES. The rule'sisStartAllowed/isEndAllowedchecks are an OR across everyallow*Start/allow*Endoption, so unrelated options such asallowArrayStartwould also exempt namespaces.allowModuleEnd. It has no effect, because the config doesn't enableafterBlockComment/afterLineComment.Tests
allowModuleStartcoverdeclare namespace,namespace,declare module 'foo', and the fixer output when the option is off.jsRules. One checks that the issue's snippet is valid, and one checks that a comment in the middle of a namespace still errors. Reverting the config line makes the first one fail.recommended()config, includingprettier/prettier. The snippet without a blank line is now clean for both rules. Comments at the start ofnamespace A.Banddeclare module 'foo'blocks are clean too.Checklist
allowModuleStartis a base rule option, already covered by the linked@stylistic/tsdocs)