diff --git a/slang/lib/src/builder/generator/generate_translations.dart b/slang/lib/src/builder/generator/generate_translations.dart index c22a82f7..d96d058c 100644 --- a/slang/lib/src/builder/generator/generate_translations.dart +++ b/slang/lib/src/builder/generator/generate_translations.dart @@ -320,7 +320,9 @@ void _generateClass( if (!localeData.base || node.interface?.attributes .any((attribute) => attribute.attributeName == key) == - true) buffer.write('@override '); + true) { + buffer.write('@override '); + } // even if this attribute exist, it has to satisfy the same signature as // specified in the interface diff --git a/slang/lib/src/builder/utils/string_extensions.dart b/slang/lib/src/builder/utils/string_extensions.dart index 741118b4..c9a236f0 100644 --- a/slang/lib/src/builder/utils/string_extensions.dart +++ b/slang/lib/src/builder/utils/string_extensions.dart @@ -14,22 +14,15 @@ extension StringExtensions on String { /// transforms the string to the specified case /// if case is null, then no transformation will be applied String toCase(CaseStyle? style) { - switch (style) { - case CaseStyle.camel: - return getWords() - .mapIndexed((index, word) => - index == 0 ? word.toLowerCase() : word.capitalize()) - .join(''); - case CaseStyle.pascal: - return getWords().map((word) => word.capitalize()).join(''); - case CaseStyle.snake: - return getWords().map((word) => word.toLowerCase()).join('_'); - case null: - return this; - default: - print('Unknown case: $style'); - return this; - } + return switch (style) { + CaseStyle.camel => getWords() + .mapIndexed((index, word) => + index == 0 ? word.toLowerCase() : word.capitalize()) + .join(''), + CaseStyle.pascal => getWords().map((word) => word.capitalize()).join(''), + CaseStyle.snake => getWords().map((word) => word.toLowerCase()).join('_'), + null => this, + }; } /// de-DE will be interpreted as [de,DE] @@ -42,9 +35,9 @@ extension StringExtensions on String { /// assume that words are separated by special characters or by camel case List getWords() { final input = this; - final StringBuffer buffer = StringBuffer(); - final List words = []; - final bool isAllCaps = input.toUpperCase() == input; + final buffer = StringBuffer(); + final words = []; + final isAllCaps = input.toUpperCase() == input; for (int i = 0; i < input.length; i++) { final String currChar = input[i]; @@ -70,5 +63,5 @@ extension StringExtensions on String { } } -final RegExp _upperAlphaRegex = RegExp(r'[A-Z]'); -final Set _symbolSet = {' ', '.', '_', '-', '/', '\\'}; +final _upperAlphaRegex = RegExp(r'[A-Z]'); +final _symbolSet = {' ', '.', '_', '-', '/', '\\'}; diff --git a/slang/pubspec.yaml b/slang/pubspec.yaml index 1d2ee047..c2dbcba6 100644 --- a/slang/pubspec.yaml +++ b/slang/pubspec.yaml @@ -26,5 +26,5 @@ dependencies: dev_dependencies: expect_error: ^1.0.7 - lints: ^2.0.0 + lints: any test: ^1.21.0 diff --git a/slang/test/integration/main/compilation_test.dart b/slang/test/integration/main/compilation_test.dart index 9debf8af..c6378e6a 100644 --- a/slang/test/integration/main/compilation_test.dart +++ b/slang/test/integration/main/compilation_test.dart @@ -1,4 +1,5 @@ @Skip('not updated for multiple files') +library; import 'package:expect_error/expect_error.dart'; import 'package:test/test.dart'; diff --git a/slang_build_runner/pubspec.yaml b/slang_build_runner/pubspec.yaml index 86565a4f..e61720ac 100644 --- a/slang_build_runner/pubspec.yaml +++ b/slang_build_runner/pubspec.yaml @@ -15,4 +15,4 @@ dependencies: slang: '>=4.3.0 <4.4.0' dev_dependencies: - lints: ^2.0.0 + lints: any