Update to latest lints, Require Dart 3.2 (dart-lang/package_config#145)
diff --git a/pkgs/package_config/.github/workflows/test-package.yml b/pkgs/package_config/.github/workflows/test-package.yml index 2aa74df..2e47591 100644 --- a/pkgs/package_config/.github/workflows/test-package.yml +++ b/pkgs/package_config/.github/workflows/test-package.yml
@@ -47,7 +47,7 @@ matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [3.0.0, dev] + sdk: [3.2, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
diff --git a/pkgs/package_config/CHANGELOG.md b/pkgs/package_config/CHANGELOG.md index d084d85..a682bc3 100644 --- a/pkgs/package_config/CHANGELOG.md +++ b/pkgs/package_config/CHANGELOG.md
@@ -1,6 +1,6 @@ ## 2.1.1-wip -- Require Dart 3.0 +- Require Dart 3.2 ## 2.1.0
diff --git a/pkgs/package_config/lib/package_config.dart b/pkgs/package_config/lib/package_config.dart index 8f40a8b..194fe89 100644 --- a/pkgs/package_config/lib/package_config.dart +++ b/pkgs/package_config/lib/package_config.dart
@@ -102,7 +102,7 @@ /// then the parent directories are checked recursively, /// all the way to the root directory, to check if those contains /// a package configuration. -/// If [recurse] is set to [false], this parent directory check is not +/// If [recurse] is set to `false`, this parent directory check is not /// performed. /// /// If [onError] is provided, the configuration file parsing will report errors @@ -140,7 +140,7 @@ /// then the parent directories are checked recursively, /// all the way to the root directory, to check if those contains /// a package configuration. -/// If [recurse] is set to [false], this parent directory check is not +/// If [recurse] is set to `false`, this parent directory check is not /// performed. /// /// If [loader] is provided, URIs are loaded using that function.
diff --git a/pkgs/package_config/lib/src/errors.dart b/pkgs/package_config/lib/src/errors.dart index 69c4137..a66fef7 100644 --- a/pkgs/package_config/lib/src/errors.dart +++ b/pkgs/package_config/lib/src/errors.dart
@@ -12,8 +12,9 @@ class PackageConfigArgumentError extends ArgumentError implements PackageConfigError { - PackageConfigArgumentError(Object? value, String name, String message) - : super.value(value, name, message); + PackageConfigArgumentError( + Object? super.value, String super.name, String super.message) + : super.value(); PackageConfigArgumentError.from(ArgumentError error) : super.value(error.invalidValue, error.name, error.message); @@ -21,8 +22,8 @@ class PackageConfigFormatException extends FormatException implements PackageConfigError { - PackageConfigFormatException(String message, Object? source, [int? offset]) - : super(message, source, offset); + PackageConfigFormatException(super.message, Object? super.source, + [super.offset]); PackageConfigFormatException.from(FormatException exception) : super(exception.message, exception.source, exception.offset);
diff --git a/pkgs/package_config/lib/src/package_config.dart b/pkgs/package_config/lib/src/package_config.dart index ba52c14..c00ac67 100644 --- a/pkgs/package_config/lib/src/package_config.dart +++ b/pkgs/package_config/lib/src/package_config.dart
@@ -32,7 +32,7 @@ /// absolute directory URIs, valid language version, if any), /// and there must not be two packages with the same name. /// - /// The package's root ([Package.rootUri]) and package-root + /// The package's root ([Package.root]) and package-root /// ([Package.packageUriRoot]) paths must satisfy a number of constraints /// We say that one path (which we know ends with a `/` charater) /// is inside another path, if the latter path is a prefix of the former path, @@ -95,7 +95,7 @@ /// Parses the JSON data of a package configuration file. /// - /// The [configuration] must be a JSON-like Dart data structure, + /// The [jsonData] must be a JSON-like Dart data structure, /// like the one provided by parsing JSON text using `dart:convert`, /// containing a valid package configuration. /// @@ -167,7 +167,7 @@ /// Provides the associated package for a specific [file] (or directory). /// /// Returns a [Package] which contains the [file]'s path, if any. - /// That is, the [Package.rootUri] directory is a parent directory + /// That is, the [Package.root] directory is a parent directory /// of the [file]'s location. /// /// Returns `null` if the file does not belong to any package. @@ -247,7 +247,7 @@ /// Is always an absolute URI with no query or fragment parts, /// and with a path ending in `/`. /// - /// All files in the [rootUri] directory are considered + /// All files in the [root] directory are considered /// part of the package for purposes where that that matters. Uri get root;
diff --git a/pkgs/package_config/lib/src/package_config_impl.dart b/pkgs/package_config/lib/src/package_config_impl.dart index f832d6a..d8e8d49 100644 --- a/pkgs/package_config/lib/src/package_config_impl.dart +++ b/pkgs/package_config/lib/src/package_config_impl.dart
@@ -141,12 +141,6 @@ @override Package? operator [](String packageName) => _packages[packageName]; - /// Provides the associated package for a specific [file] (or directory). - /// - /// Returns a [Package] which contains the [file]'s path. - /// That is, the [Package.rootUri] directory is a parent directory - /// of the [file]'s location. - /// Returns `null` if the file does not belong to any package. @override Package? packageOf(Uri file) => _packageTree.packageOf(file); @@ -270,7 +264,7 @@ } } -/// Checks whether [version] is a valid Dart language version string. +/// Checks whether [source] is a valid Dart language version string. /// /// The format is (as RegExp) `^(0|[1-9]\d+)\.(0|[1-9]\d+)$`. /// @@ -553,9 +547,8 @@ /// Conflict between packages added to the same configuration. /// /// The [package] conflicts with [existingPackage] if it has -/// the same root path ([isRootConflict]) or the package URI root path -/// of [existingPackage] is inside the root path of [package] -/// ([isPackageRootConflict]). +/// the same root path or the package URI root path +/// of [existingPackage] is inside the root path of [package]. class ConflictException { /// The existing package that [package] conflicts with. final SimplePackage existingPackage;
diff --git a/pkgs/package_config/lib/src/package_config_io.dart b/pkgs/package_config/lib/src/package_config_io.dart index 9aed621..8c5773b 100644 --- a/pkgs/package_config/lib/src/package_config_io.dart +++ b/pkgs/package_config/lib/src/package_config_io.dart
@@ -38,7 +38,7 @@ /// If the [file] is a `.packages` file and [preferNewest] is true, /// first checks whether there is an adjacent `.dart_tool/package_config.json` /// file, and if so, reads that instead. -/// If [preferNewset] is false, the specified file is loaded even if it is +/// If [preferNewest] is false, the specified file is loaded even if it is /// a `.packages` file and there is an available `package_config.json` file. /// /// The file must exist and be a normal file.
diff --git a/pkgs/package_config/lib/src/package_config_json.dart b/pkgs/package_config/lib/src/package_config_json.dart index 47e7e96..65560a0 100644 --- a/pkgs/package_config/lib/src/package_config_json.dart +++ b/pkgs/package_config/lib/src/package_config_json.dart
@@ -75,10 +75,8 @@ /// where the integer numeral cannot have a sign, and can only have a /// leading zero if the entire numeral is a single zero. /// -/// All other properties are stored in [extraData]. -/// /// The [baseLocation] is used as base URI to resolve the "rootUri" -/// URI referencestring. +/// URI reference string. PackageConfig parsePackageConfigJson( Object? json, Uri baseLocation, void Function(Object error) onError) { if (!baseLocation.hasScheme || baseLocation.isScheme('package')) { @@ -93,7 +91,7 @@ String typeName<T>() { if (0 is T) return 'int'; if ('' is T) return 'string'; - if (const [] is T) return 'array'; + if (const <Object?>[] is T) return 'array'; return 'object'; } @@ -239,7 +237,7 @@ PackageConfig config, Uri? baseUri, StringSink output) { // Can be optimized. var data = packageConfigToJson(config, baseUri); - output.write(JsonEncoder.withIndent(' ').convert(data)); + output.write(const JsonEncoder.withIndent(' ').convert(data)); } Map<String, Object?> packageConfigToJson(PackageConfig config, Uri? baseUri) =>
diff --git a/pkgs/package_config/lib/src/packages_file.dart b/pkgs/package_config/lib/src/packages_file.dart index 5d14677..f84db10 100644 --- a/pkgs/package_config/lib/src/packages_file.dart +++ b/pkgs/package_config/lib/src/packages_file.dart
@@ -148,12 +148,6 @@ /// /// If [baseUri] is provided, package locations will be made relative /// to the base URI, if possible, before writing. -/// -/// If [allowDefaultPackage] is `true`, the [packageMapping] may contain an -/// empty string mapping to the _default package name_. -/// -/// All the keys of [packageMapping] must be valid package names, -/// and the values must be URIs that do not have the `package:` scheme. void write(StringSink output, PackageConfig config, {Uri? baseUri, String? comment}) { if (baseUri != null && !baseUri.isAbsolute) {
diff --git a/pkgs/package_config/pubspec.yaml b/pkgs/package_config/pubspec.yaml index e121ab0..b713079 100644 --- a/pkgs/package_config/pubspec.yaml +++ b/pkgs/package_config/pubspec.yaml
@@ -4,7 +4,7 @@ repository: https://github.com/dart-lang/package_config environment: - sdk: ^3.0.0 + sdk: ^3.2.0 dependencies: path: ^1.8.0 @@ -13,5 +13,5 @@ build_runner: ^2.0.0 build_test: ^2.1.2 build_web_compilers: ^4.0.0 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 test: ^1.16.0
diff --git a/pkgs/package_config/test/discovery_test.dart b/pkgs/package_config/test/discovery_test.dart index 3eb0ea1..ee77559 100644 --- a/pkgs/package_config/test/discovery_test.dart +++ b/pkgs/package_config/test/discovery_test.dart
@@ -59,7 +59,7 @@ fileTest('package_config.json', { '.packages': 'invalid .packages file', 'script.dart': 'main(){}', - 'packages': {'shouldNotBeFound': {}}, + 'packages': {'shouldNotBeFound': <Never>{}}, '.dart_tool': { 'package_config.json': packageConfigFile, } @@ -73,7 +73,7 @@ fileTest('.packages', { '.packages': packagesFile, 'script.dart': 'main(){}', - 'packages': {'shouldNotBeFound': {}} + 'packages': {'shouldNotBeFound': <Object, Object>{}} }, (Directory directory) async { var config = (await findPackageConfig(directory))!; expect(config.version, 1); // Found .packages file. @@ -108,7 +108,7 @@ // Does not find a packages/ directory, and returns null if nothing found. fileTest('package directory packages not supported', { 'packages': { - 'foo': {}, + 'foo': <String, dynamic>{}, } }, (Directory directory) async { var config = await findPackageConfig(directory); @@ -119,15 +119,13 @@ fileTest('invalid .packages', { '.packages': 'not a .packages file', }, (Directory directory) { - expect(findPackageConfig(directory), - throwsA(TypeMatcher<FormatException>())); + expect(findPackageConfig(directory), throwsA(isA<FormatException>())); }); fileTest('invalid .packages as JSON', { '.packages': packageConfigFile, }, (Directory directory) { - expect(findPackageConfig(directory), - throwsA(TypeMatcher<FormatException>())); + expect(findPackageConfig(directory), throwsA(isA<FormatException>())); }); fileTest('invalid .packages', { @@ -135,8 +133,7 @@ 'package_config.json': 'not a JSON file', } }, (Directory directory) { - expect(findPackageConfig(directory), - throwsA(TypeMatcher<FormatException>())); + expect(findPackageConfig(directory), throwsA(isA<FormatException>())); }); fileTest('invalid .packages as INI', { @@ -144,8 +141,7 @@ 'package_config.json': packagesFile, } }, (Directory directory) { - expect(findPackageConfig(directory), - throwsA(TypeMatcher<FormatException>())); + expect(findPackageConfig(directory), throwsA(isA<FormatException>())); }); }); @@ -304,8 +300,8 @@ fileTest('no config found', {}, (Directory directory) { var file = dirFile(directory, 'anyname'); - expect(() => loadPackageConfig(file), - throwsA(TypeMatcher<FileSystemException>())); + expect( + () => loadPackageConfig(file), throwsA(isA<FileSystemException>())); }); fileTest('no config found, handled', {}, (Directory directory) async {
diff --git a/pkgs/package_config/test/discovery_uri_test.dart b/pkgs/package_config/test/discovery_uri_test.dart index c8fbcb8..b71ed51 100644 --- a/pkgs/package_config/test/discovery_uri_test.dart +++ b/pkgs/package_config/test/discovery_uri_test.dart
@@ -56,7 +56,7 @@ loaderTest('package_config.json', { '.packages': 'invalid .packages file', 'script.dart': 'main(){}', - 'packages': {'shouldNotBeFound': {}}, + 'packages': {'shouldNotBeFound': <String, dynamic>{}}, '.dart_tool': { 'package_config.json': packageConfigFile, } @@ -70,7 +70,7 @@ loaderTest('.packages', { '.packages': packagesFile, 'script.dart': 'main(){}', - 'packages': {'shouldNotBeFound': {}} + 'packages': {'shouldNotBeFound': <String, dynamic>{}} }, (directory, loader) async { var config = (await findPackageConfigUri(directory, loader: loader))!; expect(config.version, 1); // Found .packages file. @@ -107,7 +107,7 @@ // Does not find a packages/ directory, and returns null if nothing found. loaderTest('package directory packages not supported', { 'packages': { - 'foo': {}, + 'foo': <String, dynamic>{}, } }, (Uri directory, loader) async { var config = await findPackageConfigUri(directory, loader: loader); @@ -118,14 +118,14 @@ '.packages': 'not a .packages file', }, (Uri directory, loader) { expect(() => findPackageConfigUri(directory, loader: loader), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); loaderTest('invalid .packages as JSON', { '.packages': packageConfigFile, }, (Uri directory, loader) { expect(() => findPackageConfigUri(directory, loader: loader), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); loaderTest('invalid .packages', { @@ -134,7 +134,7 @@ } }, (Uri directory, loader) { expect(() => findPackageConfigUri(directory, loader: loader), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); loaderTest('invalid .packages as INI', { @@ -143,7 +143,7 @@ } }, (Uri directory, loader) { expect(() => findPackageConfigUri(directory, loader: loader), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); // Does not find .packages if no package_config.json and minVersion > 1.
diff --git a/pkgs/package_config/test/package_config_impl_test.dart b/pkgs/package_config/test/package_config_impl_test.dart index cef1217..87d1fd4 100644 --- a/pkgs/package_config/test/package_config_impl_test.dart +++ b/pkgs/package_config/test/package_config_impl_test.dart
@@ -36,7 +36,7 @@ void failParse(String name, String input) { test('$name - error', () { expect(() => LanguageVersion.parse(input), - throwsA(TypeMatcher<PackageConfigError>())); + throwsA(isA<PackageConfigError>())); expect(() => LanguageVersion.parse(input), throwsFormatException); var failed = false; var actual = LanguageVersion.parse(input, onError: (_) {
diff --git a/pkgs/package_config/test/parse_test.dart b/pkgs/package_config/test/parse_test.dart index ad4c749..402fe8c 100644 --- a/pkgs/package_config/test/parse_test.dart +++ b/pkgs/package_config/test/parse_test.dart
@@ -53,7 +53,7 @@ test(name, () { expect( () => packages.parse(utf8.encode(content), baseFile, throwError), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); test('$name, handle error', () { var hadError = false; @@ -308,7 +308,7 @@ // ignore: unnecessary_cast () => parsePackageConfigBytes(utf8.encode(source) as Uint8List, Uri.parse('file:///tmp/.dart_tool/file.dart'), throwError), - throwsA(TypeMatcher<FormatException>())); + throwsA(isA<FormatException>())); }); }
diff --git a/pkgs/package_config/test/src/util.dart b/pkgs/package_config/test/src/util.dart index 246e129..780ee80 100644 --- a/pkgs/package_config/test/src/util.dart +++ b/pkgs/package_config/test/src/util.dart
@@ -28,7 +28,7 @@ } """; -/// Mimics a directory structure of [description] and runs [fileTest]. +/// Mimics a directory structure of [description] and runs [loaderTest]. /// /// Description is a map, each key is a file entry. If the value is a map, /// it's a subdirectory, otherwise it's a file and the value is the content