Skip to content

Commit

Permalink
Added pedantic to node_interop
Browse files Browse the repository at this point in the history
  • Loading branch information
pulyaevskiy committed Sep 14, 2019
1 parent c1deb1f commit 9c05d66
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 41 deletions.
14 changes: 2 additions & 12 deletions node_interop/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
include: package:pedantic/analysis_options.yaml

analyzer:
exclude:
- build/**

# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
linter:
rules:
- cancel_subscriptions
- close_sinks
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- test_types_in_equals
- unrelated_type_equality_checks
- valid_regexps
2 changes: 1 addition & 1 deletion node_interop/example/console_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
}

Writable createPrintStream() {
return createWritable(new WritableOptions(
return createWritable(WritableOptions(
decodeStrings: false,
write: allowInterop((String chunk, encoding, Function callback) {
// Removes extra line-break added by `console.log`.
Expand Down
2 changes: 1 addition & 1 deletion node_interop/example/fs_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import 'package:node_interop/node.dart';
/// printing out as nicely indented JSON.
void main() {
final contents = List<String>.from(fs.readdirSync(process.cwd()));
final json = new JsonEncoder.withIndent(' ');
final json = JsonEncoder.withIndent(' ');
print(json.convert(contents));
}
2 changes: 1 addition & 1 deletion node_interop/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import 'package:node_interop/node.dart';
/// printing out as nicely indented JSON.
void main() {
final contents = List<String>.from(fs.readdirSync(process.cwd()));
final json = new JsonEncoder.withIndent(' ');
final json = JsonEncoder.withIndent(' ');
print(json.convert(contents));
}
8 changes: 4 additions & 4 deletions node_interop/example/stream_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import 'package:node_interop/stream.dart';
/// (string "Hello world") is sent as a result of a [Future] and printed
/// to stdout.
void main() {
var buffer = new StringBuffer();
var buffer = StringBuffer();
var readable = createStringReadStream();
var writable = createStringBufferStream(buffer);
var completer = new Completer<String>();
var completer = Completer<String>();

readable.pipe(writable).on('finish', allowInterop(() {
completer.complete(buffer.toString());
Expand All @@ -25,7 +25,7 @@ void main() {
}

Readable createStringReadStream() {
return createReadable(new ReadableOptions(
return createReadable(ReadableOptions(
encoding: 'utf8',
read: allowInteropCaptureThis((Readable obj, int size) {
obj.push('Hello world');
Expand All @@ -34,7 +34,7 @@ Readable createStringReadStream() {
}

Writable createStringBufferStream(StringBuffer buffer) {
return createWritable(new WritableOptions(
return createWritable(WritableOptions(
decodeStrings: false,
write: allowInterop((String chunk, encoding, Function callback) {
buffer.write(chunk);
Expand Down
4 changes: 2 additions & 2 deletions node_interop/lib/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ abstract class ServerResponse implements Writable {
external void setTimeout(num msecs, [callback]);
external Socket get socket;
external num get statusCode;
external void set statusCode(num value);
external set statusCode(num value);
external String get statusMessage;
external void set statusMessage(String value);
external set statusMessage(String value);
@override
external bool write(chunk, [encodingOrCallback, void callback()]);
external void writeContinue();
Expand Down
6 changes: 3 additions & 3 deletions node_interop/lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ T dartify<T>(Object jsObject) {
}

var keys = objectKeys(jsObject);
var result = new Map<String, dynamic>();
var result = Map<String, dynamic>();
for (var key in keys) {
result[key] = dartify(js_util.getProperty(jsObject, key));
}
Expand Down Expand Up @@ -91,7 +91,7 @@ bool _isBasicType(value) {
/// See also:
/// - [futureToPromise]
Future<T> promiseToFuture<T>(Promise promise) {
var completer = new Completer<T>.sync();
var completer = Completer<T>.sync();
promise.then(allowInterop((value) {
completer.complete(value);
}), allowInterop((error) {
Expand All @@ -105,7 +105,7 @@ Future<T> promiseToFuture<T>(Promise promise) {
/// See also:
/// - [promiseToFuture]
Promise futureToPromise<T>(Future<T> future) {
return new Promise(allowInterop((Function resolve, Function reject) {
return Promise(allowInterop((Function resolve, Function reject) {
future.then(resolve, onError: reject);
}));
}
3 changes: 2 additions & 1 deletion node_interop/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ homepage: https://github.com/pulyaevskiy/node-interop
author: Anatoly Pulyaevskiy <[email protected]>

environment:
sdk: '>=2.0.0-dev <3.0.0'
sdk: '>=2.0.0 <3.0.0'

dependencies:
js: ^0.6.1

dev_dependencies:
pedantic: ^1.0.0
test: ^1.0.0
build_runner: ^1.0.0
build_node_compilers: ^0.2.0
Expand Down
6 changes: 3 additions & 3 deletions node_interop/test/buffer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ void main() {

test('keys()', () {
final buffer = Buffer.from([1, 2, 3]);
expect(new List.from(buffer.keys()), [0, 1, 2]);
expect(List.from(buffer.keys()), [0, 1, 2]);
}, skip: 'Broken in dart2js');

test('values()', () {
final buffer = Buffer.from([1, 2, 3]);
expect(new List.from(buffer.values()), [1, 2, 3]);
expect(List.from(buffer.values()), [1, 2, 3]);
}, skip: 'Broken in dart2js');

test('entries()', () {
final buffer = Buffer.from([1, 2, 3]);
expect(new List.from(buffer.entries()), [
expect(List.from(buffer.entries()), [
[0, 1],
[1, 2],
[2, 3]
Expand Down
4 changes: 2 additions & 2 deletions node_interop/test/child_process_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import 'package:test/test.dart';
void main() {
group('child_process', () {
test('exec successful', () {
Completer<int> completer = new Completer<int>();
childProcess.exec('ls -la', new ExecOptions(),
Completer<int> completer = Completer<int>();
childProcess.exec('ls -la', ExecOptions(),
allowInterop((error, stdout, stderr) {
int result = (error == null) ? 0 : error.code;
completer.complete(result);
Expand Down
2 changes: 1 addition & 1 deletion node_interop/test/console_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
}

Writable createPrintStream() {
return createWritable(new WritableOptions(
return createWritable(WritableOptions(
decodeStrings: false,
write: allowInterop((String chunk, encoding, Function callback) {
print(chunk.replaceFirst('\n', ''));
Expand Down
8 changes: 4 additions & 4 deletions node_interop/test/promises_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ void main() {

test('futureToPromise', () {
final JsPromises js = require(promises);
var future = new Future.value('Yes');
var future = Future.value('Yes');
var promise = futureToPromise(future);
var promise2 = js.receivePromise(promise);
expect(promiseToFuture(promise2), completion('YesYesYes'));
});

test('create promise in Dart', () {
final JsPromises js = require(promises);
var promise = new Promise(allowInterop((resolve, reject) {
var promise = Promise(allowInterop((resolve, reject) {
resolve('Yas');
}));
var promise2 = js.receivePromise(promise);
expect(promiseToFuture(promise2), completion('YasYasYas'));
});

test('reject a Promise', () {
var promise = new Promise(allowInterop((resolve, reject) {
var promise = Promise(allowInterop((resolve, reject) {
reject('No');
}));
expect(promiseToFuture(promise), throwsA('No'));
});

test('reject a Future', () {
final JsPromises js = require(promises);
var future = new Future.error('No');
var future = Future.error('No');
var promise = futureToPromise(future);
var promise2 = js.receivePromise(promise);
expect(promiseToFuture(promise2), throwsA('NoNoNo'));
Expand Down
8 changes: 4 additions & 4 deletions node_interop/test/stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import 'package:test/test.dart';
void main() {
group('stream', () {
test('integration', () async {
var b = new StringBuffer();
var b = StringBuffer();
var r = createStringReadStream();
var w = createStringBufferStream(b);
var completer = new Completer<String>();
var completer = Completer<String>();

r.pipe(w).on('finish', allowInterop(() {
completer.complete(b.toString());
Expand All @@ -25,7 +25,7 @@ void main() {
}

Readable createStringReadStream() {
return createReadable(new ReadableOptions(
return createReadable(ReadableOptions(
encoding: 'utf8',
read: allowInteropCaptureThis((Readable obj, int size) {
obj.push('Hello world');
Expand All @@ -34,7 +34,7 @@ Readable createStringReadStream() {
}

Writable createStringBufferStream(StringBuffer buffer) {
return createWritable(new WritableOptions(
return createWritable(WritableOptions(
decodeStrings: false,
write: allowInterop((String chunk, encoding, Function callback) {
buffer.write(chunk);
Expand Down
4 changes: 2 additions & 2 deletions node_interop/test/timers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:test/test.dart';
void main() {
group('Timers', () {
test('setImmediate', () async {
StringBuffer buffer = new StringBuffer();
StringBuffer buffer = StringBuffer();

writesToBuffer(StringBuffer buffer) async {
buffer.writeln('before');
Expand All @@ -26,7 +26,7 @@ void main() {
}

Future setImmediateFuture(StringBuffer buffer) {
final Completer<String> completer = new Completer();
final Completer<String> completer = Completer();
setImmediate(allowInterop((StringBuffer value) {
value.writeln('hello world');
completer.complete();
Expand Down

0 comments on commit 9c05d66

Please sign in to comment.