Skip to content

Commit

Permalink
Merge pull request #116 from denis-sokolov/lint-rest
Browse files Browse the repository at this point in the history
Lint everything else
  • Loading branch information
denis-sokolov authored Sep 28, 2020
2 parents eb39b26 + 4d0eeb3 commit f5c6198
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 47 deletions.
13 changes: 2 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,9 @@
],
"prettier": true,
"rules": {
"camelcase": "off",
"ava/no-import-test-files": "off",
"ava/no-invalid-end": "off",
"ava/no-skip-test": "off",
"ava/no-statement-after-end": "off",
"eqeqeq": "off",
"no-useless-call": "off",
"no-var": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"unicorn/explicit-length-check": "off",
"unicorn/prevent-abbreviations": "off"
"ava/no-todo-test": "off",
"camelcase": "off"
}
}
}
2 changes: 1 addition & 1 deletion src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ try {
return abort(error);
}

if (!repos.length) {
if (repos.length === 0) {
console.log('No useless repositories found.');
process.exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports.mock = (responses) => {
const methodsWithoutDataField = ['listForAuthenticatedUser'];
const data =
typeof responsePassed === 'function'
? responsePassed.call(null, callData)
? responsePassed(callData)
: responsePassed;
const response = methodsWithoutDataField.includes(name) ? data : {data};
return new Promise((resolve) => {
Expand Down
5 changes: 2 additions & 3 deletions test/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test.cb('should report progress', (t) => {
mock.present,
{
progress(info) {
if (progressCallCount === 0) {
progressCallCount += 1;
if (progressCallCount === 1) {
t.is(info.countInspected, 0);
t.is(info.totalToInspect, 1);
} else {
Expand All @@ -23,8 +24,6 @@ test.cb('should report progress', (t) => {
t.is(info.lastInspected, 'fork1');
t.end();
}

progressCallCount += 1;
}
},
(error) => {
Expand Down
64 changes: 33 additions & 31 deletions test/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,43 @@ test.cb('should not delete a fork that has more branches', (t) => {
});
});

// Currently our logic does not delete this fork
test.skip('should delete a fork that has more branches, but all at upstream branch tips', (t) => {
const mock = lib.mock({
listBranches(arguments_) {
if (arguments_.user === lib.USER.login) {
test.cb(
'should delete a fork that has more branches, but all at upstream branch tips',
(t) => {
const mock = lib.mock({
listBranches(arguments_) {
if (arguments_.user === lib.USER.login) {
return [
{name: 'master', commit: lib.COMMIT_A},
{name: 'foo', commit: lib.COMMIT_A},
{name: 'bar', commit: lib.COMMIT_B}
];
}

return [
{name: 'master', commit: lib.COMMIT_A},
{name: 'foo', commit: lib.COMMIT_A},
{name: 'bar', commit: lib.COMMIT_B}
{name: 'baz', commit: lib.COMMIT_B}
];
}

return [
{name: 'master', commit: lib.COMMIT_A},
{name: 'baz', commit: lib.COMMIT_B}
];
},
delete: true
});
},
delete: true
});

removeGithubForks(mock.present, (error) => {
if (error) return t.fail(error);
lib.check(t, mock.calls(), [
['listForAuthenticatedUser', {type: 'public'}],
['get', {owner: lib.USER.login, repo: 'fork1'}],
['listBranches', {owner: lib.USER.login, repo: 'fork1', per_page: 100}],
[
'listBranches',
{owner: lib.AUTHOR.login, repo: 'upstream-lib', per_page: 100}
],
['delete', {owner: lib.USER.login, repo: 'fork1', url: undefined}]
]);
t.end();
});
});
removeGithubForks(mock.present, (error) => {
if (error) return t.fail(error);
lib.check(t, mock.calls(), [
['listForAuthenticatedUser', {type: 'public'}],
['get', {owner: lib.USER.login, repo: 'fork1'}],
['listBranches', {owner: lib.USER.login, repo: 'fork1', per_page: 100}],
[
'listBranches',
{owner: lib.AUTHOR.login, repo: 'upstream-lib', per_page: 100}
],
['delete', {owner: lib.USER.login, repo: 'fork1', url: undefined}]
]);
t.end();
});
}
);

test.cb(
'should delete a fork that has all branches at upstream branch tips',
Expand Down

0 comments on commit f5c6198

Please sign in to comment.