dependencies-ordering
Suggests sorting pubspec dependencies in alphabetical order (A to Z).
Works for dependencies
, dev_dependencies
and dependency_overrides
pubspec section.
⚙️ Config
Set flutter
(default is unset
, can be set to first
, last
or unset
) to configure the position of dependencies from the Flutter SDK (example).
analysis_options.yaml
dcm:
pubspec-rules:
- dependencies-ordering:
flutter: unset
Example
❌ Bad:
pubspec.yaml
name: some_package
description: ...
version: 1.0.0
dependencies:
xml: '>=5.3.0 <7.0.0'
yaml: 3.1.0+1
test: 1.22.2 # LINT: Dependencies are not sorted alphabetically. Try sorting them from A to Z.
✅ Good:
pubspec.yaml
name: some_package
description: ...
version: 1.0.0
dependencies:
test: 1.22.2
xml: '>=5.3.0 <7.0.0'
yaml: 3.1.0+1
Example with "flutter"
Config
analysis_options.yaml
dcm:
pubspec-rules:
- dependencies-ordering:
flutter: first
❌ Bad:
pubspec.yaml
name: some_package
description: ...
version: 1.0.0
dependencies:
collection: ^1.18.0
xml: '>=5.3.0 <7.0.0'
yaml: 3.1.0+1
flutter: # LINT: Flutter SDK dependencies are expected to be first. Try sorting them.
sdk: flutter
✅ Good:
pubspec.yaml
name: some_package
description: ...
version: 1.0.0
dependencies:
flutter:
sdk: flutter
collection: ^1.18.0
xml: '>=5.3.0 <7.0.0'
yaml: 3.1.0+1