mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
Enable strict inference
This commit is contained in:
parent
1340ba7b8a
commit
79e9bbd816
@ -1,6 +1,8 @@
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
language:
|
||||
strict-inference: true
|
||||
errors:
|
||||
missing_js_lib_annotation: ignore
|
||||
deprecated_member_use_from_same_package: ignore
|
||||
|
@ -184,7 +184,7 @@ class NodeImporter {
|
||||
/// Calls an importer that may or may not be asynchronous.
|
||||
Future<Object> _callImporterAsync(
|
||||
JSFunction importer, String url, String previousString) async {
|
||||
var completer = Completer();
|
||||
var completer = Completer<Object>();
|
||||
|
||||
var result = call3(importer, _context, url, previousString,
|
||||
allowInterop(completer.complete));
|
||||
|
@ -225,7 +225,7 @@ List<AsyncCallable> _parseFunctions(RenderOptions options,
|
||||
} else {
|
||||
result.add(AsyncBuiltInCallable.parsed(tuple.item1, tuple.item2,
|
||||
(arguments) async {
|
||||
var completer = Completer();
|
||||
var completer = Completer<Object>();
|
||||
var jsArguments = [
|
||||
...arguments.map(wrapValue),
|
||||
allowInterop(([result]) => completer.complete(result))
|
||||
|
@ -165,11 +165,18 @@ int codeUnitIndexToCodepointIndex(String string, int codeUnitIndex) {
|
||||
}
|
||||
|
||||
/// Returns whether [list1] and [list2] have the same contents.
|
||||
bool listEquals<T>(List<T> list1, List<T> list2) =>
|
||||
const ListEquality().equals(list1, list2);
|
||||
bool listEquals(List list1, List list2) =>
|
||||
const ListEquality<Object>().equals(list1, list2);
|
||||
|
||||
/// Returns a hash code for [list] that matches [listEquals].
|
||||
int listHash(List list) => const ListEquality().hash(list);
|
||||
int listHash(List list) => const ListEquality<Object>().hash(list);
|
||||
|
||||
/// Returns whether [map1] and [map2] have the same contents.
|
||||
bool mapEquals(Map map1, Map map2) =>
|
||||
const MapEquality<Object, Object>().equals(map1, map2);
|
||||
|
||||
/// Returns a hash code for [map] that matches [mapEquals].
|
||||
int mapHash(Map map) => const MapEquality<Object, Object>().hash(map);
|
||||
|
||||
/// Returns a stack frame for the given [span] with the given [member] name.
|
||||
///
|
||||
|
@ -2,10 +2,9 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import '../visitor/interface/value.dart';
|
||||
import '../value.dart';
|
||||
import '../utils.dart';
|
||||
import 'external/value.dart' as ext;
|
||||
|
||||
class SassMap extends Value implements ext.SassMap {
|
||||
@ -33,11 +32,9 @@ class SassMap extends Value implements ext.SassMap {
|
||||
SassMap assertMap([String name]) => this;
|
||||
|
||||
bool operator ==(other) =>
|
||||
(other is SassMap &&
|
||||
const MapEquality().equals(other.contents, contents)) ||
|
||||
(other is SassMap && mapEquals(other.contents, contents)) ||
|
||||
(contents.isEmpty && other is SassList && other.asList.isEmpty);
|
||||
|
||||
int get hashCode => contents.isEmpty
|
||||
? const SassList.empty().hashCode
|
||||
: const MapEquality().hash(contents);
|
||||
int get hashCode =>
|
||||
contents.isEmpty ? const SassList.empty().hashCode : mapHash(contents);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(callConstructor(sass.types.Number, [1]));
|
||||
});
|
||||
})
|
||||
@ -210,7 +210,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(JSError("aw beans"));
|
||||
});
|
||||
})
|
||||
@ -223,7 +223,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(callConstructor(sass.types.Error, ["aw beans"]));
|
||||
});
|
||||
})
|
||||
@ -236,7 +236,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(null);
|
||||
});
|
||||
})
|
||||
@ -249,7 +249,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done();
|
||||
});
|
||||
})
|
||||
@ -291,7 +291,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(callConstructor(sass.types.Number, [1]));
|
||||
});
|
||||
})
|
||||
@ -313,7 +313,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(JSError("aw beans"));
|
||||
});
|
||||
})
|
||||
@ -327,7 +327,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(null);
|
||||
});
|
||||
})
|
||||
@ -341,7 +341,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
@ -589,7 +589,7 @@ void main() {
|
||||
render(RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(NodeImporterResult(contents: 'a {b: c}'));
|
||||
});
|
||||
}))),
|
||||
@ -601,7 +601,7 @@ void main() {
|
||||
renderError(RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(JSError('oh no'));
|
||||
});
|
||||
}))),
|
||||
@ -651,7 +651,7 @@ void main() {
|
||||
render(RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(NodeImporterResult(contents: 'a {b: c}'));
|
||||
});
|
||||
}),
|
||||
@ -686,7 +686,7 @@ void main() {
|
||||
renderError(RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
Future.delayed(Duration.zero).then((_) {
|
||||
Timer(Duration.zero, () {
|
||||
done(JSError('oh no'));
|
||||
});
|
||||
}),
|
||||
|
@ -14,7 +14,7 @@ import 'utils.dart';
|
||||
|
||||
void main() {
|
||||
group("from a parameter", () {
|
||||
var value;
|
||||
Object value;
|
||||
setUp(() {
|
||||
value = parseValue("null");
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ npmReleasePackage() => _npm(release: true);
|
||||
void _npm({@required bool release}) {
|
||||
var json = {
|
||||
...(jsonDecode(File('package/package.json').readAsStringSync())
|
||||
as Map<String, dynamic>),
|
||||
as Map<String, Object>),
|
||||
"version": version
|
||||
};
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
|
||||
import 'package:sass/src/utils.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
@Task('Verify that the package is in a good state to release.')
|
||||
@ -17,7 +18,7 @@ sanityCheckBeforeRelease() {
|
||||
fail("TRAVIS_TAG $travisTag is different than pubspec version $version.");
|
||||
}
|
||||
|
||||
if (const ListEquality().equals(Version.parse(version).preRelease, ["dev"])) {
|
||||
if (listEquals(Version.parse(version).preRelease, ["dev"])) {
|
||||
fail("$version is a dev release.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user