Skip to content

Commit 1ef1d1c

Browse files
authored
Migrate to dart_flutter_team_lints v2.1 (dart-archive/watcher#153)
- Fix new lints. - Deduplicate lints in local config. - Add some missing generic types on futures and stream controllers. - Fix a typo in a test. - Remove unnecessary library names.
1 parent bffc449 commit 1ef1d1c

File tree

21 files changed

+41
-47
lines changed

21 files changed

+41
-47
lines changed

pkgs/watcher/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 1.1.1-wip
2+
13
## 1.1.0
24

35
- Require Dart SDK >= 3.0.0

pkgs/watcher/analysis_options.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
11
include: package:dart_flutter_team_lints/analysis_options.yaml
2-
3-
analyzer:
4-
language:
5-
strict-casts: true
6-
7-
linter:
8-
rules:
9-
- comment_references # https://github.com/dart-lang/sdk/issues/39467
10-

pkgs/watcher/benchmark/path_set.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// Benchmarks for the PathSet class.
6-
library watcher.benchmark.path_set;
6+
library;
77

88
import 'dart:io';
99
import 'dart:math' as math;

pkgs/watcher/example/watch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// Watches the given directory and prints each modification to it.
6-
library watch;
6+
library;
77

88
import 'package:path/path.dart' as p;
99
import 'package:watcher/watcher.dart';

pkgs/watcher/lib/src/directory_watcher/linux.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class _LinuxDirectoryWatcher
4747
bool get isReady => _readyCompleter.isCompleted;
4848

4949
@override
50-
Future get ready => _readyCompleter.future;
51-
final _readyCompleter = Completer();
50+
Future<void> get ready => _readyCompleter.future;
51+
final _readyCompleter = Completer<void>();
5252

5353
/// A stream group for the [Directory.watch] events of [path] and all its
5454
/// subdirectories.
@@ -284,7 +284,7 @@ class _LinuxDirectoryWatcher
284284
{Function? onError,
285285
void Function()? onDone,
286286
bool cancelOnError = false}) {
287-
late StreamSubscription subscription;
287+
late StreamSubscription<T> subscription;
288288
subscription = stream.listen(onData, onError: onError, onDone: () {
289289
_subscriptions.remove(subscription);
290290
onDone?.call();

pkgs/watcher/lib/src/directory_watcher/mac_os.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class _MacOSDirectoryWatcher
4747
bool get isReady => _readyCompleter.isCompleted;
4848

4949
@override
50-
Future get ready => _readyCompleter.future;
51-
final _readyCompleter = Completer();
50+
Future<void> get ready => _readyCompleter.future;
51+
final _readyCompleter = Completer<void>();
5252

5353
/// The set of files that are known to exist recursively within the watched
5454
/// directory.
@@ -367,12 +367,12 @@ class _MacOSDirectoryWatcher
367367

368368
/// Starts or restarts listing the watched directory to get an initial picture
369369
/// of its state.
370-
Future _listDir() {
370+
Future<void> _listDir() {
371371
assert(!isReady);
372372
_initialListSubscription?.cancel();
373373

374374
_files.clear();
375-
var completer = Completer();
375+
var completer = Completer<void>();
376376
var stream = Directory(path).list(recursive: true);
377377
_initialListSubscription = stream.listen((entity) {
378378
if (entity is! Directory) _files.add(entity.path);
@@ -385,9 +385,10 @@ class _MacOSDirectoryWatcher
385385
/// 200ms is short in terms of human interaction, but longer than any Mac OS
386386
/// watcher tests take on the bots, so it should be safe to assume that any
387387
/// bogus events will be signaled in that time frame.
388-
Future _waitForBogusEvents() {
389-
var completer = Completer();
390-
_bogusEventTimer = Timer(Duration(milliseconds: 200), completer.complete);
388+
Future<void> _waitForBogusEvents() {
389+
var completer = Completer<void>();
390+
_bogusEventTimer =
391+
Timer(const Duration(milliseconds: 200), completer.complete);
391392
return completer.future;
392393
}
393394

pkgs/watcher/lib/src/directory_watcher/polling.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class PollingDirectoryWatcher extends ResubscribableWatcher
2727
PollingDirectoryWatcher(String directory, {Duration? pollingDelay})
2828
: super(directory, () {
2929
return _PollingDirectoryWatcher(
30-
directory, pollingDelay ?? Duration(seconds: 1));
30+
directory, pollingDelay ?? const Duration(seconds: 1));
3131
});
3232
}
3333

@@ -184,7 +184,7 @@ class _PollingDirectoryWatcher
184184
if (!isReady) _readyCompleter.complete();
185185

186186
// Wait and then poll again.
187-
await Future.delayed(_pollingDelay);
187+
await Future<void>.delayed(_pollingDelay);
188188
if (_events.isClosed) return;
189189
_poll();
190190
}

pkgs/watcher/lib/src/directory_watcher/windows.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class _WindowsDirectoryWatcher
5656

5757
@override
5858
Future<void> get ready => _readyCompleter.future;
59-
final _readyCompleter = Completer();
59+
final _readyCompleter = Completer<void>();
6060

6161
final Map<String, _EventBatcher> _eventBatchers =
6262
HashMap<String, _EventBatcher>();
@@ -407,7 +407,7 @@ class _WindowsDirectoryWatcher
407407
_initialListSubscription?.cancel();
408408

409409
_files.clear();
410-
var completer = Completer();
410+
var completer = Completer<void>();
411411
var stream = Directory(path).list(recursive: true);
412412
void handleEntity(FileSystemEntity entity) {
413413
if (entity is! Directory) _files.add(entity.path);

pkgs/watcher/lib/src/file_watcher/native.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class _NativeFileWatcher implements FileWatcher, ManuallyClosedWatcher {
3030
bool get isReady => _readyCompleter.isCompleted;
3131

3232
@override
33-
Future get ready => _readyCompleter.future;
34-
final _readyCompleter = Completer();
33+
Future<void> get ready => _readyCompleter.future;
34+
final _readyCompleter = Completer<void>();
3535

36-
StreamSubscription? _subscription;
36+
StreamSubscription<List<FileSystemEvent>>? _subscription;
3737

3838
_NativeFileWatcher(this.path) {
3939
_listen();

pkgs/watcher/lib/src/file_watcher/polling.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PollingFileWatcher extends ResubscribableWatcher implements FileWatcher {
1515
PollingFileWatcher(String path, {Duration? pollingDelay})
1616
: super(path, () {
1717
return _PollingFileWatcher(
18-
path, pollingDelay ?? Duration(seconds: 1));
18+
path, pollingDelay ?? const Duration(seconds: 1));
1919
});
2020
}
2121

@@ -31,8 +31,8 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
3131
bool get isReady => _readyCompleter.isCompleted;
3232

3333
@override
34-
Future get ready => _readyCompleter.future;
35-
final _readyCompleter = Completer();
34+
Future<void> get ready => _readyCompleter.future;
35+
final _readyCompleter = Completer<void>();
3636

3737
/// The timer that controls polling.
3838
late final Timer _timer;
@@ -49,7 +49,7 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
4949
}
5050

5151
/// Checks the mtime of the file and whether it's been removed.
52-
Future _poll() async {
52+
Future<void> _poll() async {
5353
// We don't mark the file as removed if this is the first poll (indicated by
5454
// [_lastModified] being null). Instead, below we forward the dart:io error
5555
// that comes from trying to read the mtime below.

0 commit comments

Comments
 (0)