From 0c1df568075c237eb3df9e7a96b632a9e0521ac6 Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Fri, 24 Jan 2025 12:19:26 +0100 Subject: [PATCH] chore: Fix linting (#849) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Fixes linting according to latest linting rules. ## Type of Change - [ ] โœจ `feat` -- New feature (non-breaking change which adds functionality) - [ ] ๐Ÿ› ๏ธ `fix` -- Bug fix (non-breaking change which fixes an issue) - [ ] โŒ `!` -- Breaking change (fix or feature that would cause existing functionality to change) - [ ] ๐Ÿงน `refactor` -- Code refactor - [ ] โœ… `ci` -- Build configuration change - [ ] ๐Ÿ“ `docs` -- Documentation - [x] ๐Ÿ—‘๏ธ `chore` -- Chore --- packages/melos/lib/src/command_runner.dart | 8 +- .../melos/lib/src/command_runner/list.dart | 20 ++- .../melos/lib/src/commands/bootstrap.dart | 20 ++- packages/melos/lib/src/commands/publish.dart | 8 +- packages/melos/lib/src/commands/run.dart | 8 +- packages/melos/lib/src/commands/version.dart | 8 +- packages/melos/lib/src/common/changelog.dart | 12 +- packages/melos/lib/src/common/git.dart | 18 ++- .../melos/lib/src/common/git_repository.dart | 6 +- packages/melos/lib/src/common/glob.dart | 2 +- .../lib/src/common/intellij_project.dart | 8 +- packages/melos/lib/src/common/io.dart | 8 +- .../src/common/pending_package_update.dart | 4 +- .../melos/lib/src/common/pub_credential.dart | 4 +- packages/melos/lib/src/common/utils.dart | 22 +++- packages/melos/lib/src/common/validation.dart | 28 ++-- packages/melos/lib/src/package.dart | 124 +++++++++++++----- packages/melos/lib/src/workspace_config.dart | 4 +- packages/melos/pubspec.yaml | 1 + packages/melos/test/utils.dart | 2 +- 20 files changed, 225 insertions(+), 90 deletions(-) diff --git a/packages/melos/lib/src/command_runner.dart b/packages/melos/lib/src/command_runner.dart index 25c319cfa..722fa855f 100644 --- a/packages/melos/lib/src/command_runner.dart +++ b/packages/melos/lib/src/command_runner.dart @@ -90,7 +90,9 @@ FutureOr melosEntryPoint( logger.log(melosVersion); // No version checks on CIs. - if (utils.isCI) return; + if (utils.isCI) { + return; + } // Check for updates. final pubUpdater = PubUpdater(); @@ -155,7 +157,9 @@ Future _resolveConfig( } bool _shouldUseEmptyConfig(List arguments) { - if (arguments.firstOrNull == 'init') return true; + if (arguments.firstOrNull == 'init') { + return true; + } final willShowHelp = arguments.isEmpty || arguments.contains('--help') || arguments.contains('-h'); diff --git a/packages/melos/lib/src/command_runner/list.dart b/packages/melos/lib/src/command_runner/list.dart index b3a7c5392..532161388 100644 --- a/packages/melos/lib/src/command_runner/list.dart +++ b/packages/melos/lib/src/command_runner/list.dart @@ -74,11 +74,21 @@ class ListCommand extends MelosCommand { var kind = ListOutputKind.column; - if (parsable) kind = ListOutputKind.parsable; - if (json) kind = ListOutputKind.json; - if (graph) kind = ListOutputKind.graph; - if (gviz) kind = ListOutputKind.gviz; - if (cycles) kind = ListOutputKind.cycles; + if (parsable) { + kind = ListOutputKind.parsable; + } + if (json) { + kind = ListOutputKind.json; + } + if (graph) { + kind = ListOutputKind.graph; + } + if (gviz) { + kind = ListOutputKind.gviz; + } + if (cycles) { + kind = ListOutputKind.cycles; + } return melos.list( long: long, diff --git a/packages/melos/lib/src/commands/bootstrap.dart b/packages/melos/lib/src/commands/bootstrap.dart index c0b1936a7..4ae4263c8 100644 --- a/packages/melos/lib/src/commands/bootstrap.dart +++ b/packages/melos/lib/src/commands/bootstrap.dart @@ -261,8 +261,12 @@ mixin _BootstrapMixin on _CleanMixin { } for (final entry in workspaceEnvironment.entries) { - if (!packageEnvironment.containsKey(entry.key)) continue; - if (packageEnvironment[entry.key] == entry.value) continue; + if (!packageEnvironment.containsKey(entry.key)) { + continue; + } + if (packageEnvironment[entry.key] == entry.value) { + continue; + } pubspecEditor.update( ['environment', entry.key], @@ -291,11 +295,15 @@ mixin _BootstrapMixin on _CleanMixin { required Map packageDependencies, required String pubspecKey, }) { - if (workspaceDependencies == null) return 0; + if (workspaceDependencies == null) { + return 0; + } // Filter out the packages that do not exist in package and only the // dependencies that have a different version specified in the workspace. final dependenciesToUpdate = workspaceDependencies.entries.where((entry) { - if (!packageDependencies.containsKey(entry.key)) return false; + if (!packageDependencies.containsKey(entry.key)) { + return false; + } // TODO: We may want to replace the `pubspec` dependency with something // else that is actively maintained, so we don't have to provide our own // equality logic. @@ -353,7 +361,9 @@ mixin _BootstrapMixin on _CleanMixin { .map((line) { var lineWithWorkspacePackagesHighlighted = line; for (final workspacePackage in workspace.allPackages.values) { - if (workspacePackage.name == package.name) continue; + if (workspacePackage.name == package.name) { + continue; + } lineWithWorkspacePackagesHighlighted = lineWithWorkspacePackagesHighlighted.replaceAll( '${workspacePackage.name} ', diff --git a/packages/melos/lib/src/commands/publish.dart b/packages/melos/lib/src/commands/publish.dart index 1adc02856..41f33fc76 100644 --- a/packages/melos/lib/src/commands/publish.dart +++ b/packages/melos/lib/src/commands/publish.dart @@ -106,7 +106,9 @@ mixin _PublishMixin on _ExecMixin { if (!force) { final shouldContinue = promptBool(); - if (!shouldContinue) throw CancelledException(); + if (!shouldContinue) { + throw CancelledException(); + } logger.newLine(); } @@ -126,7 +128,9 @@ mixin _PublishMixin on _ExecMixin { await pool.forEach(workspace.filteredPackages.values, (package) async { - if (package.isPrivate) return; + if (package.isPrivate) { + return; + } final pubPackage = await package.getPublishedPackage(); final versions = pubPackage?.prioritizedVersions.reversed diff --git a/packages/melos/lib/src/commands/run.dart b/packages/melos/lib/src/commands/run.dart index 422203216..3ac2cfde0 100644 --- a/packages/melos/lib/src/commands/run.dart +++ b/packages/melos/lib/src/commands/run.dart @@ -8,7 +8,9 @@ mixin _RunMixin on _Melos { bool noSelect = false, List extraArgs = const [], }) async { - if (config.scripts.keys.isEmpty) throw NoScriptException._(); + if (config.scripts.keys.isEmpty) { + throw NoScriptException._(); + } scriptName ??= await _pickScript(config); final script = config.scripts[scriptName]; @@ -217,10 +219,10 @@ mixin _RunMixin on _Melos { Future _runMultipleScripts( Script script, { - GlobalOptions? global, - bool noSelect = false, required Scripts scripts, required List steps, + GlobalOptions? global, + bool noSelect = false, }) async { final workspace = await createWorkspace( global: global, diff --git a/packages/melos/lib/src/commands/version.dart b/packages/melos/lib/src/commands/version.dart index 203ec6154..0bdbbfc56 100644 --- a/packages/melos/lib/src/commands/version.dart +++ b/packages/melos/lib/src/commands/version.dart @@ -157,7 +157,9 @@ mixin _VersionMixin on _RunMixin { if (asStableRelease) { for (final package in workspace.filteredPackages.values) { - if (!package.version.isPreRelease) continue; + if (!package.version.isPreRelease) { + continue; + } pendingPackageUpdates.add( MelosPendingPackageUpdate( @@ -742,7 +744,9 @@ mixin _VersionMixin on _RunMixin { final packageCommits = >{}; await Pool(10).forEach(workspace.filteredPackages.values, (package) async { - if (!versionPrivatePackages && package.isPrivate) return; + if (!versionPrivatePackages && package.isPrivate) { + return; + } final commits = await gitCommitsForPackage( package, diff --git a/packages/melos/lib/src/common/changelog.dart b/packages/melos/lib/src/common/changelog.dart index 784021d5f..e585d49cd 100644 --- a/packages/melos/lib/src/common/changelog.dart +++ b/packages/melos/lib/src/common/changelog.dart @@ -193,8 +193,12 @@ extension ChangelogStringBufferExtension on StringBuffer { final version = update.workspace.config.commands.version; - if (!version.includeCommitBody) continue; - if (parsedMessage.body == null) continue; + if (!version.includeCommitBody) { + continue; + } + if (parsedMessage.body == null) { + continue; + } final shouldWriteBody = !version.commitBodyOnlyBreaking || parsedMessage.isBreakingChange; @@ -225,7 +229,9 @@ List _filteredAndSortedCommits( final r = a.parsedMessage.isBreakingChange .toString() .compareTo(b.parsedMessage.isBreakingChange.toString()); - if (r != 0) return r; + if (r != 0) { + return r; + } return b.parsedMessage.type!.compareTo(a.parsedMessage.type!); }); diff --git a/packages/melos/lib/src/common/git.dart b/packages/melos/lib/src/common/git.dart index 804ee28e5..76cd975e2 100644 --- a/packages/melos/lib/src/common/git.dart +++ b/packages/melos/lib/src/common/git.dart @@ -82,9 +82,9 @@ Future gitExecuteCommand({ /// Optionally specify [tagReleaseType] to specify [TagReleaseType]. Future> gitTagsForPackage( Package package, { + required MelosLogger logger, TagReleaseType tagReleaseType = TagReleaseType.all, String preid = 'dev', - required MelosLogger logger, }) async { final filterPattern = gitTagFilterPattern(package.name, tagReleaseType, preid: preid); @@ -130,8 +130,8 @@ Future gitTagCreate( String tag, String message, { required String workingDirectory, - String? commitId, required MelosLogger logger, + String? commitId, }) async { if (await gitTagExists( tag, @@ -171,11 +171,13 @@ Future gitTagCreate( /// are requested. Future gitLatestTagForPackage( Package package, { - String preid = 'dev', required MelosLogger logger, + String preid = 'dev', }) async { // Package doesn't have a version, skip. - if (package.version.toString() == '0.0.0') return null; + if (package.version.toString() == '0.0.0') { + return null; + } final currentVersionTag = gitTagForPackageVersion(package.name, package.version.toString()); @@ -202,7 +204,9 @@ Future gitLatestTagForPackage( preid: preid, logger: logger, ); - if (tags.isEmpty) return null; + if (tags.isEmpty) { + return null; + } return tags.first; } @@ -256,8 +260,8 @@ final _gitVersionRangeShortHandRegExp = RegExp(r'^.+\.{2,3}.+$'); /// Diff also supports specifying a range of commits, e.g. `HEAD~5..HEAD`. Future> gitCommitsForPackage( Package package, { - String? diff, required MelosLogger logger, + String? diff, }) async { final revisionRange = await _resolveRevisionRange(package, diff: diff, logger: logger); @@ -355,9 +359,9 @@ Future gitRemoteUpdate({ /// branch. Future gitIsBehindUpstream({ required String workingDirectory, + required MelosLogger logger, String remote = 'origin', String? branch, - required MelosLogger logger, }) async { await gitRemoteUpdate(workingDirectory: workingDirectory, logger: logger); diff --git a/packages/melos/lib/src/common/git_repository.dart b/packages/melos/lib/src/common/git_repository.dart index 0550385be..eebdd0723 100644 --- a/packages/melos/lib/src/common/git_repository.dart +++ b/packages/melos/lib/src/common/git_repository.dart @@ -55,9 +55,9 @@ mixin SupportsManualRelease on HostedGitRepository { @immutable class GitHubRepository extends HostedGitRepository with SupportsManualRelease { GitHubRepository({ - String origin = defaultOrigin, required this.owner, required this.name, + String origin = defaultOrigin, }) : origin = removeTrailingSlash(origin); factory GitHubRepository.fromUrl(Uri uri) { @@ -138,9 +138,9 @@ GitHubRepository( @immutable class GitLabRepository extends HostedGitRepository { GitLabRepository({ - String origin = defaultOrigin, required this.owner, required this.name, + String origin = defaultOrigin, }) : origin = removeTrailingSlash(origin); factory GitLabRepository.fromUrl(Uri uri) { @@ -202,9 +202,9 @@ GitLabRepository( class BitbucketRepository extends HostedGitRepository { BitbucketRepository({ - String origin = defaultOrigin, required this.owner, required this.name, + String origin = defaultOrigin, }) : origin = removeTrailingSlash(origin); factory BitbucketRepository.fromUrl(Uri uri) { diff --git a/packages/melos/lib/src/common/glob.dart b/packages/melos/lib/src/common/glob.dart index 6d17cdea0..06aeba84c 100644 --- a/packages/melos/lib/src/common/glob.dart +++ b/packages/melos/lib/src/common/glob.dart @@ -7,10 +7,10 @@ import 'package:path/path.dart' as p; /// Workaround for https://github.com/dart-lang/glob/issues/52 Glob createGlob( String pattern, { + required String currentDirectoryPath, p.Context? context, bool recursive = false, bool? caseSensitive, - required String currentDirectoryPath, }) { context ??= p.Context( style: p.context.style, diff --git a/packages/melos/lib/src/common/intellij_project.dart b/packages/melos/lib/src/common/intellij_project.dart index a0bc6f199..dd252a20a 100644 --- a/packages/melos/lib/src/common/intellij_project.dart +++ b/packages/melos/lib/src/common/intellij_project.dart @@ -114,7 +114,9 @@ class IntellijProject { String fileName, { String? templateCategory, }) async { - if (_cacheTemplates[fileName] != null) return _cacheTemplates[fileName]!; + if (_cacheTemplates[fileName] != null) { + return _cacheTemplates[fileName]!; + } String templatesRootPath; if (templateCategory != null) { @@ -282,7 +284,9 @@ class IntellijProject { ); await Future.forEach(_workspace.filteredPackages.values, (package) async { - if (!package.isFlutterApp) return; + if (!package.isFlutterApp) { + return; + } final generatedRunConfiguration = injectTemplateVariables( flutterTestTemplate, diff --git a/packages/melos/lib/src/common/io.dart b/packages/melos/lib/src/common/io.dart index 08bc5d7b6..e9f074154 100644 --- a/packages/melos/lib/src/common/io.dart +++ b/packages/melos/lib/src/common/io.dart @@ -101,7 +101,9 @@ void copyFile(String from, String to, {bool recursive = false}) { /// The [File] class overwrites the symlink targets when writing to a file, /// which is never what we want, so this delete the symlink first if necessary. void deleteIfLink(String file) { - if (!linkExists(file)) return; + if (!linkExists(file)) { + return; + } Link(file).deleteSync(); } @@ -180,7 +182,9 @@ void _attempt( break; } on FileSystemException catch (error) { final reason = getErrorReason(error); - if (reason == null) rethrow; + if (reason == null) { + rethrow; + } if (i < maxRetries - 1) { sleep(const Duration(milliseconds: 50)); diff --git a/packages/melos/lib/src/common/pending_package_update.dart b/packages/melos/lib/src/common/pending_package_update.dart index f3136bc88..5264744f4 100644 --- a/packages/melos/lib/src/common/pending_package_update.dart +++ b/packages/melos/lib/src/common/pending_package_update.dart @@ -34,10 +34,10 @@ class MelosPendingPackageUpdate { this.package, this.commits, this.reason, { + required this.logger, this.prerelease = false, this.graduate = false, this.preid, - required this.logger, }) : manualVersion = null, userChangelogMessage = null; @@ -46,8 +46,8 @@ class MelosPendingPackageUpdate { this.package, this.commits, this.manualVersion, { - this.userChangelogMessage, required this.logger, + this.userChangelogMessage, }) : reason = PackageUpdateReason.manual, prerelease = false, graduate = false, diff --git a/packages/melos/lib/src/common/pub_credential.dart b/packages/melos/lib/src/common/pub_credential.dart index 8da310a8f..cf0946386 100644 --- a/packages/melos/lib/src/common/pub_credential.dart +++ b/packages/melos/lib/src/common/pub_credential.dart @@ -102,7 +102,9 @@ class PubCredential { } String? getAuthHeader() { - if (!isValid()) return null; + if (!isValid()) { + return null; + } return 'Bearer $_tokenValue'; } } diff --git a/packages/melos/lib/src/common/utils.dart b/packages/melos/lib/src/common/utils.dart index 3beac3136..23e5b188f 100644 --- a/packages/melos/lib/src/common/utils.dart +++ b/packages/melos/lib/src/common/utils.dart @@ -49,7 +49,9 @@ const publishOptionForce = 'force'; extension Let on T? { R? let(R Function(T value) cb) { - if (this == null) return null; + if (this == null) { + return null; + } return cb(this as T); } @@ -104,12 +106,16 @@ extension StringUtils on String { } String get capitalized { - if (isEmpty) return this; + if (isEmpty) { + return this; + } return '${this[0].toUpperCase()}${substring(1)}'; } String get camelCased { - if (isEmpty) return this; + if (isEmpty) { + return this; + } var isFirstWord = true; return splitMapJoin( _camelCasedDelimiterRegExp, @@ -336,10 +342,14 @@ String listAsPaddedTable(List> table, {int paddingSize = 1}) { final colWidth = maxColumnSizes[i]! + paddingSize; final cellWidth = AnsiStyles.strip(column).length; var padding = colWidth - cellWidth; - if (padding < paddingSize) padding = paddingSize; + if (padding < paddingSize) { + padding = paddingSize; + } // last cell of the list, no need for padding - if (i + 1 >= row.length) padding = 0; + if (i + 1 >= row.length) { + padding = 0; + } rowBuffer.write('$column${List.filled(padding, ' ').join()}'); i++; @@ -440,12 +450,12 @@ List get runningPids => UnmodifiableListView(_runningPids); Future startCommand( List command, { + required MelosLogger logger, String? logPrefix, Map environment = const {}, String? workingDirectory, bool onlyOutputOnError = false, bool includeParentEnvironment = true, - required MelosLogger logger, String? group, }) async { final processedCommand = command diff --git a/packages/melos/lib/src/common/validation.dart b/packages/melos/lib/src/common/validation.dart index 11a6fda84..4c3ea87bc 100644 --- a/packages/melos/lib/src/common/validation.dart +++ b/packages/melos/lib/src/common/validation.dart @@ -4,12 +4,14 @@ library validation; import 'exception.dart'; T assertIsA({ + required Object? value, int? index, Object? key, String? path, - required Object? value, }) { - if (value is T) return value; + if (value is T) { + return value; + } throw MelosConfigException.invalidType( index: index, @@ -21,9 +23,9 @@ T assertIsA({ } T assertKeyIsA({ - String? path, required Object key, required Map map, + String? path, }) { if (null is! T && !map.containsKey(key)) { throw MelosConfigException.missingKey(key: key, path: path); @@ -33,15 +35,17 @@ T assertKeyIsA({ } List assertListOrString({ - String? path, required Object key, required Map map, + String? path, bool isRequired = false, }) { final value = map[key]; if (value == null) { - if (isRequired) throw MelosConfigException.missingKey(key: key, path: path); + if (isRequired) { + throw MelosConfigException.missingKey(key: key, path: path); + } return []; } @@ -65,11 +69,11 @@ List assertListOrString({ } List assertListIsA({ - String? path, required Object key, required Map map, required bool isRequired, required T Function(int index, Object? value) assertItemIsA, + String? path, }) { final collection = assertKeyIsA?>(key: key, map: map); @@ -90,12 +94,12 @@ List assertListIsA({ } Map assertMapIsA({ - String? path, required Object key, required Map map, required bool isRequired, required T Function(Object? value) assertKey, required V Function(Object? key, Object? value) assertValue, + String? path, }) { final collection = assertKeyIsA?>(key: key, map: map); @@ -125,9 +129,9 @@ class MelosConfigException implements MelosException { MelosConfigException.invalidType({ required Object expectedType, + required Object? value, Object? key, int? index, - required Object? value, String? path, }) : this( '${_descriptor(key: key, index: index, path: path)} ' @@ -136,11 +140,15 @@ class MelosConfigException implements MelosException { static String _descriptor({Object? key, String? path, int? index}) { if (key != null) { - if (path == null) return 'The property $key'; + if (path == null) { + return 'The property $key'; + } return 'The property $key at $path'; } if (index != null) { - if (path == null) return 'The index $index'; + if (path == null) { + return 'The index $index'; + } return 'The index $index at $path'; } diff --git a/packages/melos/lib/src/package.dart b/packages/melos/lib/src/package.dart index cd46de9ef..784e14e9a 100644 --- a/packages/melos/lib/src/package.dart +++ b/packages/melos/lib/src/package.dart @@ -639,7 +639,9 @@ The packages that caused the problem are: /// /// This is the default packages behaviour when a workspace is loaded. Future applyFilters(PackageFilters? filters) async { - if (filters == null) return this; + if (filters == null) { + return this; + } var packageList = await values .applyIgnore(filters.ignore) @@ -674,7 +676,9 @@ The packages that caused the problem are: extension IterablePackageExt on Iterable { Iterable applyIgnore(List ignore) { - if (ignore.isEmpty) return this; + if (ignore.isEmpty) { + return this; + } return where((package) { return ignore.every((glob) => !glob.matches(package.name)); @@ -682,7 +686,9 @@ extension IterablePackageExt on Iterable { } Iterable applyDirExists(List directoryPaths) { - if (directoryPaths.isEmpty) return this; + if (directoryPaths.isEmpty) { + return this; + } // Directory exists packages filter, multiple filters behaviour is 'AND'. return where((package) { @@ -694,7 +700,9 @@ extension IterablePackageExt on Iterable { } Iterable applyFileExists(List filePaths) { - if (filePaths.isEmpty) return this; + if (filePaths.isEmpty) { + return this; + } return where((package) { final fileExistsMatched = filePaths.any((fileExistsPath) { @@ -718,7 +726,9 @@ extension IterablePackageExt on Iterable { /// If `include` is true, only include private packages. If false, only /// include public packages. If null, does nothing. Iterable filterPrivatePackages({bool? include}) { - if (include == null) return this; + if (include == null) { + return this; + } return where((package) => include == package.isPrivate); } @@ -731,7 +741,9 @@ extension IterablePackageExt on Iterable { Future> filterPublishedPackages({ required bool? published, }) async { - if (published == null) return this; + if (published == null) { + return this; + } final pool = Pool(10); final packagesFilteredWithPublishStatus = []; @@ -753,7 +765,9 @@ extension IterablePackageExt on Iterable { String? diff, MelosLogger logger, ) async { - if (diff == null) return this; + if (diff == null) { + return this; + } return Pool(10) .forEach(this, (package) async { @@ -771,7 +785,9 @@ extension IterablePackageExt on Iterable { /// If `include` is true, only null-safe packages. If false, only include /// packages that are not null-safe. If null, does nothing. Iterable filterNullSafe({required bool? nullSafe}) { - if (nullSafe == null) return this; + if (nullSafe == null) { + return this; + } return where((package) { final version = package.version; @@ -784,7 +800,9 @@ extension IterablePackageExt on Iterable { } Iterable applyScope(List scope) { - if (scope.isEmpty) return this; + if (scope.isEmpty) { + return this; + } return where((package) { return scope.any( @@ -794,7 +812,9 @@ extension IterablePackageExt on Iterable { } Iterable applyCategories(List appliedCategories) { - if (appliedCategories.isEmpty) return this; + if (appliedCategories.isEmpty) { + return this; + } return where((package) { return package.categories.any( @@ -806,7 +826,9 @@ extension IterablePackageExt on Iterable { } Iterable applyDependsOn(List dependsOn) { - if (dependsOn.isEmpty) return this; + if (dependsOn.isEmpty) { + return this; + } return where((package) { return dependsOn.every((element) { @@ -817,7 +839,9 @@ extension IterablePackageExt on Iterable { } Iterable applyNoDependsOn(List noDependsOn) { - if (noDependsOn.isEmpty) return this; + if (noDependsOn.isEmpty) { + return this; + } return where((package) { return noDependsOn.every((element) { @@ -834,7 +858,9 @@ extension IterablePackageExt on Iterable { // We apply both dependents and includeDependencies at the same time, as if // both flags are enabled, this could otherwise include the dependencies // of the dependents โ€“ which is undesired. - if (!includeDependents && !includeDependencies) return this; + if (!includeDependents && !includeDependencies) { + return this; + } return { for (final package in this) ...[ @@ -952,9 +978,15 @@ class Package { /// Type of this package, e.g. [PackageType.flutterApp]. PackageType get type { - if (isFlutterApp) return PackageType.flutterApp; - if (isFlutterPlugin) return PackageType.flutterPlugin; - if (isFlutterPackage) return PackageType.flutterPackage; + if (isFlutterApp) { + return PackageType.flutterApp; + } + if (isFlutterPlugin) { + return PackageType.flutterPlugin; + } + if (isFlutterPackage) { + return PackageType.flutterPackage; + } return PackageType.dartPackage; } @@ -966,7 +998,9 @@ class Package { /// Returns whether this package is private (publish_to set to 'none'). bool get isPrivate { // Unversioned package, assuming private, e.g. example apps. - if (pubspec.version == null) return true; + if (pubspec.version == null) { + return true; + } return publishTo.toString() == 'none'; } @@ -995,47 +1029,63 @@ class Package { /// - c) a lib/main.dart file exists in the package. bool get isFlutterApp { // Must directly depend on the Flutter SDK. - if (!isFlutterPackage) return false; + if (!isFlutterPackage) { + return false; + } // Must not have a Flutter plugin definition in its pubspec.yaml. - if (pubspec.flutterPlugin != null) return false; + if (pubspec.flutterPlugin != null) { + return false; + } return fileExists(p.join(path, 'lib', 'main.dart')); } /// Returns whether this package supports Flutter for Android. bool get flutterAppSupportsAndroid { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kAndroid); } /// Returns whether this package supports Flutter for Web. bool get flutterAppSupportsWeb { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kWeb); } /// Returns whether this package supports Flutter for Windows. bool get flutterAppSupportsWindows { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kWindows); } /// Returns whether this package supports Flutter for MacOS. bool get flutterAppSupportsMacos { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kMacos); } /// Returns whether this package supports Flutter for iOS. bool get flutterAppSupportsIos { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kIos); } /// Returns whether this package supports Flutter for Linux. bool get flutterAppSupportsLinux { - if (!isFlutterApp) return false; + if (!isFlutterApp) { + return false; + } return _flutterAppSupportsPlatform(kLinux); } @@ -1047,37 +1097,49 @@ class Package { /// Returns whether this package supports Flutter for Android. bool get flutterPluginSupportsAndroid { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kAndroid); } /// Returns whether this package supports Flutter for Web. bool get flutterPluginSupportsWeb { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kWeb); } /// Returns whether this package supports Flutter for Windows. bool get flutterPluginSupportsWindows { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kWindows); } /// Returns whether this package supports Flutter for MacOS. bool get flutterPluginSupportsMacos { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kMacos); } /// Returns whether this package supports Flutter for iOS. bool get flutterPluginSupportsIos { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kIos); } /// Returns whether this package supports Flutter for Linux. bool get flutterPluginSupportsLinux { - if (!isFlutterPlugin) return false; + if (!isFlutterPlugin) { + return false; + } return _flutterPluginSupportsPlatform(kLinux); } diff --git a/packages/melos/lib/src/workspace_config.dart b/packages/melos/lib/src/workspace_config.dart index 7e6c908f0..e3a7de1cb 100644 --- a/packages/melos/lib/src/workspace_config.dart +++ b/packages/melos/lib/src/workspace_config.dart @@ -133,9 +133,9 @@ IntelliJConfig( @immutable class AggregateChangelogConfig { const AggregateChangelogConfig({ - this.isWorkspaceChangelog = false, required this.path, required this.packageFilters, + this.isWorkspaceChangelog = false, this.description, }); @@ -198,9 +198,9 @@ class MelosWorkspaceConfig { MelosWorkspaceConfig({ required this.path, required this.name, + required this.packages, this.sdkPath, this.repository, - required this.packages, this.categories = const {}, this.ignore = const [], this.scripts = Scripts.empty, diff --git a/packages/melos/pubspec.yaml b/packages/melos/pubspec.yaml index e5dec9550..619a2465d 100644 --- a/packages/melos/pubspec.yaml +++ b/packages/melos/pubspec.yaml @@ -49,5 +49,6 @@ dependencies: yaml_edit: ^2.2.2 dev_dependencies: + flame_lint: ^1.2.1 mockito: ^5.4.5 test: any diff --git a/packages/melos/test/utils.dart b/packages/melos/test/utils.dart index 1fb0eb8c5..abfe392a7 100644 --- a/packages/melos/test/utils.dart +++ b/packages/melos/test/utils.dart @@ -328,8 +328,8 @@ class PackageDependencyConfig { } Pubspec pubspecFromJsonFile({ - String path = 'test/test_assets/', required String fileName, + String path = 'test/test_assets/', }) { final filePath = '$path$fileName'; final jsonAsString = readTextFile(filePath);