Skip to main content

newline-before-pubspec-entry

effort: 2m
configurable
has IDE fix
teams+

Enforces a blank line between the configured pubspec entries.

⚙️ Config

Set entries (default is [environment, dependencies, dev_dependencies, flutter]) to configure the list of pubspec entries.

To enforce a blank line for inner entries, use the dependencies:collection syntax.

analysis_options.yaml
dcm:
pubspec-rules:
- newline-before-pubspec-entry:
entries:
- environment
- dependencies
- dev_dependencies
- flutter
- dependencies:collection

Example

❌ Bad:

pubspec.yaml
name: some_package
description: ...
version: 1.0.0
environment: # LINT: Missing a blank line before this entry. Try adding it.
sdk: '>=3.6.0 <4.0.0'
flutter: '>=3.27.1'
dependencies: # LINT: Missing a blank line before this entry. Try adding it.
flutter:
sdk: flutter
collection: ^1.18.0 # LINT: Missing a blank line before this entry. Try adding it.
meta: ^1.12.0
ordered_set: ^8.0.0
vector_math: ^2.1.4
dev_dependencies: # LINT: Missing a blank line before this entry. Try adding it.
benchmark_harness: ^2.3.1

✅ Good:

pubspec.yaml
name: some_package
description: ...
version: 1.0.0

environment:
sdk: '>=3.6.0 <4.0.0'
flutter: '>=3.27.1'

dependencies:
flutter:
sdk: flutter

collection: ^1.18.0
meta: ^1.12.0
ordered_set: ^8.0.0
vector_math: ^2.1.4

dev_dependencies:
benchmark_harness: ^2.3.1