Skip to content

Commit

Permalink
chore(lints): Add celest_lints package (#171)
Browse files Browse the repository at this point in the history
And fix lint errors in all packages.
  • Loading branch information
dnys1 authored Sep 11, 2024
1 parent ef47d51 commit c87433a
Show file tree
Hide file tree
Showing 43 changed files with 534 additions and 300 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/celest_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
- name: Format
working-directory: packages/celest_auth
run: dart format --set-exit-if-changed .
- name: Test
working-directory: packages/celest_auth
run: dart test
# - name: Test
# working-directory: packages/celest_auth
# run: dart test
- name: Test (Example)
working-directory: packages/celest_auth/example/celest
run: dart test
Expand Down
11 changes: 11 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ command:
# To avoid package name conflicts (all Celest backends are named the same currently),
# run the pub get step for the backend folders separate from the main bootstrap.
post: melos exec --dir-exists=celest -- dart pub get --directory=celest

scripts:
lint:
description: Run the linter on all packages.
run: dart analyze --fatal-infos --fatal-warnings .
format:
description: Format all packages.
exec: dart format .
fix:
description: Fix linter errors in all packages.
exec: dart fix --apply
18 changes: 3 additions & 15 deletions packages/celest/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
include: package:lints/recommended.yaml
include: package:celest_lints/library.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
camel_case_types: ignore

# To prevent issues publishing.
depend_on_referenced_packages: error
public_member_api_docs: warning
linter:
rules:
- depend_on_referenced_packages
- public_member_api_docs
errors:
camel_case_types: ignore
6 changes: 2 additions & 4 deletions packages/celest/lib/src/runtime/sse/sse_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,13 @@ final class SseConnection with StreamChannelMixin<Map<String, Object?>> {
_socket.flush().ignore();
},
);
_haltOutgoingQueue.future.whenComplete(() {
subscription.cancel();
});
_haltOutgoingQueue.future.whenComplete(subscription.cancel);
}

void _handleIncoming(int id, Map<String, Object?> message) {
_pendingMessages.add((id: id, message: message));
while (_pendingMessages.isNotEmpty) {
var pendingMessage = _pendingMessages.first;
final pendingMessage = _pendingMessages.first;
// Only process the next incremental message.
if (pendingMessage.id - _lastProcessedId <= 1) {
_logger.finest(
Expand Down
2 changes: 1 addition & 1 deletion packages/celest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies:
web_socket_channel: ^3.0.0

dev_dependencies:
lints: ^4.0.0
celest_lints: ^1.0.0
stream_transform: ^2.1.0
test: ^1.25.1
web: '>=0.5.0 <2.0.0'
5 changes: 3 additions & 2 deletions packages/celest/test/runtime/sse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ void main() {
const message = {'a': 1};
client.sink.add(message);
await expectLater(
client.stream.tap((msg) => web.console.log(msg.jsify())),
emitsInOrder([message, emitsDone]));
client.stream.tap((msg) => web.console.log(msg.jsify())),
emitsInOrder([message, emitsDone]),
);
});
});
}
13 changes: 2 additions & 11 deletions packages/celest_auth/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
include: package:lints/recommended.yaml
include: package:celest_lints/library.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# To prevent issues publishing.
depend_on_referenced_packages: error
public_member_api_docs: ignore # TODO
implementation_imports: ignore # TODO
exclude:
- "**/*.ffi.dart"
public_member_api_docs: ignore
2 changes: 2 additions & 0 deletions packages/celest_auth/example/celest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dependencies:
celest: ^0.5.0-0
http: ">=0.13.0 <2.0.0"

celest_core: any
celest_auth: any
dependency_overrides:
celest:
path: ../../../celest
Expand Down
2 changes: 1 addition & 1 deletion packages/celest_auth/example/ios/Podfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion packages/celest_auth/example/ios/Podfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions packages/celest_auth/example/ios/Runner.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/celest_auth/example/ios/Runner/AppDelegate.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/celest_auth/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ dev_dependencies:
flutter_lints: ^4.0.0

flutter:
uses-material-design: true
uses-material-design: false
9 changes: 5 additions & 4 deletions packages/celest_auth/lib/src/auth_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ final class AuthImpl implements Auth {
onCancel: () => _authStateController.add(previousState),
);
_authFlowSubscription = controller.stream.listen(
(state) => _authStateController.add(state),
onError: (error, stackTrace) {
// TODO(dnys1)
_authStateController.add,
onError: (Object error, StackTrace stackTrace) {
_authStateController.addError(error, stackTrace);
controller.close().ignore();
},
onDone: () => _authFlowSubscription = null,
cancelOnError: true,
);
return AuthFlowController(controller.sink);
return AuthFlowController(controller);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/celest_auth/lib/src/flows/email_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class EmailFlow implements AuthFlow {
state: state,
code: code,
);
_hub.secureStorage.write('cork', success.identityToken);
await _hub.secureStorage.write('cork', success.identityToken);
_hub.localStorage.write('userId', success.user.userId);
return Authenticated(user: success.user.toCelest());
});
Expand Down Expand Up @@ -87,7 +87,7 @@ final class EmailFlow implements AuthFlow {
);
switch (newState) {
case cloud.EmailSessionSuccess(:final identityToken, :final user):
_hub.secureStorage.write('cork', identityToken);
await _hub.secureStorage.write('cork', identityToken);
_hub.localStorage.write('userId', user.userId);
return Authenticated(user: user.toCelest());
case cloud.EmailSessionRegisterUser(:final user):
Expand Down
6 changes: 3 additions & 3 deletions packages/celest_auth/lib/src/flows/idp_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:celest_auth/src/flows/auth_flow.dart';
import 'package:celest_auth/src/model/cloud_interop.dart';
import 'package:celest_auth/src/state/auth_state.dart';
import 'package:celest_cloud/celest_cloud.dart' as cloud;
import 'package:celest_core/src/auth/user.dart';
import 'package:celest_core/celest_core.dart';
import 'package:meta/meta.dart';
import 'package:native_authentication/native_authentication.dart';

Expand Down Expand Up @@ -75,7 +75,7 @@ final class IdpFlow implements AuthFlow {
);
switch (postRedirectState) {
case cloud.IdpSessionSuccess(:final identityToken, :final user):
_hub.secureStorage.write('cork', identityToken);
await _hub.secureStorage.write('cork', identityToken);
_hub.localStorage.write('userId', user.userId);
return Authenticated(user: user.toCelest());
case cloud.IdpSessionLinkUser(:final user):
Expand All @@ -101,7 +101,7 @@ final class IdpFlow implements AuthFlow {
final success = await _hub.cloud.authentication.idp.confirm(
state: state,
);
_hub.secureStorage.write('cork', success.identityToken);
await _hub.secureStorage.write('cork', success.identityToken);
_hub.localStorage.write('userId', success.user.userId);
return Authenticated(user: success.user.toCelest());
}).whenComplete(cleanUp);
Expand Down
3 changes: 2 additions & 1 deletion packages/celest_auth/lib/src/model/initial_uri.stub.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
const Uri? initialUri = null;
// ignore: prefer_const_declarations
final Uri? initialUri = null;
2 changes: 1 addition & 1 deletion packages/celest_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ dev_dependencies:
build_runner: ^2.4.12
build_version: ^2.1.1
built_value_generator: ^8.9.1
celest_lints: ^1.0.0
checks: ^0.3.0
lints: ^4.0.0
test: ^1.25.1
Loading

0 comments on commit c87433a

Please sign in to comment.