From e8927c0fddbeeea6ec8095fa38d907d0d3cc67e7 Mon Sep 17 00:00:00 2001 From: Daichi Furiya Date: Tue, 19 Oct 2021 12:10:07 +0900 Subject: [PATCH] refactor: replace to flutter_lints (#137) * refactor: change to flutter_lints * style: fix surround symbol --- example/analysis_options.yaml | 2 +- example/lib/main.dart | 6 +- example/pubspec.lock | 21 +++-- example/pubspec.yaml | 2 +- packages/command/analysis_options.yaml | 2 +- packages/command/bin/flutter_gen_command.dart | 1 + packages/command/pubspec.lock | 21 +++-- packages/command/pubspec.yaml | 2 +- packages/core/analysis_options.yaml | 2 +- packages/core/lib/flutter_generator.dart | 2 + .../core/lib/generators/assets_generator.dart | 8 +- .../core/lib/generators/colors_generator.dart | 2 +- .../core/lib/generators/fonts_generator.dart | 5 +- .../integrations/flare_integration.dart | 2 +- .../integrations/svg_integration.dart | 2 +- packages/core/lib/settings/config.dart | 1 + packages/core/lib/utils/map.dart | 2 +- packages/core/pubspec.lock | 21 +++-- packages/core/pubspec.yaml | 2 +- .../test/assets_gen_integrations_test.dart | 22 +++--- packages/core/test/assets_gen_test.dart | 36 ++++----- packages/core/test/colors_gen_test.dart | 10 +-- packages/core/test/flutter_gen_test.dart | 76 +++++++++---------- packages/core/test/fonts_gen_test.dart | 6 +- packages/runner/analysis_options.yaml | 2 +- packages/runner/pubspec.lock | 21 +++-- packages/runner/pubspec.yaml | 2 +- 27 files changed, 157 insertions(+), 124 deletions(-) diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 05557e9b..a932a962 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:effective_dart/analysis_options.yaml +include: package:flutter_lints/flutter.yaml linter: rules: diff --git a/example/lib/main.dart b/example/lib/main.dart index e21b4770..05906b91 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -23,7 +23,7 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, children: [ // Auto generated image from FlutterGen. - Container( + SizedBox( width: 200, height: 200, child: Assets.flare.penguin.flare( @@ -32,14 +32,14 @@ void main() { ), ), Image(image: Assets.images.chip1), - Assets.images.icons.kmm.svg(key: Key("kmm_svg")), + Assets.images.icons.kmm.svg(key: const Key("kmm_svg")), Assets.images.icons.fuchsia.svg(), Assets.images.icons.paint.svg( width: 120, height: 120, ), Assets.pictures.chip5.image( - key: Key("chip5"), + key: const Key("chip5"), width: 120, height: 120, fit: BoxFit.scaleDown, diff --git a/example/pubspec.lock b/example/pubspec.lock index 94aafee4..ac7380c4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,13 +176,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.1" - effective_dart: - dependency: "direct dev" - description: - name: effective_dart - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" fake_async: dependency: transitive description: @@ -230,6 +223,13 @@ packages: relative: true source: path version: "4.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" flutter_svg: dependency: "direct main" description: @@ -298,6 +298,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1c51f843..8963de36 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -23,7 +23,7 @@ dev_dependencies: flutter_gen_runner: path: ../packages/runner - effective_dart: '>=1.3.1 <2.0.0' + flutter_lints: '>=1.0.4 < 2.0.0' flutter_gen: output: lib/gen/ # Optional (default: lib/gen/) diff --git a/packages/command/analysis_options.yaml b/packages/command/analysis_options.yaml index 05557e9b..a932a962 100644 --- a/packages/command/analysis_options.yaml +++ b/packages/command/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:effective_dart/analysis_options.yaml +include: package:flutter_lints/flutter.yaml linter: rules: diff --git a/packages/command/bin/flutter_gen_command.dart b/packages/command/bin/flutter_gen_command.dart index 3be28807..9389f17b 100644 --- a/packages/command/bin/flutter_gen_command.dart +++ b/packages/command/bin/flutter_gen_command.dart @@ -24,6 +24,7 @@ void main(List args) { try { results = parser.parse(args); if (results.wasParsed('help')) { + // ignore: avoid_print print(parser.usage); return; } diff --git a/packages/command/pubspec.lock b/packages/command/pubspec.lock index c765ebbc..55cf5aea 100644 --- a/packages/command/pubspec.lock +++ b/packages/command/pubspec.lock @@ -92,13 +92,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.1" - effective_dart: - dependency: "direct dev" - description: - name: effective_dart - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" file: dependency: transitive description: @@ -113,6 +106,13 @@ packages: relative: true source: path version: "4.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" glob: dependency: transitive description: @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" meta: dependency: transitive description: diff --git a/packages/command/pubspec.yaml b/packages/command/pubspec.yaml index 0e894f41..3eb8a4f7 100644 --- a/packages/command/pubspec.yaml +++ b/packages/command/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: args: '>=2.0.0 <3.0.0' dev_dependencies: - effective_dart: '>=1.3.1 <2.0.0' + flutter_lints: '>=1.0.4 < 2.0.0' # TODO: When publish to pub.dev, disabled the dependencies_override dependency_overrides: diff --git a/packages/core/analysis_options.yaml b/packages/core/analysis_options.yaml index 7b2c380e..47aaa21c 100644 --- a/packages/core/analysis_options.yaml +++ b/packages/core/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:effective_dart/analysis_options.yaml +include: package:flutter_lints/flutter.yaml analyzer: exclude: diff --git a/packages/core/lib/flutter_generator.dart b/packages/core/lib/flutter_generator.dart index 7d64c0a5..3106644a 100644 --- a/packages/core/lib/flutter_generator.dart +++ b/packages/core/lib/flutter_generator.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'dart:io'; import 'package:dart_style/dart_style.dart'; diff --git a/packages/core/lib/generators/assets_generator.dart b/packages/core/lib/generators/assets_generator.dart index 1e4171bf..e64d4383 100644 --- a/packages/core/lib/generators/assets_generator.dart +++ b/packages/core/lib/generators/assets_generator.dart @@ -47,7 +47,7 @@ String generateAssets( DartFormatter formatter, ) { if (config.assets.isEmpty) { - throw InvalidSettingsException( + throw const InvalidSettingsException( 'The value of "flutter/assets:" is incorrect.'); } @@ -148,7 +148,7 @@ _Statement? _createAssetTypeStatement( return _Statement( type: 'AssetGenImage', name: name, - value: 'AssetGenImage\(\'${posixStyle(assetType.path)}\'\)', + value: 'AssetGenImage(\'${posixStyle(assetType.path)}\')', isConstConstructor: true, ); } else if (FileSystemEntity.isDirectorySync(childAssetAbsolutePath)) { @@ -156,7 +156,7 @@ _Statement? _createAssetTypeStatement( return _Statement( type: childClassName, name: name, - value: '$childClassName\(\)', + value: '$childClassName()', isConstConstructor: true, ); } else if (!assetType.isIgnoreFile) { @@ -227,7 +227,7 @@ String _dotDelimiterStyleDefinition( assetsStaticStatements.add(_Statement( type: className, name: assetType.baseName.camelCase(), - value: '$className\(\)', + value: '$className()', isConstConstructor: true, )); } diff --git a/packages/core/lib/generators/colors_generator.dart b/packages/core/lib/generators/colors_generator.dart index 3df84abe..a7a1aab7 100644 --- a/packages/core/lib/generators/colors_generator.dart +++ b/packages/core/lib/generators/colors_generator.dart @@ -18,7 +18,7 @@ String generateColors( FlutterGenColors colors, ) { if (colors.inputs.isEmpty) { - throw InvalidSettingsException( + throw const InvalidSettingsException( 'The value of "flutter_gen/colors:" is incorrect.'); } diff --git a/packages/core/lib/generators/fonts_generator.dart b/packages/core/lib/generators/fonts_generator.dart index a0973014..b99d7191 100644 --- a/packages/core/lib/generators/fonts_generator.dart +++ b/packages/core/lib/generators/fonts_generator.dart @@ -1,3 +1,5 @@ +// ignore_for_file: prefer_const_constructors + import 'package:dart_style/dart_style.dart'; import 'package:dartx/dartx.dart'; @@ -23,8 +25,7 @@ String generateFonts( buffer.writeln(); fonts.map((element) => element.family).distinct().sorted().forEach((family) { - buffer - .writeln(" static const String ${family.camelCase()} = \'$family\';"); + buffer.writeln(" static const String ${family.camelCase()} = '$family';"); }); buffer.writeln('}'); diff --git a/packages/core/lib/generators/integrations/flare_integration.dart b/packages/core/lib/generators/integrations/flare_integration.dart index 8f518e66..717f89df 100644 --- a/packages/core/lib/generators/integrations/flare_integration.dart +++ b/packages/core/lib/generators/integrations/flare_integration.dart @@ -56,7 +56,7 @@ class FlareIntegration extends Integration { String get className => 'FlareGenImage'; @override - String classInstantiate(String path) => 'FlareGenImage\(\'$path\'\)'; + String classInstantiate(String path) => 'FlareGenImage(\'$path\')'; @override bool isSupport(AssetType type) => type.extension == '.flr'; diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index a659b824..ff795972 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -68,7 +68,7 @@ class SvgIntegration extends Integration { String get className => 'SvgGenImage'; @override - String classInstantiate(String path) => 'SvgGenImage\(\'$path\'\)'; + String classInstantiate(String path) => 'SvgGenImage(\'$path\')'; @override bool isSupport(AssetType type) => type.mime == 'image/svg+xml'; diff --git a/packages/core/lib/settings/config.dart b/packages/core/lib/settings/config.dart index 216bb118..730ecbcc 100644 --- a/packages/core/lib/settings/config.dart +++ b/packages/core/lib/settings/config.dart @@ -13,6 +13,7 @@ class Config { } Future loadPubspecConfig(File pubspecFile) async { + // ignore: avoid_print print('FlutterGen Loading ... ' '${normalize(join( basename(pubspecFile.parent.path), diff --git a/packages/core/lib/utils/map.dart b/packages/core/lib/utils/map.dart index b0c9b56a..2d1ffbd4 100644 --- a/packages/core/lib/utils/map.dart +++ b/packages/core/lib/utils/map.dart @@ -5,7 +5,7 @@ _copyValues( Map from, Map to, bool recursive, bool acceptNull) { for (var key in from.keys) { if (from[key] is Map && recursive) { - if (!(to[key] is Map)) { + if (to[key] is! Map) { to[key] = {} as V; } _copyValues(from[key] as Map, to[key] as Map, recursive, acceptNull); diff --git a/packages/core/pubspec.lock b/packages/core/pubspec.lock index c0f94831..be7d55d8 100644 --- a/packages/core/pubspec.lock +++ b/packages/core/pubspec.lock @@ -176,13 +176,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.1" - effective_dart: - dependency: "direct dev" - description: - name: effective_dart - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" file: dependency: transitive description: @@ -197,6 +190,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" frontend_server_client: dependency: transitive description: @@ -260,6 +260,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.2" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 5e55ae7f..fcd9840d 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -28,6 +28,6 @@ dependencies: dev_dependencies: test: '>=1.16.0 <2.0.0' - effective_dart: '>=1.3.1 <2.0.0' + flutter_lints: '>=1.0.4 < 2.0.0' build_runner: '>=2.0.0 <3.0.0' json_serializable: '>=5.0.0 <6.0.0' diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index 5d5068e3..8d42e144 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -9,19 +9,19 @@ import 'gen_test_helper.dart'; void main() { group('Test Assets Integration generator', () { test('Assets with No integrations on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets_no_integrations.yaml'; - final fact = 'test_resources/actual_data/assets_no_integrations.gen.dart'; - final generated = + const pubspec = 'test_resources/pubspec_assets_no_integrations.yaml'; + const fact = 'test_resources/actual_data/assets_no_integrations.gen.dart'; + const generated = 'test_resources/lib/gen/assets_no_integrations.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); test('Assets with Svg integrations on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets_svg_integrations.yaml'; - final fact = + const pubspec = 'test_resources/pubspec_assets_svg_integrations.yaml'; + const fact = 'test_resources/actual_data/assets_svg_integrations.gen.dart'; - final generated = + const generated = 'test_resources/lib/gen/assets_svg_integrations.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); @@ -29,17 +29,17 @@ void main() { final integration = SvgIntegration('package_name'); expect(integration.className, 'SvgGenImage'); expect(integration.classInstantiate('assets/path'), - 'SvgGenImage\(\'assets/path\'\)'); + 'SvgGenImage(\'assets/path\')'); expect(integration.isSupport(AssetType('assets/path/dog.svg')), isTrue); expect(integration.isSupport(AssetType('assets/path/dog.png')), isFalse); expect(integration.isConstConstructor, isTrue); }); test('Assets with Flare integrations on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets_flare_integrations.yaml'; - final fact = + const pubspec = 'test_resources/pubspec_assets_flare_integrations.yaml'; + const fact = 'test_resources/actual_data/assets_flare_integrations.gen.dart'; - final generated = + const generated = 'test_resources/lib/gen/assets_flare_integrations.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); @@ -47,7 +47,7 @@ void main() { final integration = FlareIntegration(); expect(integration.className, 'FlareGenImage'); expect(integration.classInstantiate('assets/path'), - 'FlareGenImage\(\'assets/path\'\)'); + 'FlareGenImage(\'assets/path\')'); expect(integration.isSupport(AssetType('assets/path/dog.flr')), isTrue); expect(integration.isSupport(AssetType('assets/path/dog.json')), isFalse); expect(integration.isConstConstructor, isTrue); diff --git a/packages/core/test/assets_gen_test.dart b/packages/core/test/assets_gen_test.dart index 30d62f22..40b2e034 100644 --- a/packages/core/test/assets_gen_test.dart +++ b/packages/core/test/assets_gen_test.dart @@ -12,43 +12,43 @@ import 'gen_test_helper.dart'; void main() { group('Test Assets generator', () { test('Assets on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets.yaml'; - final fact = 'test_resources/actual_data/assets.gen.dart'; - final generated = 'test_resources/lib/gen/assets.gen.dart'; + const pubspec = 'test_resources/pubspec_assets.yaml'; + const fact = 'test_resources/actual_data/assets.gen.dart'; + const generated = 'test_resources/lib/gen/assets.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); test('Assets snake-case style on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets_snake_case.yaml'; - final fact = 'test_resources/actual_data/assets_snake_case.gen.dart'; - final generated = 'test_resources/lib/gen/assets_snake_case.gen.dart'; + const pubspec = 'test_resources/pubspec_assets_snake_case.yaml'; + const fact = 'test_resources/actual_data/assets_snake_case.gen.dart'; + const generated = 'test_resources/lib/gen/assets_snake_case.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); test('Assets camel-case style on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_assets_camel_case.yaml'; - final fact = 'test_resources/actual_data/assets_camel_case.gen.dart'; - final generated = 'test_resources/lib/gen/assets_camel_case.gen.dart'; + const pubspec = 'test_resources/pubspec_assets_camel_case.yaml'; + const fact = 'test_resources/actual_data/assets_camel_case.gen.dart'; + const generated = 'test_resources/lib/gen/assets_camel_case.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); test('Assets with Unknown mime type on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_unknown_mime_type.yaml'; - final fact = + const pubspec = 'test_resources/pubspec_unknown_mime_type.yaml'; + const fact = 'test_resources/actual_data/assets_unknown_mime_type.gen.dart'; - final generated = + const generated = 'test_resources/lib/gen/assets_unknown_mime_type.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); test('Assets with ignore files on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_ignore_files.yaml'; - final fact = 'test_resources/actual_data/assets_ignore_files.gen.dart'; - final generated = 'test_resources/lib/gen/assets_ignore_files.gen.dart'; + const pubspec = 'test_resources/pubspec_ignore_files.yaml'; + const fact = 'test_resources/actual_data/assets_ignore_files.gen.dart'; + const generated = 'test_resources/lib/gen/assets_ignore_files.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); @@ -66,10 +66,10 @@ void main() { }); test('Assets with package parameter enabled', () async { - final pubspec = 'test_resources/pubspec_assets_package_parameter.yaml'; - final fact = + const pubspec = 'test_resources/pubspec_assets_package_parameter.yaml'; + const fact = 'test_resources/actual_data/assets_package_parameter.gen.dart'; - final generated = + const generated = 'test_resources/lib/gen/assets_package_parameter.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); diff --git a/packages/core/test/colors_gen_test.dart b/packages/core/test/colors_gen_test.dart index d29d6cc4..c03bb5a9 100644 --- a/packages/core/test/colors_gen_test.dart +++ b/packages/core/test/colors_gen_test.dart @@ -13,9 +13,9 @@ import 'gen_test_helper.dart'; void main() { group('Test Color generator', () { test('Colors on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_colors.yaml'; - final fact = 'test_resources/actual_data/colors.gen.dart'; - final generated = 'test_resources/lib/gen/colors.gen.dart'; + const pubspec = 'test_resources/pubspec_colors.yaml'; + const fact = 'test_resources/actual_data/colors.gen.dart'; + const generated = 'test_resources/lib/gen/colors.gen.dart'; await expectedColorsGen(pubspec, generated, fact); }); @@ -45,11 +45,11 @@ void main() { }); test('ColorPath Tests', () async { - final colorPath = ColorPath('test_resources/assets/color/colors.xml'); + const colorPath = ColorPath('test_resources/assets/color/colors.xml'); expect(colorPath.mime, 'application/xml'); expect(colorPath.isXml, isTrue); - final wrongColorPath = + const wrongColorPath = ColorPath('test_resources/assets/json/fruits.json'); expect(wrongColorPath.isXml, isFalse); }); diff --git a/packages/core/test/flutter_gen_test.dart b/packages/core/test/flutter_gen_test.dart index eb64b04c..cdcf03f4 100644 --- a/packages/core/test/flutter_gen_test.dart +++ b/packages/core/test/flutter_gen_test.dart @@ -7,10 +7,10 @@ import 'package:test/test.dart'; void main() { group('Test FlutterGenerator Exceptions', () { test('Not founded pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_not_founded.yaml'; - final assets = 'pubspec_not_founded_assets.gen.dart'; - final colors = 'pubspec_not_founded_colors.gen.dart'; - final fonts = 'pubspec_not_founded_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_not_founded.yaml'; + const assets = 'pubspec_not_founded_assets.gen.dart'; + const colors = 'pubspec_not_founded_colors.gen.dart'; + const fonts = 'pubspec_not_founded_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -24,10 +24,10 @@ void main() { }); test('Empty pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_empty.yaml'; - final assets = 'pubspec_empty_assets.gen.dart'; - final colors = 'pubspec_empty_colors.gen.dart'; - final fonts = 'pubspec_empty_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_empty.yaml'; + const assets = 'pubspec_empty_assets.gen.dart'; + const colors = 'pubspec_empty_colors.gen.dart'; + const fonts = 'pubspec_empty_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -41,10 +41,10 @@ void main() { }); test('No settings pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_no_settings.yaml'; - final assets = 'pubspec_no_settings_assets.gen.dart'; - final colors = 'pubspec_no_settings_colors.gen.dart'; - final fonts = 'pubspec_no_settings_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_no_settings.yaml'; + const assets = 'pubspec_no_settings_assets.gen.dart'; + const colors = 'pubspec_no_settings_colors.gen.dart'; + const fonts = 'pubspec_no_settings_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -60,10 +60,10 @@ void main() { group('Test FlutterGenerator', () { test('pubspec_normal.yaml', () async { - final pubspec = 'test_resources/pubspec_normal.yaml'; - final assets = 'pubspec_assets.gen.dart'; - final colors = 'pubspec_colors.gen.dart'; - final fonts = 'pubspec_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_normal.yaml'; + const assets = 'pubspec_assets.gen.dart'; + const colors = 'pubspec_colors.gen.dart'; + const fonts = 'pubspec_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -80,10 +80,10 @@ void main() { }); test('Only flutter value', () async { - final pubspec = 'test_resources/pubspec_only_flutter_value.yaml'; - final assets = 'pubspec_only_flutter_value_assets.gen.dart'; - final colors = 'pubspec_only_flutter_value_colors.gen.dart'; - final fonts = 'pubspec_only_flutter_value_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_only_flutter_value.yaml'; + const assets = 'pubspec_only_flutter_value_assets.gen.dart'; + const colors = 'pubspec_only_flutter_value_colors.gen.dart'; + const fonts = 'pubspec_only_flutter_value_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -99,10 +99,10 @@ void main() { }); test('Only flutter_gen value', () async { - final pubspec = 'test_resources/pubspec_only_flutter_gen_value.yaml'; - final assets = 'pubspec_only_flutter_gen_value_assets.gen.dart'; - final colors = 'pubspec_only_flutter_gen_value_colors.gen.dart'; - final fonts = 'pubspec_only_flutter_gen_value_colors.gen.dart'; + const pubspec = 'test_resources/pubspec_only_flutter_gen_value.yaml'; + const assets = 'pubspec_only_flutter_gen_value_assets.gen.dart'; + const colors = 'pubspec_only_flutter_gen_value_colors.gen.dart'; + const fonts = 'pubspec_only_flutter_gen_value_colors.gen.dart'; await FlutterGenerator( File(pubspec), @@ -117,10 +117,10 @@ void main() { }); test('Change output path', () async { - final pubspec = 'test_resources/pubspec_change_output_path.yaml'; - final assets = 'pubspec_change_output_path_assets.gen.dart'; - final colors = 'pubspec_change_output_path_colors.gen.dart'; - final fonts = 'pubspec_change_output_path_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_change_output_path.yaml'; + const assets = 'pubspec_change_output_path_assets.gen.dart'; + const colors = 'pubspec_change_output_path_colors.gen.dart'; + const fonts = 'pubspec_change_output_path_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -138,10 +138,10 @@ void main() { }); test('Empty output path', () async { - final pubspec = 'test_resources/pubspec_wrong_output_path.yaml'; - final assets = 'pubspec_wrong_output_path_assets.gen.dart'; - final colors = 'pubspec_wrong_output_path_colors.gen.dart'; - final fonts = 'pubspec_wrong_output_path_fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_wrong_output_path.yaml'; + const assets = 'pubspec_wrong_output_path_assets.gen.dart'; + const colors = 'pubspec_wrong_output_path_colors.gen.dart'; + const fonts = 'pubspec_wrong_output_path_fonts.gen.dart'; await FlutterGenerator( File(pubspec), @@ -158,7 +158,7 @@ void main() { }); test('Wrong lineLength', () async { - final pubspec = 'test_resources/pubspec_wrong_line_length.yaml'; + const pubspec = 'test_resources/pubspec_wrong_line_length.yaml'; expect(() { return FlutterGenerator(File(pubspec)).build(); @@ -166,11 +166,11 @@ void main() { }); test('Disabled generation', () async { - final pubspec = 'test_resources/pubspec_generation_disabled.yaml'; - final assets = 'none_assets.gen.dart'; - final colors = 'none_colors.gen.dart'; - final fonts = 'none_fonts.gen.dart'; - await FlutterGenerator( + const pubspec = 'test_resources/pubspec_generation_disabled.yaml'; + const assets = 'none_assets.gen.dart'; + const colors = 'none_colors.gen.dart'; + const fonts = 'none_fonts.gen.dart'; + FlutterGenerator( File(pubspec), assetsName: assets, colorsName: colors, diff --git a/packages/core/test/fonts_gen_test.dart b/packages/core/test/fonts_gen_test.dart index 64b3a17f..c5bd9960 100644 --- a/packages/core/test/fonts_gen_test.dart +++ b/packages/core/test/fonts_gen_test.dart @@ -12,9 +12,9 @@ import 'gen_test_helper.dart'; void main() { group('Test Fonts generator', () { test('Fonts on pubspec.yaml', () async { - final pubspec = 'test_resources/pubspec_fonts.yaml'; - final fact = 'test_resources/actual_data/fonts.gen.dart'; - final generated = 'test_resources/lib/gen/fonts.gen.dart'; + const pubspec = 'test_resources/pubspec_fonts.yaml'; + const fact = 'test_resources/actual_data/fonts.gen.dart'; + const generated = 'test_resources/lib/gen/fonts.gen.dart'; await expectedFontsGen(pubspec, generated, fact); }); diff --git a/packages/runner/analysis_options.yaml b/packages/runner/analysis_options.yaml index 05557e9b..a932a962 100644 --- a/packages/runner/analysis_options.yaml +++ b/packages/runner/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:effective_dart/analysis_options.yaml +include: package:flutter_lints/flutter.yaml linter: rules: diff --git a/packages/runner/pubspec.lock b/packages/runner/pubspec.lock index 304eec16..29807305 100644 --- a/packages/runner/pubspec.lock +++ b/packages/runner/pubspec.lock @@ -148,13 +148,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.1" - effective_dart: - dependency: "direct dev" - description: - name: effective_dart - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" file: dependency: transitive description: @@ -169,6 +162,13 @@ packages: relative: true source: path version: "4.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" frontend_server_client: dependency: transitive description: @@ -232,6 +232,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: diff --git a/packages/runner/pubspec.yaml b/packages/runner/pubspec.yaml index 38a010b0..cf3090fe 100644 --- a/packages/runner/pubspec.yaml +++ b/packages/runner/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: build: '>=2.0.0 <3.0.0' dev_dependencies: - effective_dart: '>=1.3.1 <2.0.0' + flutter_lints: '>=1.0.4 < 2.0.0' build_test: '>=2.0.0 <3.0.0' # TODO: When publish to pub.dev, disabled the dependencies_override