Ben Konyi 1709c884aa
[ Tool ] Enable omit_obvious_*_types and specify_nonobvious_*_types lints (#172018)
Sources under `packages/flutter_tools/` aren't accessible to the average
Flutter user by navigating through sources from their projects, so it
doesn't need to be as explicitly verbose with types for readability
purposes. The `always_specify_types` lint results in extremely verbose
code within the tool which adds little value.

This change disables `always_specify_types` in favor of a new set of
lints that aim to reduce verbosity by removing obvious types while also
maintaining readability in cases where variable types otherwise wouldn't
be obvious:

  - `omit_obvious_local_variable_types`
  - `omit_obvious_property_types`
  - `specify_nonobvious_local_variable_types`
  - `specify_nonobvious_property_types`
2025-07-11 19:32:57 +00:00

45 lines
1.5 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/flutter_manifest.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:yaml/yaml.dart';
import 'common.dart';
/// Check if the pubspec.yaml file under the `projectDir` is valid for a plugin project.
void validatePubspecForPlugin({
required String projectDir,
String? pluginClass,
bool ffiPlugin = false,
required List<String> expectedPlatforms,
List<String> unexpectedPlatforms = const <String>[],
String? androidIdentifier,
String? webFileName,
}) {
assert(pluginClass != null || ffiPlugin);
final FlutterManifest manifest = FlutterManifest.createFromPath(
'$projectDir/pubspec.yaml',
fileSystem: globals.fs,
logger: globals.logger,
)!;
final platformMaps = YamlMap.wrap(manifest.supportedPlatforms!);
for (final platform in expectedPlatforms) {
expect(platformMaps[platform], isNotNull);
final platformMap = platformMaps[platform]! as YamlMap;
if (pluginClass != null) {
expect(platformMap['pluginClass'], pluginClass);
}
if (platform == 'android') {
expect(platformMap['package'], androidIdentifier);
}
if (platform == 'web') {
expect(platformMap['fileName'], webFileName);
}
}
for (final platform in unexpectedPlatforms) {
expect(platformMaps[platform], isNull);
}
}