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:
parent
ea389c3c88
commit
ab45ab1f8d
@ -27,6 +27,7 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
|
|||||||
|
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const branchesByType = Object.entries(DEFINITIONS).reduce(
|
const branchesByType = Object.entries(DEFINITIONS).reduce(
|
||||||
|
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
|
||||||
(branchesByType, [type, {filter}]) => ({[type]: branches.filter(filter), ...branchesByType}),
|
(branchesByType, [type, {filter}]) => ({[type]: branches.filter(filter), ...branchesByType}),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
@ -16,6 +16,7 @@ const prerelease = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const release = {
|
const release = {
|
||||||
|
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
|
||||||
filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
|
filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
|
||||||
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
|
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
|
||||||
};
|
};
|
||||||
|
@ -89,7 +89,7 @@ module.exports = async (context) => {
|
|||||||
try {
|
try {
|
||||||
debug('Verifying ssh auth by attempting to push to %s', repositoryUrl);
|
debug('Verifying ssh auth by attempting to push to %s', repositoryUrl);
|
||||||
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
|
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
|
||||||
} catch (_) {
|
} catch {
|
||||||
debug('SSH key auth failed, falling back to https.');
|
debug('SSH key auth failed, falling back to https.');
|
||||||
const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));
|
const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
|
|||||||
],
|
],
|
||||||
execaOptions
|
execaOptions
|
||||||
);
|
);
|
||||||
} catch (_) {
|
} catch {
|
||||||
await execa(
|
await execa(
|
||||||
'git',
|
'git',
|
||||||
[
|
[
|
||||||
@ -144,7 +144,7 @@ async function fetchNotes(repositoryUrl, execaOptions) {
|
|||||||
['fetch', '--unshallow', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`],
|
['fetch', '--unshallow', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`],
|
||||||
execaOptions
|
execaOptions
|
||||||
);
|
);
|
||||||
} catch (_) {
|
} catch {
|
||||||
await execa('git', ['fetch', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], {
|
await execa('git', ['fetch', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], {
|
||||||
...execaOptions,
|
...execaOptions,
|
||||||
reject: false,
|
reject: false,
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
"prettier": true,
|
"prettier": true,
|
||||||
"space": true,
|
"space": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"unicorn/no-reduce": "off",
|
||||||
"unicorn/string-content": "off"
|
"unicorn/string-content": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,7 @@ const test = require('ava');
|
|||||||
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
|
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) => {
|
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.x.x'}));
|
||||||
t.true(maintenance.filter({name: '1.0.x'}));
|
t.true(maintenance.filter({name: '1.0.x'}));
|
||||||
t.true(maintenance.filter({name: '1.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: 'some-name'}));
|
||||||
t.false(maintenance.filter({name: '1.0.0'}));
|
t.false(maintenance.filter({name: '1.0.0'}));
|
||||||
t.false(maintenance.filter({name: 'x.x.x'}));
|
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) => {
|
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) => {
|
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: true}));
|
||||||
t.true(prerelease.filter({name: 'some-name', prerelease: 'beta'}));
|
t.true(prerelease.filter({name: 'some-name', prerelease: 'beta'}));
|
||||||
t.true(prerelease.filter({name: 'some-name', prerelease: ''}));
|
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: null}));
|
||||||
t.false(prerelease.filter({name: 'some-name', prerelease: false}));
|
t.false(prerelease.filter({name: 'some-name', prerelease: false}));
|
||||||
t.false(prerelease.filter({name: 'some-name'}));
|
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) => {
|
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) => {
|
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.true(release.filter({name: 'some-name'}));
|
||||||
|
|
||||||
t.false(release.filter({name: '1.x.x'}));
|
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', range: '1.1.x'}));
|
||||||
t.false(release.filter({name: 'some-name', prerelease: true}));
|
t.false(release.filter({name: 'some-name', prerelease: true}));
|
||||||
t.false(release.filter({name: 'some-name', prerelease: 'beta'}));
|
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) => {
|
test('There must be between 1 and 3 release branches', (t) => {
|
||||||
|
@ -30,7 +30,7 @@ async function start() {
|
|||||||
minTimeout: 1000,
|
minTimeout: 1000,
|
||||||
factor: 2,
|
factor: 2,
|
||||||
});
|
});
|
||||||
} catch (_) {
|
} catch {
|
||||||
throw new Error(`Couldn't start mock-server after 2 min`);
|
throw new Error(`Couldn't start mock-server after 2 min`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ async function start() {
|
|||||||
minTimeout: 1000,
|
minTimeout: 1000,
|
||||||
factor: 2,
|
factor: 2,
|
||||||
});
|
});
|
||||||
} catch (_) {
|
} catch {
|
||||||
throw new Error(`Couldn't start npm-registry-docker after 2 min`);
|
throw new Error(`Couldn't start npm-registry-docker after 2 min`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user