Skip to content

Commit d5d23cb

Browse files
committed
Remove xo rule
1 parent e067d76 commit d5d23cb

9 files changed

Lines changed: 172 additions & 159 deletions

File tree

lib/collective/labels.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export async function labels(ctx) {
1414
const remove = (labels.remove || []).map((d) => toLabelSlug(d))
1515
const replace = {}
1616
const add = []
17-
labels.add.forEach((x) => (x.labels ? addAll : addOne)(x))
17+
18+
for (const x of labels.add) {
19+
;(x.labels ? addAll : addOne)(x)
20+
}
21+
1822
return {remove, replace, add}
1923

2024
function addOne({legacy = [], color, ...x}) {
@@ -26,9 +30,9 @@ export async function labels(ctx) {
2630
slug
2731
})
2832

29-
legacy.forEach((y) => {
33+
for (const y of legacy) {
3034
replace[toLabelSlug(y)] = slug
31-
})
35+
}
3236
}
3337

3438
function addAll(group) {
@@ -41,13 +45,14 @@ export async function labels(ctx) {
4145
.range([color.from, color.to])
4246
}
4347

44-
labels
48+
const all = labels
4549
.concat()
4650
.map((x) => ({...x, slug: toLabelSlug(x.name)}))
4751
.sort((a, b) => sort()(a.slug, b.slug))
48-
.forEach((x, i) => {
49-
addOne({color: scale ? scale(i) : color, ...x})
50-
})
52+
53+
for (const [i, x] of all.entries()) {
54+
addOne({color: scale ? scale(i) : color, ...x})
55+
}
5156
}
5257
}
5358
}

lib/org/people.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@ export async function people(ctx) {
4545
role
4646
}))
4747

48+
const notExpected = actual.filter(
49+
(x) => !expected.some((y) => x.login === y.login)
50+
)
51+
4852
// Remove
49-
actual
50-
.filter((x) => !expected.some((y) => x.login === y.login))
51-
.forEach(({login, role}) => {
52-
console.log(
53-
' ' + chalk.red('✖') + ' @%s should not be in %s as %s',
54-
login,
55-
org,
56-
role
57-
)
58-
})
53+
for (const {login, role} of notExpected) {
54+
console.log(
55+
' ' + chalk.red('✖') + ' @%s should not be in %s as %s',
56+
login,
57+
org,
58+
role
59+
)
60+
}
5961

6062
// Add or update humans with missing or unexpected roles.
6163
// Note that this will add pending humans again.

lib/org/teams.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export async function teams(ctx) {
1212

1313
const teamToParent = {}
1414

15-
ghTeams.forEach((cur) => {
15+
for (const cur of ghTeams) {
1616
teamToParent[cur.name] = cur.parent
17-
})
17+
}
1818

1919
// Sort teams as ancestors first, children last.
2020
const teams = ghTeams

lib/repo/collaborators.js

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -58,55 +58,57 @@ export async function collaborators(info) {
5858
}))
5959

6060
// Warn about missing expected outside collaborators.
61-
outside
62-
.filter((login) => !ghOutside.some((y) => login === y.login))
63-
.forEach((login) => {
64-
console.log(
65-
' ' +
66-
chalk.blue('ℹ') +
67-
' @%s should be an outside collaborator for %s',
68-
login,
69-
name
70-
)
71-
})
61+
const missing = outside.filter(
62+
(login) => !ghOutside.some((y) => login === y.login)
63+
)
64+
65+
for (const login of missing) {
66+
console.log(
67+
' ' + chalk.blue('ℹ') + ' @%s should be an outside collaborator for %s',
68+
login,
69+
name
70+
)
71+
}
7272

7373
// Remove.
74-
ghOutside
75-
.filter(({login}) => !outside.includes(login))
76-
.forEach(({login}) => {
77-
console.log(
78-
' ' +
79-
chalk.red('✖') +
80-
' @%s should not be an outside collaborator for %s',
81-
login,
82-
name
83-
)
84-
})
74+
const unexpected = ghOutside.filter(({login}) => !outside.includes(login))
75+
76+
for (const {login} of unexpected) {
77+
console.log(
78+
' ' +
79+
chalk.red('✖') +
80+
' @%s should not be an outside collaborator for %s',
81+
login,
82+
name
83+
)
84+
}
8585

8686
// Wrong permissions.
87-
ghOutside
88-
.filter((x) => x.permission !== permission)
89-
.forEach((x) => {
90-
console.log(
91-
' ' + chalk.red('✖') + ' @%s should have %s, not %s, rights for %s',
92-
x.login,
93-
permission,
94-
x.permission,
95-
name
96-
)
97-
})
87+
const wrong = ghOutside.filter((x) => x.permission !== permission)
88+
89+
for (const x of wrong) {
90+
console.log(
91+
' ' + chalk.red('✖') + ' @%s should have %s, not %s, rights for %s',
92+
x.login,
93+
permission,
94+
x.permission,
95+
name
96+
)
97+
}
9898

9999
// Team member and collaborator.
100-
ghDirect
101-
.filter(({login}) => !ghOutside.some((y) => login === y.login))
102-
.forEach((x) => {
103-
console.log(
104-
' ' +
105-
chalk.red('✖') +
106-
' @%s is a team member *and* an outside collaborator (%s) for %s',
107-
x.login,
108-
x.permission,
109-
name
110-
)
111-
})
100+
const both = ghDirect.filter(
101+
({login}) => !ghOutside.some((y) => login === y.login)
102+
)
103+
104+
for (const x of both) {
105+
console.log(
106+
' ' +
107+
chalk.red('✖') +
108+
' @%s is a team member *and* an outside collaborator (%s) for %s',
109+
x.login,
110+
x.permission,
111+
name
112+
)
113+
}
112114
}

0 commit comments

Comments
 (0)