Comments (12)
I like the extension idea, but maybe not in this package (why not in core or meta). I have to add pedantic as a regular dependency just for some unawaited calls (that I sometimes remove to use ignore comment instead to avoid this dependency). I'd rather have this package without code so I can use it as a dev_dependency.
from pedantic.
Agreed, that's why we tried to move unawaited
to package:meta
, but we failed.
The extension might have better luck.
from pedantic.
I can also not see any issues with adding this to package:meta
(and the recommending it over unawaited
from package:pedantic
). That said, I also saw no issue with moving the unawaited
future top package meta to begin with.
There should not be any conflict unless someone already defined another extension on Future
with name unawaited
(unlikely) and you need to use both of them in the same library (compounding the unlikeliness) and you are not willing to invoke them explicitly.
Are we allowed to ignore FutureOr
now. I can see that unawaited
takes a Future?
as argument. Not sure why accepting one union type and not the other, so should it take FutureOr?
as well?
An alternative name could be .ignore
(but that should probably also catch and ignore errors).
from pedantic.
I like it--and it doesn't pollute the top level namespace like the current unawaited
.
But we've learned to be very careful with changes to this package :/ as so much depends on it. I think if we add such an extension it would break someone who already has the same extension?
from pedantic.
I think if we add such an extension it would break someone who already has the same extension?
It should be ok as long as no other extension defines a unawaited
member on Future.
//---------- pedantic.dart
extension FutureExt<T> on Future<T> {
void get unawaited {}
}
//---------- a.dart
extension FutureExt<T> on Future<T> {
void get a {}
}
//----------- main.dart
import 'a.dart';
import 'pedantic.dart';
main() {
var future = Future<void>.value();
future.unawaited; // OK - extension from pedantic.dart
future.a; // OK - extension from a.dart
future.b; // extension from current lib
}
extension FutureExt<T> on Future<T> {
void get b {}
// void unawaited() {} // error if this unawaited is also defined hehe
}
void unawaited() {} // OK
@lrhn : do you see a potential breaking issue about this addition?
from pedantic.
That is much like what broke when we tried moving unawaited
to package:meta
; package:test
had defined its own unawaited
, and so we broke package:test
and most of the world.
We don't have a good way to check for such breakage in important packages.
from pedantic.
no, no breakage if an unawaited
member is defined in main.dart
(I updated the above code). The breakage only occurs if unawaited
is also defined in an extension of Future
(that is really more unlikely)
from pedantic.
Right. I mean someone might define the exact same extension, for exactly the same reason :)
I can search google3 code, nobody has done it there yet :) so we're probably safe on core packages.
from pedantic.
@davidmorgan feel free to move this issue to the appropriate issue tracker if it can land in meta
.
from pedantic.
I can also create a PR on meta!
from pedantic.
:D please go ahead with a PR/issue for package:meta, let's keep this one here too since it relates to effectively deprecating the code part of this package.
from pedantic.
PR submitted at dart-lang/sdk#45284
from pedantic.
Related Issues (20)
- Rephrase README - the lints reach outside the scope of effective Dart HOT 1
- Tag the v1.9.0 release HOT 2
- Ignore rules in yaml config HOT 4
- Omit type annotations for local variables make code harder to understand. HOT 49
- Unable to use 1.9.0 on Flutter stable 1.12.13+hotfix.5 HOT 7
- prefer_single_quotes needs an automatic fix HOT 5
- Getting dart analyses warning for auto generated file HOT 3
- Omit type annotation for local variable lint warning is only shown in certain situation. HOT 20
- Don't allow `as` to be used in casting, it does more harm than good. HOT 2
- 'flutter pub get' fails for pedantic 1.9.1 HOT 4
- Re-add back the definition of `unawaited` to this package
- Invalid include_file_not_found when pedantic added to dev_dependencies HOT 5
- What does "does not reflect common usage" mean? HOT 4
- Exclude option doesn't work HOT 1
- Feature request: find hardcoded strings HOT 1
- Remove unsafe_html HOT 2
- Show lint warning when a late marked field is final and initialized when declaring. HOT 3
- sort_constructors_first gives false positives for factories HOT 2
- Provide an options file which includes `package:lints/recommended.yaml` HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pedantic.