Skip to content

Commit

Permalink
chore(lint): disabled rules that dont apply to this project (#2408)
Browse files Browse the repository at this point in the history
the performance and readability of reduce is not a concern in this project since maintainers are
familiar with the idiom and are iterating over small lists. the filter rule is disabled selectively
since the filter being identified is not Array.filter

closes #2403
  • Loading branch information
travi committed Apr 2, 2022
1 parent ea389c3 commit ab45ab1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/branches/index.js
Expand Up @@ -27,6 +27,7 @@ module.exports = async (repositoryUrl, ciBranch, context) => {

const errors = [];
const branchesByType = Object.entries(DEFINITIONS).reduce(
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
(branchesByType, [type, {filter}]) => ({[type]: branches.filter(filter), ...branchesByType}),
{}
);
Expand Down
1 change: 1 addition & 0 deletions lib/definitions/branches.js
Expand Up @@ -16,6 +16,7 @@ const prerelease = {
};

const release = {
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/get-git-auth-url.js
Expand Up @@ -89,7 +89,7 @@ module.exports = async (context) => {
try {
debug('Verifying ssh auth by attempting to push to %s', repositoryUrl);
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
} catch (_) {
} catch {
debug('SSH key auth failed, falling back to https.');
const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));

Expand Down
4 changes: 2 additions & 2 deletions lib/git.js
Expand Up @@ -116,7 +116,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
],
execaOptions
);
} catch (_) {
} catch {
await execa(
'git',
[
Expand Down Expand Up @@ -144,7 +144,7 @@ async function fetchNotes(repositoryUrl, execaOptions) {
['fetch', '--unshallow', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`],
execaOptions
);
} catch (_) {
} catch {
await execa('git', ['fetch', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], {
...execaOptions,
reject: false,
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -129,6 +129,7 @@
"prettier": true,
"space": true,
"rules": {
"unicorn/no-reduce": "off",
"unicorn/string-content": "off"
}
},
Expand Down
6 changes: 6 additions & 0 deletions test/definitions/branches.test.js
Expand Up @@ -2,6 +2,7 @@ const test = require('ava');
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');

test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(maintenance.filter({name: '1.x.x'}));
t.true(maintenance.filter({name: '1.0.x'}));
t.true(maintenance.filter({name: '1.x'}));
Expand All @@ -15,6 +16,7 @@ test('A "maintenance" branch is identified by having a "range" property or a "na
t.false(maintenance.filter({name: 'some-name'}));
t.false(maintenance.filter({name: '1.0.0'}));
t.false(maintenance.filter({name: 'x.x.x'}));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});

test('A "maintenance" branches must have a "range" property formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
Expand All @@ -37,13 +39,15 @@ test('The "maintenance" branches must have unique ranges', (t) => {
});

test('A "prerelease" branch is identified by having a thruthy "prerelease" property', (t) => {
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(prerelease.filter({name: 'some-name', prerelease: true}));
t.true(prerelease.filter({name: 'some-name', prerelease: 'beta'}));
t.true(prerelease.filter({name: 'some-name', prerelease: ''}));

t.false(prerelease.filter({name: 'some-name', prerelease: null}));
t.false(prerelease.filter({name: 'some-name', prerelease: false}));
t.false(prerelease.filter({name: 'some-name'}));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});

test('A "prerelease" branch must have a valid prerelease detonation in "prerelease" property or in "name" if "prerelease" is "true"', (t) => {
Expand All @@ -66,6 +70,7 @@ test('The "prerelease" branches must have unique "prerelease" property', (t) =>
});

test('A "release" branch is identified by not havin a "range" or "prerelease" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(release.filter({name: 'some-name'}));

t.false(release.filter({name: '1.x.x'}));
Expand All @@ -74,6 +79,7 @@ test('A "release" branch is identified by not havin a "range" or "prerelease" pr
t.false(release.filter({name: 'some-name', range: '1.1.x'}));
t.false(release.filter({name: 'some-name', prerelease: true}));
t.false(release.filter({name: 'some-name', prerelease: 'beta'}));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});

test('There must be between 1 and 3 release branches', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/mockserver.js
Expand Up @@ -30,7 +30,7 @@ async function start() {
minTimeout: 1000,
factor: 2,
});
} catch (_) {
} catch {
throw new Error(`Couldn't start mock-server after 2 min`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/npm-registry.js
Expand Up @@ -37,7 +37,7 @@ async function start() {
minTimeout: 1000,
factor: 2,
});
} catch (_) {
} catch {
throw new Error(`Couldn't start npm-registry-docker after 2 min`);
}

Expand Down

0 comments on commit ab45ab1

Please sign in to comment.