Contribute to Open Source. Search issue labels to find the right project for you!

Flow type definition fails with latest `flow-bin`

avajs/ava

When updating to flow-bin 0.48.0 our type definition test started failing:

> flow check test/flow-types

test/flow-types/regression-1114.js.flow:41
 41: test('2 + 2 === 4', macro, '2 + 2', 4);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150:    (              run: ContextualTest): void;
151:    (name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150:  (              run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   41: test('2 + 2 === 4', macro, '2 + 2', 4);
            ^^^^^^^^^^^^^ string. This type is incompatible with
  150:  (              run: ContextualTest): void;
                            ^^^^^^^^^^^^^^ union: type application of polymorphic type: type `TestFunction` | array type. See: index.js.flow:150
    Member 1:
    100:    | TestFunction<T, R>
              ^^^^^^^^^^^^^^^^^^ type application of polymorphic type: type `TestFunction`. See: index.js.flow:100
    Error:
     41: test('2 + 2 === 4', macro, '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    100:    | TestFunction<T, R>
              ^^^^^^^^^^^^^^^^^^ object type. See: index.js.flow:100
    Member 2:
    101:    | Array<TestFunction<T, R>>;
              ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
    Error:
     41: test('2 + 2 === 4', macro, '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    101:    | Array<TestFunction<T, R>>;
              ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
  Member 2:
  151:  (name: string, run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   41: test('2 + 2 === 4', macro, '2 + 2', 4);
                                  ^^^^^^^ unused function argument
    151:    (name: string, run: ContextualTest): void;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 2 arguments. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:42
 42: test(macro, '2 * 3', 6);
     ^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150:    (              run: ContextualTest): void;
151:    (name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150:  (              run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   42: test(macro, '2 * 3', 6);
                   ^^^^^^^ unused function argument
    150:    (              run: ContextualTest): void;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 1 argument. See: index.js.flow:150
  Member 2:
  151:  (name: string, run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   42: test(macro, '2 * 3', 6);
            ^^^^^ function. This type is incompatible with the expected param type of
  151:  (name: string, run: ContextualTest): void;
               ^^^^^^ string. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:44
 44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150:    (              run: ContextualTest): void;
151:    (name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150:  (              run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
            ^^^^^^^^^^^^^ string. This type is incompatible with
  150:  (              run: ContextualTest): void;
                            ^^^^^^^^^^^^^^ union: type application of polymorphic type: type `TestFunction` | array type. See: index.js.flow:150
    Member 1:
    100:    | TestFunction<T, R>
              ^^^^^^^^^^^^^^^^^^ type application of polymorphic type: type `TestFunction`. See: index.js.flow:100
    Error:
     44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    100:    | TestFunction<T, R>
              ^^^^^^^^^^^^^^^^^^ object type. See: index.js.flow:100
    Member 2:
    101:    | Array<TestFunction<T, R>>;
              ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
    Error:
     44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
              ^^^^^^^^^^^^^ string. This type is incompatible with
    101:    | Array<TestFunction<T, R>>;
              ^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See: index.js.flow:101
  Member 2:
  151:  (name: string, run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   44: test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
                                            ^^^^^^^ unused function argument
    151:    (name: string, run: ContextualTest): void;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 2 arguments. See: index.js.flow:151

test/flow-types/regression-1114.js.flow:45
 45: test([macro, macro2], '2 * 3', 6);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type
                             v
149: declare module.exports: {
150:    (              run: ContextualTest): void;
151:    (name: string, run: ContextualTest): void;
...:
164: };
     ^ intersection. See: index.js.flow:149
  Member 1:
  150:  (              run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:150
  Error:
   45: test([macro, macro2], '2 * 3', 6);
                             ^^^^^^^ unused function argument
    150:    (              run: ContextualTest): void;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type expects no more than 1 argument. See: index.js.flow:150
  Member 2:
  151:  (name: string, run: ContextualTest): void;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: index.js.flow:151
  Error:
   45: test([macro, macro2], '2 * 3', 6);
            ^^^^^^^^^^^^^^^ array literal. This type is incompatible with the expected param type of
  151:  (name: string, run: ContextualTest): void;
               ^^^^^^ string. See: index.js.flow:151


Found 4 errors

// @leebyron

Updated 26/06/2017 16:50

Explore storing an error object, rather than directly capturing a stack trace

avajs/ava

For asynchronous assertions we capture a stack trace before the assertion is run. Inspired by this comment by @alxandr we should explore storing an error object, and reading the stack trace later if it’s actually necessary:

… instead of passing the stack trace itself, an error object could be passed. This has less performance impact, because then the stack trace is only generated on demand (this might even be something that could improve the performance of your existing async tests).

See lib/test.js and lib/assert.js.

Updated 20/06/2017 23:24 6 Comments

Support commit_id field in PullRequestReviewRequest in file pulls_reviews.go

google/go-github

GitHub Developer Announcement: https://developer.github.com/changes/2017-05-30-specify-commit-for-review/

The announcement was uncharacteristically terse this time and did not provide a link to the developer API docs. It appears to me that this is the API in question: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review

A new (optional) commit_id field needs to be added to the PullRequestReviewRequest (sounds like Java 😄) struct. Note that the Go version of the name would be CommitID.

Updated 02/06/2017 13:28 1 Comments

Additional options to pass when executing writable job

deployphp/deployer
Q A
Issue Type Feature Request
Deployer Version 5.0.1
Local Machine OS MacOS Sierra
Remote Machine OS Ubuntu 16.04

Description

When setting writable on directories on remote server i used chmod/chgrp but i was getting following error:

chgrp: cannot dereference ‘sugar-deployment/vendor/bin/phpunit’: No such file or directory

I solved it by adding additional option to chmod or chgrp -h affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink)

run(“$sudo chown -RLh $httpUser $dirs”);

Which resulted in link to shared as well as shared content to be properly set.

Maybe there should be an easy way to add additional options to pass when executing writable commands ?

Updated 30/05/2017 01:24 4 Comments

List copied file types in `copy_dirs`

deployphp/deployer
Q A
Issue Type Feature Request
Deployer Version -
Local Machine OS -
Remote Machine OS -

Description

It would be nice to have an option to set just some file types to copy in copy_dirs directive. For example: set('copy_dirs', [ 'dist/*.js', 'dist/*.css' ]); Don’t know, maybe copy_files would be better with allowing concrete files as well (eg dist/abcd.css).

Updated 23/05/2017 17:45 1 Comments

Require `new RegExp()` in instead of `RegExp()`

sindresorhus/eslint-plugin-unicorn

RegExp() and new RegExp() are no different, but would be nice to enforce a consistent style. This rule should enforce new RegExp() as that’s how it’s commonly used and matches other constructors like new Error() and user-land constructors. Should be fixable.

For reference, similar rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/rules/throw-new-error.js

I think we could use AST selectors for this: http://eslint.org/docs/developer-guide/selectors

Updated 19/06/2017 10:49

Support scoped shortcut package name

textlint/textlint

Currently, textlint support following rule names

  • @textlint/textlint-rule-no-todo
  • textlint-rule-no-todo
  • no-todo

We want to add support shortcut for scoped module.

  • @textlint/textlint-rule-no-todo can be shorten to @textlint/no-todo

FYI: This features is supported by ESLint.

  • https://github.com/eslint/eslint/blob/afbea78d4b94839ec6d59d2c98321901aeb76313/lib/config/config-file.js#L459-L477
Updated 17/05/2017 01:24

rate limit exceeded: funky error message

google/go-github

The error message for “rate limit exceeded” has both a period and a semicolon in it which looks weird.

GET https://api.github.com/repos/golang/go/issues?direction=desc&page=1&per_page=100&sort=updated&state=all: 403 API rate limit of 5000 
still exceeded until 2017-04-21 08:38:57 -0700 PDT, not making remote request.; rate reset 
in 26m8.032328588s

We could also probably round the duration to the nearest second (if greater than a minute) or tenth of a second (if less than a minute) to avoid 8 useless units of precision after the decimal.

Updated 24/04/2017 15:57 15 Comments

Consistent Go naming for JSON fields

google/go-github

As discussed in https://github.com/google/go-github/pull/520#discussion_r98727959 and https://github.com/google/go-github/pull/602#issuecomment-290255621 the naming of fields such as Total (as opposed to TotalCount) where the JSON name is total_count seems inconsistent and it would be nice to consolidate.

However, this is a breaking API change.

This issue has been opened to discuss the situation and see if it is worth breaking the API to have more consistency.

Updated 01/04/2017 00:40 12 Comments

Recipe for using a plain function instead of `beforeEach` hook

avajs/ava

In many cases you could just use a plain function instead of a beforeEach hook. In the below case it’s both more clear and less code.

import test from 'ava';

const setup = () => {
    doStuff();

    return {
        unicorn: fn('unicorn')
        rainbow: fn('rainbow')
    };
}

test('foo', t => {
    const {unicorn, rainbow} = setup();
    t.true(unicorn('foo'));
    t.true(rainbow('foo'));
});

test('bar', t => {
    const {unicorn, rainbow} = setup();
    t.true(unicorn('bar'));
    t.true(rainbow('bar'));
});

With beforeEach it would be:

import test from 'ava';

test.beforeEach(t => {
    doStuff();

    t.context = {
        unicorn: fn('unicorn')
        rainbow: fn('rainbow')
    };
}

test('foo', t => {
    const {unicorn, rainbow} = t.context;
    t.true(unicorn('foo'));
    t.true(rainbow('foo'));
});

test('bar', t => {
    const {unicorn, rainbow} = t.context;
    t.true(unicorn('bar'));
    t.true(rainbow('bar'));
});

Still, there are benefits of beforeEach too. They’re not mutually exclusive. beforeEach has benefits like supporting non-promise asynchronicity. Better output when a hook fails. Void hook usage doesn’t require a call in each test. And more.

Updated 13/05/2017 14:57 3 Comments

tape/tap transition guide

avajs/ava

Would make migrating from tape easier if AVA & tape shared the same API.

Below is the full list of tape apis that don’t exist in AVA. Most of these would only require a simple alias e.g. Test.prototype.deepEqual = Test.prototype.same

Though it’s possible there’s benefit in divorcing the tape API entirely & just keeping the current, simpler API. For example, not sure if it was ever a good idea to support both deepEquals and deepEqual other than to encourage bikeshedding within a team about which one to use.

const TapeTest = require('tape/lib/test')
const AVATest = require('ava/lib/test')
Object.keys(TapeTest.prototype).filter(k => !Object.keys(AVATest.prototype).includes(k))
[ 'test',
  'comment',
  'timeoutAfter',
  '_end',
  '_exit',
  '_pendingAsserts',
  'skip',
  'notok',
  'iferror',
  'ifErr',
  'strictEquals',
  'strictEqual',
  'isEqual',
  'equals',
  'equal',
  'isInequal',
  'doesNotEqual',
  'isNot',
  'isNotEqual',
  'notStrictEquals',
  'notStrictEqual',
  'notEquals',
  'notEqual',
  'isEquivalent',
  'deepEquals',
  'deepEqual',
  'looseEquals',
  'looseEqual',
  'deepLooseEqual',
  'isInequivalent',
  'isNotEquivalent',
  'isNotDeeply',
  'isNotDeepEqual',
  'notDeeply',
  'notEquivalent',
  'notDeepEqual',
  'notLooseEquals',
  'notLooseEqual',
  'notDeepLooseEqual' ]

Related to https://github.com/sindresorhus/ava/issues/96

Updated 21/04/2017 18:32 10 Comments

Fork me on GitHub