diff --git a/pkgs/dart_pad/analysis_options.yaml b/pkgs/dart_pad/analysis_options.yaml index db6ff1ea7..655834e75 100644 --- a/pkgs/dart_pad/analysis_options.yaml +++ b/pkgs/dart_pad/analysis_options.yaml @@ -16,16 +16,8 @@ analyzer: linter: rules: - - always_declare_return_types - avoid_private_typedef_functions - avoid_void_async - - directives_ordering - prefer_final_in_for_each - prefer_final_locals - - prefer_mixin - - prefer_relative_imports - - prefer_single_quotes - - sort_pub_dependencies - - unawaited_futures - use_enums - - use_super_parameters diff --git a/pkgs/dart_pad/lib/core/dependencies.dart b/pkgs/dart_pad/lib/core/dependencies.dart index e4b92f3f3..d3d3057d1 100644 --- a/pkgs/dart_pad/lib/core/dependencies.dart +++ b/pkgs/dart_pad/lib/core/dependencies.dart @@ -14,7 +14,7 @@ Dependencies get deps => Dependencies.instance; /// A simple dependency manager. This class manages a collection of singletons. /// You can create separate `Dependency` instances to manage separate sets of /// collections (for instance, one for testing). Or, you can use the single -/// [dependency] instance defined in this library to set up all the singletons +/// [deps] instance defined in this library to set up all the singletons /// for your application. /// /// Dependencies dependencies = new Dependencies(); @@ -34,7 +34,7 @@ Dependencies get deps => Dependencies.instance; /// dependencies.setDependency(DogManager, new MockDogManager()); /// dependencies.runInZone(executeTests); /// -/// It will execute the method [executeTests] in a new Zone. Any queries to +/// It will execute the method `executeTests` in a new Zone. Any queries to /// [Dependencies.instance] will return the new dependencies set up for that /// zone. class Dependencies { diff --git a/pkgs/dart_pad/lib/editing/editor_codemirror.dart b/pkgs/dart_pad/lib/editing/editor_codemirror.dart index cdba46bc8..26a813798 100644 --- a/pkgs/dart_pad/lib/editing/editor_codemirror.dart +++ b/pkgs/dart_pad/lib/editing/editor_codemirror.dart @@ -136,7 +136,8 @@ class CodeMirrorFactory extends EditorFactory { } }, hintRenderer: (html.Element element, HintResult hint) { - final escapeHtml = HtmlEscape().convert as String Function(String?); + final escapeHtml = + const HtmlEscape().convert as String Function(String?); if (completion.type != 'type-quick_fix') { element.innerHtml = escapeHtml(completion.displayString) .replaceFirst(escapeHtml(stringToReplace), diff --git a/pkgs/dart_pad/lib/elements/console.dart b/pkgs/dart_pad/lib/elements/console.dart index dcb539cd3..8dd3dbe75 100644 --- a/pkgs/dart_pad/lib/elements/console.dart +++ b/pkgs/dart_pad/lib/elements/console.dart @@ -124,8 +124,8 @@ class AnsiConsoleHandler { 0xa5a5a5, // bright white ]; - /// We set this to [darkModeAnsiColors] or [lightModeAnsiColors] in constructor - /// depending on [_darkMode]. + /// We set this to [darkModeAnsiColors] or [lightModeAnsiColors] in + /// the constructor depending on if `darkMode` is enabled or not. late final List _themeModeAnsiColors; // Certain ranges that are matched here do not contain real graphics rendition diff --git a/pkgs/dart_pad/lib/elements/elements.dart b/pkgs/dart_pad/lib/elements/elements.dart index a58b2997a..dbfd734e9 100644 --- a/pkgs/dart_pad/lib/elements/elements.dart +++ b/pkgs/dart_pad/lib/elements/elements.dart @@ -248,7 +248,7 @@ class DToast extends DElement { // Add to the DOM, start a timer, make it visible. document.body!.children.add(element); - Timer(Duration(milliseconds: 16), () { + Timer(const Duration(milliseconds: 16), () { element.classes.toggle('showing', true); }); } @@ -331,7 +331,7 @@ abstract class DDialog extends DElement { // Add to the DOM, start a timer, make it visible. document.body!.children.add(element); - Timer(Duration(milliseconds: 16), () { + Timer(const Duration(milliseconds: 16), () { element.classes.toggle('showing', true); }); } @@ -342,7 +342,7 @@ abstract class DDialog extends DElement { pane.hide(); // Start a timer, hide, remove from dom. - Timer(Duration(milliseconds: 16), () { + Timer(const Duration(milliseconds: 16), () { element.classes.toggle('showing', false); element.onTransitionEnd.first.then((event) { dispose(); diff --git a/pkgs/dart_pad/lib/embed.dart b/pkgs/dart_pad/lib/embed.dart index fcad7baa4..bf9e6fa1e 100644 --- a/pkgs/dart_pad/lib/embed.dart +++ b/pkgs/dart_pad/lib/embed.dart @@ -476,7 +476,7 @@ class Embed extends EditorUi { void _init() { deps[GistLoader] = GistLoader.defaultFilters(); - deps[Analytics] = Analytics(); + deps[Analytics] = const Analytics(); final channel = queryParams.channel; if (Channel.urlMapping.keys.contains(channel)) { @@ -1377,7 +1377,7 @@ class EmbedContext extends Context { /// Counts the number of lines in [str]. static int countLinesInString(String str) => - LineSplitter().convert(str).length; + const LineSplitter().convert(str).length; } final RegExp _flutterUrlExp = diff --git a/pkgs/dart_pad/lib/github.dart b/pkgs/dart_pad/lib/github.dart index b2945a8e3..76062800a 100644 --- a/pkgs/dart_pad/lib/github.dart +++ b/pkgs/dart_pad/lib/github.dart @@ -151,7 +151,7 @@ class GitHubUIController { void setupGithubGistListeners() { _playground.mutableGist.onChanged - .debounce(Duration(milliseconds: 100)) + .debounce(const Duration(milliseconds: 100)) .listen((_) { setUnsavedLocalEdits(); }); @@ -170,12 +170,12 @@ class GitHubUIController { _updateStarredGistMenuState(); }); _starUnstarButton.onClick - .debounce(Duration(milliseconds: 100)) + .debounce(const Duration(milliseconds: 100)) .listen(_starredButtonClickHandler); // This will only happen when we make 'contenteditable' true while authenticated. _titleElement.element.onInput - .debounce(Duration(milliseconds: 100)) + .debounce(const Duration(milliseconds: 100)) .listen((_) { _playground.mutableGist.description = _titleElement.text; setUnsavedLocalEdits(); diff --git a/pkgs/dart_pad/lib/playground.dart b/pkgs/dart_pad/lib/playground.dart index 1820808a1..af91682d0 100644 --- a/pkgs/dart_pad/lib/playground.dart +++ b/pkgs/dart_pad/lib/playground.dart @@ -166,7 +166,9 @@ class Playground extends EditorUi implements GistContainer, GistController { void _initGistStorage() { // If there was a change, and the gist is dirty, write the gist's contents // to storage. - mutableGist.onChanged.debounce(Duration(milliseconds: 100)).listen((_) { + mutableGist.onChanged + .debounce(const Duration(milliseconds: 100)) + .listen((_) { if (mutableGist.dirty) { _gistStorage.setStoredGist(mutableGist.createGist()); } @@ -174,7 +176,9 @@ class Playground extends EditorUi implements GistContainer, GistController { } void _initLayoutDetection() { - mutableGist.onChanged.debounce(Duration(milliseconds: 32)).listen((_) { + mutableGist.onChanged + .debounce(const Duration(milliseconds: 32)) + .listen((_) { if (hasFlutterContent(context.dartSource)) { _changeLayout(Layout.flutter); } else if (hasHtmlContent(context.dartSource)) { @@ -526,7 +530,7 @@ class Playground extends EditorUi implements GistContainer, GistController { executionService.onStderr.listen((m) => showOutput(m, error: true)); // Set up Google Analytics. - deps[Analytics] = Analytics(); + deps[Analytics] = const Analytics(); // Set up the gist loader. deps[GistLoader] = GistLoader.defaultFilters(); diff --git a/pkgs/dart_pad/lib/search_controller.dart b/pkgs/dart_pad/lib/search_controller.dart index 8726821e5..c6f87f557 100644 --- a/pkgs/dart_pad/lib/search_controller.dart +++ b/pkgs/dart_pad/lib/search_controller.dart @@ -377,7 +377,7 @@ class SearchController { } // queue up a second attempt at select all because sometimes browser flakes on first // (this sometimes happens on the first time the search dialog is opened) - Timer(Duration(milliseconds: 20), () { + Timer(const Duration(milliseconds: 20), () { findTextInput.focus(); findTextInput.select(); }); diff --git a/pkgs/dart_pad/lib/services/execution_iframe.dart b/pkgs/dart_pad/lib/services/execution_iframe.dart index 422d21f54..6f25a5171 100644 --- a/pkgs/dart_pad/lib/services/execution_iframe.dart +++ b/pkgs/dart_pad/lib/services/execution_iframe.dart @@ -231,7 +231,8 @@ require(["dartpad_main", "dart_sdk"], function(dartpad_main, dart_sdk) { _frame = clone; } - return _readyCompleter.future.timeout(Duration(seconds: 1), onTimeout: () { + return _readyCompleter.future.timeout(const Duration(seconds: 1), + onTimeout: () { if (!_readyCompleter.isCompleted) _readyCompleter.complete(); }); } diff --git a/pkgs/dart_pad/lib/sharing/exercise_metadata.dart b/pkgs/dart_pad/lib/sharing/exercise_metadata.dart index 6f4c56cee..10760c634 100644 --- a/pkgs/dart_pad/lib/sharing/exercise_metadata.dart +++ b/pkgs/dart_pad/lib/sharing/exercise_metadata.dart @@ -36,13 +36,15 @@ class ExerciseFileMetadata { ExerciseFileMetadata.fromMap(Map? map) { if (map == null) { - throw MetadataException('Null json was given to ExerciseFileMetadata().'); + throw const MetadataException( + 'Null json was given to ExerciseFileMetadata().'); } if (map['name'] == null || map['name'] is! String || (map['name'] as String).isEmpty) { - throw MetadataException('The "name" field is required for each file.'); + throw const MetadataException( + 'The "name" field is required for each file.'); } name = map.containsKey('name') ? map['name'] as String : ''; @@ -63,26 +65,30 @@ class ExerciseMetadata { ExerciseMetadata.fromMap(Map? map) { if (map == null) { - throw MetadataException('Null json was given to ExerciseMetadata().'); + throw const MetadataException( + 'Null json was given to ExerciseMetadata().'); } if (map['name'] == null || map['name'] is! String || (map['name'] as String).isEmpty) { - throw MetadataException('The "name" field is required for an exercise.'); + throw const MetadataException( + 'The "name" field is required for an exercise.'); } if (map['mode'] == null || map['mode'] is! String || !exerciseModeNames.containsKey(map['mode'])) { - throw MetadataException('A "mode" field of "dart", "html" or "flutter" ' + throw const MetadataException( + 'A "mode" field of "dart", "html" or "flutter" ' 'is required for an exercise.'); } if (map['files'] == null || map['files'] is! List || (map['files'] as List).isEmpty) { - throw MetadataException('Each exercise must have at least one file in ' + throw const MetadataException( + 'Each exercise must have at least one file in ' 'its "files" array.'); } diff --git a/pkgs/dart_pad/lib/sharing/gists.dart b/pkgs/dart_pad/lib/sharing/gists.dart index 269861ad1..5d5f08727 100644 --- a/pkgs/dart_pad/lib/sharing/gists.dart +++ b/pkgs/dart_pad/lib/sharing/gists.dart @@ -639,11 +639,11 @@ $styleRef$dartRef final metadataResponse = await _client.get(metadataUrl); if (metadataResponse.statusCode == 404) { - throw GistLoaderException(GistLoaderFailureType.contentNotFound); + throw const GistLoaderException(GistLoaderFailureType.contentNotFound); } else if (metadataResponse.statusCode == 403) { - throw GistLoaderException(GistLoaderFailureType.rateLimitExceeded); + throw const GistLoaderException(GistLoaderFailureType.rateLimitExceeded); } else if (metadataResponse.statusCode != 200) { - throw GistLoaderException(GistLoaderFailureType.unknown); + throw const GistLoaderException(GistLoaderFailureType.unknown); } final metadataContent = extractGitHubResponseBody(metadataResponse.body); @@ -654,7 +654,7 @@ $styleRef$dartRef final yamlMap = yaml.loadYaml(metadataContent); if (yamlMap is! Map) { - throw FormatException(); + throw const FormatException(); } metadata = ExerciseMetadata.fromMap(yamlMap.cast()); @@ -674,12 +674,13 @@ $styleRef$dartRef if (contentResponse.statusCode == 404) { // Blame the metadata for listing an invalid file. - throw GistLoaderException( + throw const GistLoaderException( GistLoaderFailureType.invalidExerciseMetadata); } else if (metadataResponse.statusCode == 403) { - throw GistLoaderException(GistLoaderFailureType.rateLimitExceeded); + throw const GistLoaderException( + GistLoaderFailureType.rateLimitExceeded); } else if (metadataResponse.statusCode != 200) { - throw GistLoaderException(GistLoaderFailureType.unknown); + throw const GistLoaderException(GistLoaderFailureType.unknown); } return extractGitHubResponseBody(contentResponse.body); diff --git a/pkgs/dart_pad/lib/workshops.dart b/pkgs/dart_pad/lib/workshops.dart index 16f668c42..45f9a7212 100644 --- a/pkgs/dart_pad/lib/workshops.dart +++ b/pkgs/dart_pad/lib/workshops.dart @@ -144,11 +144,11 @@ class WorkshopUi extends EditorUi { // Put onchange handler on document and if there are changes // store them in local storage. editor.document.onChange - .debounce(Duration(milliseconds: 500)) + .debounce(const Duration(milliseconds: 500)) .listen((_) => _handleChangeInUsersWork()); editor.document.onChange.listen((_) => busyLight.on()); editor.document.onChange - .debounce(Duration(milliseconds: 1250)) + .debounce(const Duration(milliseconds: 1250)) .listen((_) => performAnalysis()); editorFactory.registerCompleter( @@ -225,7 +225,7 @@ class WorkshopUi extends EditorUi { executionService.onStdout.listen(showOutput); executionService.onStderr.listen((m) => showOutput(m, error: true)); // Set up Google Analytics. - deps[Analytics] = Analytics(); + deps[Analytics] = const Analytics(); // Use null safety for workshops (deps[DartservicesApi] as DartservicesApi).rootUrl = serverUrl; @@ -461,7 +461,7 @@ class WorkshopUi extends EditorUi { div.children.clear(); div.setInnerHtml( markdown.markdownToHtml(_workshopState.currentStep.instructions, - blockSyntaxes: [markdown.TableSyntax()]), + blockSyntaxes: [const markdown.TableSyntax()]), validator: _htmlValidator); hljs.highlightAll(); div.scrollTop = 0; diff --git a/pkgs/dart_pad/lib/workshops/src/github.dart b/pkgs/dart_pad/lib/workshops/src/github.dart index c01dee897..7e0bc37d1 100644 --- a/pkgs/dart_pad/lib/workshops/src/github.dart +++ b/pkgs/dart_pad/lib/workshops/src/github.dart @@ -30,12 +30,13 @@ class GithubWorkshopFetcher extends WorkshopFetcherImpl { final statusCode = res.statusCode; if (statusCode == 404) { - throw WorkshopFetchException(WorkshopFetchExceptionType.contentNotFound); + throw const WorkshopFetchException( + WorkshopFetchExceptionType.contentNotFound); } else if (statusCode == 403) { - throw WorkshopFetchException( + throw const WorkshopFetchException( WorkshopFetchExceptionType.rateLimitExceeded); } else if (statusCode != 200) { - throw WorkshopFetchException(WorkshopFetchExceptionType.unknown); + throw const WorkshopFetchException(WorkshopFetchExceptionType.unknown); } return extractGitHubResponseBody(res.body); diff --git a/pkgs/dart_pad/pubspec.lock b/pkgs/dart_pad/pubspec.lock index 0c2f7d168..531daf52c 100644 --- a/pkgs/dart_pad/pubspec.lock +++ b/pkgs/dart_pad/pubspec.lock @@ -253,10 +253,10 @@ packages: dependency: "direct dev" description: name: dart_flutter_team_lints - sha256: e2f4fcafdaf0797e5af1c5c162d0b6c5025e9228ab3f95174340ed35c85dccd6 + sha256: "66517b1f6a53e3275938eece5fe0df6960d1e86a82bad074d7364a9a5c97ae10" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.0.0" dart_style: dependency: transitive description: diff --git a/pkgs/dart_pad/pubspec.yaml b/pkgs/dart_pad/pubspec.yaml index f221bf250..560c78c58 100644 --- a/pkgs/dart_pad/pubspec.yaml +++ b/pkgs/dart_pad/pubspec.yaml @@ -34,7 +34,7 @@ dev_dependencies: build_runner: ^2.4.4 build_test: ^2.1.7 build_web_compilers: ^4.0.3 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 git: ^2.0.0 grinder: ^0.9.4 json_serializable: ^6.7.0 diff --git a/pkgs/dart_pad/test/e2e/playground_test.dart b/pkgs/dart_pad/test/e2e/playground_test.dart index e0fc37b54..3d4d85e54 100644 --- a/pkgs/dart_pad/test/e2e/playground_test.dart +++ b/pkgs/dart_pad/test/e2e/playground_test.dart @@ -71,11 +71,11 @@ void main() async { Future waitForPageToStabilize() async { while (true) { final versionsElement = - await driver.findElement(By.id('dartpad-version')); + await driver.findElement(const By.id('dartpad-version')); if ((await versionsElement.text).isNotEmpty) { return; } - await Future.delayed(Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); } } @@ -85,7 +85,7 @@ void main() async { uri: Uri.parse('http://localhost:4444/wd/hub/'), desired: Capabilities.chrome); - await Future.delayed(Duration(milliseconds: 2000)); + await Future.delayed(const Duration(milliseconds: 2000)); // Go to your page await driver.get('http://localhost:8000/'); @@ -97,14 +97,15 @@ void main() async { }); Future writeScript(String content) async { - final codeMirror = await driver.findElement(By.className('CodeMirror')); + final codeMirror = + await driver.findElement(const By.className('CodeMirror')); content = content.replaceAll('\n', '\\n'); await driver .execute('arguments[0].CodeMirror.setValue("$content");', [codeMirror]); } Future runScript() async { - final runButton = await driver.findElement(By.id('run-button')); + final runButton = await driver.findElement(const By.id('run-button')); await runButton.click(); } @@ -114,7 +115,7 @@ void main() async { Future waitForOutput(String sample) async { while (true) { final outputPanel = - await driver.findElement(By.id('right-output-panel-content')); + await driver.findElement(const By.id('right-output-panel-content')); final text = await outputPanel.text; if (text.contains(sample)) { return text; @@ -123,7 +124,8 @@ void main() async { } test('Version text is displayed', () async { - final versionsElement = await driver.findElement(By.id('dartpad-version')); + final versionsElement = + await driver.findElement(const By.id('dartpad-version')); expect(await versionsElement.text, startsWith('Based on Flutter')); }, skip: runningInCi); diff --git a/pkgs/dart_pad/test/embed/embed_test.dart b/pkgs/dart_pad/test/embed/embed_test.dart index 07b378b8d..7a5f0f9fc 100644 --- a/pkgs/dart_pad/test/embed/embed_test.dart +++ b/pkgs/dart_pad/test/embed/embed_test.dart @@ -12,7 +12,7 @@ import 'package:test/test.dart'; void main() { group('embed', () { - setUp(() => embed.init(embed.EmbedOptions(embed.EmbedMode.flutter))); + setUp(() => embed.init(const embed.EmbedOptions(embed.EmbedMode.flutter))); test('Editor tab is selected at init', () { final editorTab = querySelector('#editor-tab')!; diff --git a/pkgs/dart_pad/test/inject/inject_embed_test.dart b/pkgs/dart_pad/test/inject/inject_embed_test.dart index ddcec1a10..2a1d32d4d 100644 --- a/pkgs/dart_pad/test/inject/inject_embed_test.dart +++ b/pkgs/dart_pad/test/inject/inject_embed_test.dart @@ -24,7 +24,7 @@ void main() { test('injects a DartPad iframe with a correct code snippet', () async { final iframes = querySelectorAll('iframe'); final iframe = iframes.first; - expect(iframe, TypeMatcher()); + expect(iframe, const TypeMatcher()); expect(iframe.attributes['src'], 'embed-flutter.html?theme=dark&run=false&split=false&ga_id=example1&null_safety=false'); }); diff --git a/pkgs/dart_pad/test/inject/inject_parser_test.dart b/pkgs/dart_pad/test/inject/inject_parser_test.dart index 6d444b626..523b619a9 100644 --- a/pkgs/dart_pad/test/inject/inject_parser_test.dart +++ b/pkgs/dart_pad/test/inject/inject_parser_test.dart @@ -18,7 +18,7 @@ void main() { test('throws with invalid input', () { expect(InjectParser(_invalidCodelab).read, - throwsA(TypeMatcher())); + throwsA(const TypeMatcher())); }); test('can parse normal snippets', () { diff --git a/pkgs/dart_pad/web/scripts/embed_dart.dart b/pkgs/dart_pad/web/scripts/embed_dart.dart index a6873fb9c..3d7160eba 100644 --- a/pkgs/dart_pad/web/scripts/embed_dart.dart +++ b/pkgs/dart_pad/web/scripts/embed_dart.dart @@ -6,7 +6,7 @@ import 'package:dart_pad/embed.dart'; import 'package:logging/logging.dart'; void main() { - init(EmbedOptions(EmbedMode.dart)); + init(const EmbedOptions(EmbedMode.dart)); Logger.root.onRecord.listen(print); } diff --git a/pkgs/dart_pad/web/scripts/embed_flutter.dart b/pkgs/dart_pad/web/scripts/embed_flutter.dart index 93776df2e..f7ea17e13 100644 --- a/pkgs/dart_pad/web/scripts/embed_flutter.dart +++ b/pkgs/dart_pad/web/scripts/embed_flutter.dart @@ -6,7 +6,7 @@ import 'package:dart_pad/embed.dart'; import 'package:logging/logging.dart'; void main() { - init(EmbedOptions(EmbedMode.flutter)); + init(const EmbedOptions(EmbedMode.flutter)); Logger.root.onRecord.listen(print); } diff --git a/pkgs/dart_pad/web/scripts/embed_flutter_showcase.dart b/pkgs/dart_pad/web/scripts/embed_flutter_showcase.dart index d119ace69..d2c577d90 100644 --- a/pkgs/dart_pad/web/scripts/embed_flutter_showcase.dart +++ b/pkgs/dart_pad/web/scripts/embed_flutter_showcase.dart @@ -6,7 +6,7 @@ import 'package:dart_pad/embed.dart'; import 'package:logging/logging.dart'; void main() { - init(EmbedOptions(EmbedMode.flutter_showcase)); + init(const EmbedOptions(EmbedMode.flutter_showcase)); Logger.root.onRecord.listen(print); } diff --git a/pkgs/dart_pad/web/scripts/embed_html.dart b/pkgs/dart_pad/web/scripts/embed_html.dart index 78eeec8e9..8f66531b1 100644 --- a/pkgs/dart_pad/web/scripts/embed_html.dart +++ b/pkgs/dart_pad/web/scripts/embed_html.dart @@ -6,7 +6,7 @@ import 'package:dart_pad/embed.dart'; import 'package:logging/logging.dart'; void main() { - init(EmbedOptions(EmbedMode.html)); + init(const EmbedOptions(EmbedMode.html)); Logger.root.onRecord.listen(print); } diff --git a/pkgs/dart_pad/web/scripts/embed_inline.dart b/pkgs/dart_pad/web/scripts/embed_inline.dart index 16e025c2a..9dd64375b 100644 --- a/pkgs/dart_pad/web/scripts/embed_inline.dart +++ b/pkgs/dart_pad/web/scripts/embed_inline.dart @@ -6,7 +6,7 @@ import 'package:dart_pad/embed.dart'; import 'package:logging/logging.dart'; void main() { - init(EmbedOptions(EmbedMode.inline)); + init(const EmbedOptions(EmbedMode.inline)); Logger.root.onRecord.listen(print); } diff --git a/pkgs/dart_services/analysis_options.yaml b/pkgs/dart_services/analysis_options.yaml index 0d392077c..cbbee4c3d 100644 --- a/pkgs/dart_services/analysis_options.yaml +++ b/pkgs/dart_services/analysis_options.yaml @@ -16,4 +16,3 @@ linter: rules: - prefer_final_in_for_each - prefer_final_locals - - prefer_relative_imports diff --git a/pkgs/dart_services/lib/src/github_oauth_handler.dart b/pkgs/dart_services/lib/src/github_oauth_handler.dart index 10c0161cb..99362c607 100644 --- a/pkgs/dart_services/lib/src/github_oauth_handler.dart +++ b/pkgs/dart_services/lib/src/github_oauth_handler.dart @@ -32,11 +32,11 @@ class GitHubOAuthHandler { /// Entry point called from Dart-Pad to initiate a GitHub OAuth Token request. /// NOTE: any change to [entryPointGitHubOAuthInitiate] must also be /// reflected in changing value in dart-pad\lib\github.dart's - /// [GitHubUIController.entryPointGitHubOAuthInitiate] to + /// `GitHubUIController.entryPointGitHubOAuthInitiate` to /// match. static const entryPointGitHubOAuthInitiate = 'github_oauth_initiate'; - /// Entry point specifed to GitHub when setting up OAuth App that GitHub will + /// Entry point specified to GitHub when setting up OAuth App that GitHub will /// redirect to after the OAuth process is completed. This entry point name /// here must also match that used in [_returnToAppUrl] member variable (or /// set using the K_GITHUB_OAUTH_RETURN_TO_APP_URL environmental variable). @@ -53,7 +53,7 @@ class GitHubOAuthHandler { static late final String _authReturnUrl; static late final String _returnToAppUrl; - static final Duration tenMinuteExpiration = Duration(minutes: 10); + static const Duration tenMinuteExpiration = Duration(minutes: 10); /// Adds the GitHub OAuth api end point routes to the passed in Router. static bool addRoutes(Router router) { diff --git a/pkgs/dart_services/pubspec.lock b/pkgs/dart_services/pubspec.lock index 4581474a3..3355d6489 100644 --- a/pkgs/dart_services/pubspec.lock +++ b/pkgs/dart_services/pubspec.lock @@ -213,10 +213,10 @@ packages: dependency: "direct dev" description: name: dart_flutter_team_lints - sha256: e2f4fcafdaf0797e5af1c5c162d0b6c5025e9228ab3f95174340ed35c85dccd6 + sha256: "66517b1f6a53e3275938eece5fe0df6960d1e86a82bad074d7364a9a5c97ae10" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.0.0" dart_style: dependency: transitive description: diff --git a/pkgs/dart_services/pubspec.yaml b/pkgs/dart_services/pubspec.yaml index f53d9f4ce..975dc1e72 100644 --- a/pkgs/dart_services/pubspec.yaml +++ b/pkgs/dart_services/pubspec.yaml @@ -26,7 +26,7 @@ dev_dependencies: angel3_mock_request: ^8.0.0 async: ^2.11.0 build_runner: ^2.4.5 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 grinder: ^0.9.4 package_config: ^2.1.0 shelf_router_generator: ^1.0.6 diff --git a/pkgs/dart_services/test/analysis_server_test.dart b/pkgs/dart_services/test/analysis_server_test.dart index ecc9b7c33..cd77abd49 100644 --- a/pkgs/dart_services/test/analysis_server_test.dart +++ b/pkgs/dart_services/test/analysis_server_test.dart @@ -265,8 +265,10 @@ void defineTests() { test('files={} simple_completion', () async { // Just after `i.` on line 3 of [completionCode] - final results = await analysisServer - .completeFiles({kMainDart: completionCode}, Location(kMainDart, 32)); + final results = await analysisServer.completeFiles( + {kMainDart: completionCode}, + const Location(kMainDart, 32), + ); expect(results.replacementLength, 0); expect(results.replacementOffset, 32); final completions = @@ -290,7 +292,7 @@ void defineTests() { test('files={} repro #126 - completions polluted on second request', () async { final files = {kMainDart: completionFilterCode}; - final location = Location(kMainDart, 17); + final location = const Location(kMainDart, 17); // https://github.com/dart-lang/dart-services/issues/126 return analysisServer.completeFiles(files, location).then((results) { return analysisServer.completeFiles(files, location).then((results) { @@ -307,8 +309,10 @@ void defineTests() { // to enable browsing the file system. final testCode = "import '/'; main() { int a = 0; a. }"; - final results = await analysisServer - .completeFiles({kMainDart: testCode}, Location(kMainDart, 9)); + final results = await analysisServer.completeFiles( + {kMainDart: testCode}, + const Location(kMainDart, 9), + ); final completions = results.completions; if (completions.isNotEmpty) { @@ -322,8 +326,10 @@ void defineTests() { // Ensure we can import dart: imports. final testCode = "import 'dart:c'; main() { int a = 0; a. }"; - final results = await analysisServer - .completeFiles({kMainDart: testCode}, Location(kMainDart, 14)); + final results = await analysisServer.completeFiles( + {kMainDart: testCode}, + const Location(kMainDart, 14), + ); final completions = results.completions; expect( @@ -341,16 +347,19 @@ void defineTests() { test('files={} import_and_other_test', () async { final testCode = "import '/'; main() { int a = 0; a. }"; - final results = await analysisServer - .completeFiles({kMainDart: testCode}, Location(kMainDart, 34)); + final results = await analysisServer.completeFiles( + {kMainDart: testCode}, + const Location(kMainDart, 34), + ); expect(completionsContains(results, 'abs'), true); }); test('files={} myRandomName.dart + simple_quickFix', () async { final results = await analysisServer.getFixesMulti( - {'myRandomName.dart': quickFixesCode}, - Location('myRandomName.dart', 25)); + {'myRandomName.dart': quickFixesCode}, + const Location('myRandomName.dart', 25), + ); expect(results.fixes.length, 2); @@ -390,7 +399,9 @@ void defineTests() { final idx = 61; expect(completionLargeNamespaces.substring(idx - 1, idx), 'A'); final results = await analysisServer.completeFiles( - {kMainDart: completionLargeNamespaces}, Location(kMainDart, 61)); + {kMainDart: completionLargeNamespaces}, + const Location(kMainDart, 61), + ); expect(completionsContains(results, 'A'), true); expect(completionsContains(results, 'AB'), true); expect(completionsContains(results, 'ABC'), true); diff --git a/pkgs/dart_services/test/redis_cache_test.dart b/pkgs/dart_services/test/redis_cache_test.dart index 7f1343d71..edd987a20 100644 --- a/pkgs/dart_services/test/redis_cache_test.dart +++ b/pkgs/dart_services/test/redis_cache_test.dart @@ -93,8 +93,8 @@ void defineTests(bool hasRedis) { await singleTestOnly.synchronized(() async { logMessages = []; await redisCache.set('expiringkey', 'expiringValue', - expiration: Duration(milliseconds: 1)); - await Future.delayed(Duration(milliseconds: 100)); + expiration: const Duration(milliseconds: 1)); + await Future.delayed(const Duration(milliseconds: 100)); await expectLater(await redisCache.get('expiringkey'), isNull); expect(logMessages, isEmpty); }); @@ -149,7 +149,7 @@ void defineTests(bool hasRedis) { try { // Wait for a retry message. while (logMessages.length < 2) { - await Future.delayed(Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); } expect( logMessages.join('\n'), @@ -193,7 +193,9 @@ void defineTests(bool hasRedis) { '(aversion): Connected to redis server', ])); }); - }, onPlatform: {'windows': Skip('Windows does not have sigstop/sigcont')}); + }, onPlatform: { + 'windows': const Skip('Windows does not have sigstop/sigcont'), + }); test( 'Verify cache that starts out connected but breaks retries until reconnection (slow)', diff --git a/pkgs/dart_services/tool/grind.dart b/pkgs/dart_services/tool/grind.dart index 8ddea1d26..8553c6834 100644 --- a/pkgs/dart_services/tool/grind.dart +++ b/pkgs/dart_services/tool/grind.dart @@ -441,7 +441,7 @@ Future _updateDependenciesFile({ final packageVersions = packageVersionsFromPubspecLock(tempDir.path); _pubDependenciesFile(channel: channel).writeAsStringSync( - JsonEncoder.withIndent(' ').convert(packageVersions), + const JsonEncoder.withIndent(' ').convert(packageVersions), ); }