chore(lint): disabled rules that dont apply to this project (#2408)

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
This commit is contained in:
Matt Travi 2022-04-02 17:33:08 -05:00 committed by GitHub
parent ea389c3c88
commit ab45ab1f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 5 deletions

View File

@ -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}),
{}
);

View File

@ -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,
};

View File

@ -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]));

View File

@ -116,7 +116,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
],
execaOptions
);
} catch (_) {
} catch {
await execa(
'git',
[
@ -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,

View File

@ -129,6 +129,7 @@
"prettier": true,
"space": true,
"rules": {
"unicorn/no-reduce": "off",
"unicorn/string-content": "off"
}
},

View File

@ -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'}));
@ -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) => {
@ -37,6 +39,7 @@ 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: ''}));
@ -44,6 +47,7 @@ test('A "prerelease" branch is identified by having a thruthy "prerelease" prope
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) => {
@ -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'}));
@ -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) => {

View File

@ -30,7 +30,7 @@ async function start() {
minTimeout: 1000,
factor: 2,
});
} catch (_) {
} catch {
throw new Error(`Couldn't start mock-server after 2 min`);
}
}

View File

@ -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`);
}