Skip to content

Commit 1705f09

Browse files
committed
Apply dart_flutter_team_lints set
Makes the packages in this repo conformant with the recommended set of lints for packages maintained by the Dart and Flutter teams. This is done in preparation for migrating these packages into the Dart SDK.
1 parent bb5af96 commit 1705f09

File tree

157 files changed

+1320
-1124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+1320
-1124
lines changed

_analysis_config/lib/analysis_options.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# for details. All rights reserved. Use of this source code is governed by a
33
# BSD-style license that can be found in the LICENSE file.
44

5-
include: package:lints/recommended.yaml
5+
include: package:dart_flutter_team_lints/analysis_options.yaml
66

77
analyzer:
8-
# language:
9-
# strict-casts: true
8+
# language:
9+
# strict-casts: true
1010
errors:
1111
dead_code: error
1212
unused_element: error
@@ -55,7 +55,7 @@ dart_code_metrics:
5555
- avoid-collection-methods-with-unrelated-types
5656
# - avoid-double-slash-imports
5757
- avoid-duplicate-exports
58-
# - avoid-dynamic
58+
# - avoid-Object?
5959
# - avoid-global-state # Enable.
6060
# - avoid-ignoring-return-values
6161
# - avoid-late-keyword

_analysis_config/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ environment:
77
sdk: ^3.10.0-0.0.dev
88

99
dependencies:
10-
lints: ^5.0.0
10+
dart_flutter_team_lints: ^3.5.2

dwds/analysis_options.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ analyzer:
66
- "lib/data/*"
77
# Ignore debug extension builds
88
- "debug_extension/compiled/*"
9-
10-
linter:
11-
rules:
12-
- always_use_package_imports

dwds/debug_extension/web/background.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void _registerListeners() {
6161
}
6262

6363
Future<void> _handleRuntimeMessages(
64-
dynamic jsRequest,
64+
Object? jsRequest,
6565
MessageSender sender,
6666
Function sendResponse,
6767
) async {

dwds/debug_extension/web/chrome_api.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class Port {
233233
@JS()
234234
@anonymous
235235
class OnPortMessageHandler {
236-
external void addListener(void Function(dynamic, Port) callback);
236+
external void addListener(void Function(Object?, Port) callback);
237237
}
238238

239239
@JS()
@@ -246,7 +246,7 @@ class ConnectionHandler {
246246
@anonymous
247247
class OnMessageHandler {
248248
external void addListener(
249-
dynamic Function(dynamic, MessageSender, Function) callback,
249+
Object? Function(Object?, MessageSender, Function) callback,
250250
);
251251
}
252252

@@ -307,16 +307,16 @@ class OnChangedHandler {
307307
@JS()
308308
@anonymous
309309
class Tabs {
310-
external dynamic query(
310+
external Object? query(
311311
QueryInfo queryInfo,
312312
void Function(List<Tab>) callback,
313313
);
314314

315-
external dynamic create(TabInfo tabInfo, void Function(Tab) callback);
315+
external Object? create(TabInfo tabInfo, void Function(Tab) callback);
316316

317-
external dynamic get(int tabId, void Function(Tab?) callback);
317+
external Object? get(int tabId, void Function(Tab?) callback);
318318

319-
external dynamic remove(int tabId, void Function()? callback);
319+
external Object? remove(int tabId, void Function()? callback);
320320

321321
external Object sendMessage(
322322
int tabId,
@@ -339,7 +339,7 @@ class OnActivatedHandler {
339339
@JS()
340340
@anonymous
341341
class OnRemovedHandler {
342-
external void addListener(void Function(int tabId, dynamic info) callback);
342+
external void addListener(void Function(int tabId, Object? info) callback);
343343
}
344344

345345
@JS()
@@ -403,7 +403,10 @@ class NavigationInfo {
403403
@JS()
404404
@anonymous
405405
class Windows {
406-
external dynamic create(WindowInfo? createData, Function(WindowObj) callback);
406+
external Object? create(
407+
WindowInfo? createData,
408+
void Function(WindowObj) callback,
409+
);
407410

408411
external OnFocusChangedHandler get onFocusChanged;
409412
}

dwds/debug_extension/web/cider_connection.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ void sendErrorMessageToCider({
9696

9797
void _sendMessageToCider(String json) {
9898
final message = {'key': _ciderDartMessageKey, 'json': json};
99-
_ciderPort!.postMessage(jsify(message));
99+
_ciderPort!.postMessage(jsify(message) as Object);
100100
}
101101

102-
Future<void> _handleMessageFromCider(dynamic message, Port _) async {
103-
final key = getProperty(message, 'key');
104-
final json = getProperty(message, 'json');
102+
Future<void> _handleMessageFromCider(Object? message, Port _) async {
103+
final key = getProperty<String>(message!, 'key');
104+
final json = getProperty<Object?>(message, 'json');
105105
if (key != _ciderDartMessageKey || json is! String) {
106106
sendErrorMessageToCider(
107107
errorType: CiderErrorType.invalidRequest,
@@ -110,7 +110,7 @@ Future<void> _handleMessageFromCider(dynamic message, Port _) async {
110110
return;
111111
}
112112

113-
final decoded = jsonDecode(json) as Map<String, dynamic>;
113+
final decoded = jsonDecode(json) as Map<String, Object?>;
114114
final messageType = decoded['messageType'] as String?;
115115
final messageBody = decoded['messageBody'] as String?;
116116

dwds/debug_extension/web/copier.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ void main() {
2121
}
2222

2323
void _registerListeners() {
24-
chrome.runtime.onMessage.addListener(allowInterop(_handleRuntimeMessages));
24+
chrome.runtime.onMessage.addListener(
25+
allowInterop<void Function(Object?, MessageSender, Function)>(
26+
_handleRuntimeMessages,
27+
),
28+
);
2529
}
2630

2731
void _handleRuntimeMessages(
28-
dynamic jsRequest,
32+
Object? jsRequest,
2933
MessageSender sender,
3034
Function sendResponse,
3135
) {
3236
interceptMessage<String>(
33-
message: jsRequest,
37+
message: jsRequest as String?,
3438
expectedType: MessageType.appId,
3539
expectedSender: Script.background,
3640
expectedRecipient: Script.copier,
3741
sender: sender,
3842
messageHandler: _copyAppId,
3943
);
4044

41-
sendResponse(defaultResponse);
45+
(sendResponse as void Function(Object?))(defaultResponse);
4246
}
4347

4448
void _copyAppId(String appId) {

dwds/debug_extension/web/cross_extension_communication.dart

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ final _eventsForAngularDartDevTools = {
3030
};
3131

3232
Future<void> handleMessagesFromAngularDartDevTools(
33-
dynamic jsRequest,
33+
Object? jsRequest,
3434
// ignore: avoid-unused-parameters
3535
MessageSender sender,
3636
Function sendResponse,
3737
) async {
38+
if (sendResponse is! void Function(Object)) {
39+
throw StateError(
40+
'Unexpected sendResponse signature: ${sendResponse.runtimeType}',
41+
);
42+
}
3843
if (jsRequest == null) return;
3944
final message = jsRequest as ExternalExtensionMessage;
4045
if (message.name == 'chrome.debugger.sendCommand') {
@@ -53,7 +58,7 @@ Future<void> handleMessagesFromAngularDartDevTools(
5358

5459
void maybeForwardMessageToAngularDartDevTools({
5560
required String method,
56-
required dynamic params,
61+
required Object? params,
5762
required int tabId,
5863
}) {
5964
if (!_eventsForAngularDartDevTools.contains(method)) return;
@@ -67,7 +72,7 @@ void maybeForwardMessageToAngularDartDevTools({
6772

6873
void _forwardCommandToChromeDebugger(
6974
ExternalExtensionMessage message,
70-
Function sendResponse,
75+
void Function(Object) sendResponse,
7176
) {
7277
try {
7378
final options = message.options as SendCommandOptions;
@@ -76,15 +81,18 @@ void _forwardCommandToChromeDebugger(
7681
options.method,
7782
options.commandParams,
7883
allowInterop(
79-
([result]) => _respondWithChromeResult(result, sendResponse),
84+
([Object? result]) => _respondWithChromeResult(result, sendResponse),
8085
),
8186
);
8287
} catch (e) {
8388
sendResponse(ErrorResponse()..error = '$e');
8489
}
8590
}
8691

87-
void _respondWithChromeResult(Object? chromeResult, Function sendResponse) {
92+
void _respondWithChromeResult(
93+
Object? chromeResult,
94+
void Function(Object) sendResponse,
95+
) {
8896
// No result indicates that an error occurred.
8997
if (chromeResult == null) {
9098
sendResponse(
@@ -96,7 +104,10 @@ void _respondWithChromeResult(Object? chromeResult, Function sendResponse) {
96104
}
97105
}
98106

99-
Future<void> _respondWithEncodedUri(int tabId, Function sendResponse) async {
107+
Future<void> _respondWithEncodedUri(
108+
int tabId,
109+
void Function(Object) sendResponse,
110+
) async {
100111
final encodedUri = await fetchStorageObject<String>(
101112
type: StorageObject.encodedUri,
102113
tabId: tabId,
@@ -110,7 +121,7 @@ void _forwardMessageToAngularDartDevTools(ExternalExtensionMessage message) {
110121
message,
111122
// options
112123
null,
113-
allowInterop(([result]) => _checkForErrors(result, message.name)),
124+
allowInterop(([Object? result]) => _checkForErrors(result, message.name)),
114125
);
115126
}
116127

@@ -124,7 +135,7 @@ void _checkForErrors(Object? chromeResult, String messageName) {
124135

125136
ExternalExtensionMessage _debugEventMessage({
126137
required String method,
127-
required dynamic params,
138+
required Object? params,
128139
required int tabId,
129140
}) => ExternalExtensionMessage(
130141
name: 'chrome.debugger.event',
@@ -134,7 +145,7 @@ ExternalExtensionMessage _debugEventMessage({
134145

135146
ExternalExtensionMessage _dwdsEventMessage({
136147
required String method,
137-
required dynamic params,
148+
required Object? params,
138149
required int tabId,
139150
}) => ExternalExtensionMessage(name: method, tabId: tabId, options: params);
140151

@@ -145,11 +156,11 @@ ExternalExtensionMessage _dwdsEventMessage({
145156
class ExternalExtensionMessage {
146157
external int get tabId;
147158
external String get name;
148-
external dynamic get options;
159+
external Object? get options;
149160
external factory ExternalExtensionMessage({
150161
required int tabId,
151162
required String name,
152-
required dynamic options,
163+
required Object? options,
153164
});
154165
}
155166

dwds/debug_extension/web/debug_session.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Future<bool> _isDartFrame({required int tabId, required int contextId}) {
320320
returnByValue: true,
321321
contextId: contextId,
322322
),
323-
allowInterop((dynamic response) {
323+
allowInterop((Object? response) {
324324
final evalResponse = response as _EvalResponse;
325325
final value = evalResponse.result.value;
326326
final appId = value?[0];
@@ -449,7 +449,7 @@ void _forwardDwdsEventToChromeDebugger(
449449
Debuggee(tabId: tabId),
450450
message.command,
451451
js_util.jsify(params),
452-
allowInterop(([e]) {
452+
allowInterop(([Object? e]) {
453453
// No arguments indicate that an error occurred.
454454
if (e == null) {
455455
client.sink.add(
@@ -491,7 +491,7 @@ void _forwardDwdsEventToChromeDebugger(
491491
void _forwardChromeDebuggerEventToDwds(
492492
Debuggee source,
493493
String method,
494-
dynamic params,
494+
Object? params,
495495
) {
496496
final debugSession = _debugSessions.firstWhereOrNull(
497497
(session) => session.appTabId == source.tabId,
@@ -736,7 +736,7 @@ DebuggerLocation? _debuggerLocation(int dartAppTabId) {
736736
}
737737

738738
/// Construct an [ExtensionEvent] from [method] and [params].
739-
ExtensionEvent _extensionEventFor(String method, dynamic params) {
739+
ExtensionEvent _extensionEventFor(String method, Object? params) {
740740
return ExtensionEvent(
741741
(b) => b
742742
..params = jsonEncode(json.decode(JSON.stringify(params)))
@@ -783,7 +783,7 @@ class _DebugSession {
783783
required this.trigger,
784784
required void Function(String data) onIncoming,
785785
required void Function() onDone,
786-
required void Function(dynamic error) onError,
786+
required void Function(Object? error) onError,
787787
required bool cancelOnError,
788788
}) : _socketClient = client {
789789
// Collect extension events and send them periodically to the server.

dwds/debug_extension/web/detector.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ void _detectMultipleDartApps() {
8282
}
8383

8484
void _detectMultipleDartAppsCallback(
85-
List<dynamic> mutations,
85+
List<Object?> mutations,
8686
MutationObserver observer,
8787
) {
8888
for (final mutation in mutations) {
89-
if (_isMultipleAppsMutation(mutation)) {
89+
if (_isMultipleAppsMutation(mutation!)) {
9090
_sendMessageToBackgroundScript(
9191
type: MessageType.multipleAppsDetected,
9292
body: 'true',
@@ -96,13 +96,14 @@ void _detectMultipleDartAppsCallback(
9696
}
9797
}
9898

99-
bool _isMultipleAppsMutation(dynamic mutation) {
99+
bool _isMultipleAppsMutation(Object mutation) {
100100
final isAttributeMutation =
101101
hasProperty(mutation, 'type') &&
102-
getProperty(mutation, 'type') == 'attributes';
102+
getProperty<String>(mutation, 'type') == 'attributes';
103103
if (isAttributeMutation) {
104104
return hasProperty(mutation, 'attributeName') &&
105-
getProperty(mutation, 'attributeName') == _multipleAppsAttribute;
105+
getProperty<String>(mutation, 'attributeName') ==
106+
_multipleAppsAttribute;
106107
}
107108
return false;
108109
}

0 commit comments

Comments
 (0)