Skip to content

Commit deb6be9

Browse files
hpierre74Pierre Huyghe
and
Pierre Huyghe
authored
refactor: add tbody to contributors table (#307)
* refactor: add tbody to contributors table * chore(node): bump version to lts * fix(html): add correct indentation * test(url): fix bind error message Co-authored-by: Pierre Huyghe <phuyghe.externe@bedrockstreaming.com>
1 parent 5dbb721 commit deb6be9

File tree

5 files changed

+54
-42
lines changed

5 files changed

+54
-42
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2.1
22

33
docker_defaults: &docker_defaults
44
docker:
5-
- image: circleci/node:12.14.0
5+
- image: cimg/node:16.17.0
66

77
commands:
88
prep_env:

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.14.0
1+
16.17.0

src/generate/__tests__/__snapshots__/index.js.snap

+20-16
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ These people contributed to the project:
1111
<!-- prettier-ignore-start -->
1212
<!-- markdownlint-disable -->
1313
<table>
14-
<tr>
15-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
16-
<td align=\\"center\\">Divjot Singh is awesome!</td>
17-
<td align=\\"center\\">Jeroen Engels is awesome!</td>
18-
</tr>
14+
<tbody>
15+
<tr>
16+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
17+
<td align=\\"center\\">Divjot Singh is awesome!</td>
18+
<td align=\\"center\\">Jeroen Engels is awesome!</td>
19+
</tr>
20+
</tobdy>
1921
</table>
2022
2123
<!-- markdownlint-restore -->
@@ -37,17 +39,19 @@ These people contributed to the project:
3739
<!-- prettier-ignore-start -->
3840
<!-- markdownlint-disable -->
3941
<table>
40-
<tr>
41-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
42-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
43-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
44-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
45-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
46-
</tr>
47-
<tr>
48-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
49-
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
50-
</tr>
42+
<tbody>
43+
<tr>
44+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
45+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
46+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
47+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
48+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
49+
</tr>
50+
<tr>
51+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
52+
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
53+
</tr>
54+
</tobdy>
5155
</table>
5256
5357
<!-- markdownlint-restore -->

src/generate/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const formatBadge = require('./format-badge')
33
const formatContributor = require('./format-contributor')
44

55
function injectListBetweenTags(newContent) {
6-
return function(previousContent) {
6+
return function (previousContent) {
77
const tagToLookFor = `<!-- ALL-CONTRIBUTORS-LIST:`
88
const closingTag = '-->'
99
const startOfOpeningTagIndex = previousContent.indexOf(
@@ -39,7 +39,7 @@ function injectListBetweenTags(newContent) {
3939

4040
function formatLine(contributors) {
4141
return `<td align="center">${contributors.join(
42-
'</td>\n <td align="center">',
42+
'</td>\n <td align="center">',
4343
)}</td>`
4444
}
4545

@@ -55,15 +55,15 @@ function generateContributorsList(options, contributors) {
5555
}),
5656
_.chunk(options.contributorsPerLine),
5757
_.map(formatLine),
58-
_.join('\n </tr>\n <tr>\n '),
58+
_.join('\n </tr>\n <tr>\n '),
5959
newContent => {
60-
return `\n<table>\n <tr>\n ${newContent}\n </tr>\n</table>\n\n`
60+
return `\n<table>\n <tbody>\n <tr>\n ${newContent}\n </tr>\n </tobdy>\n</table>\n\n`
6161
},
6262
)(contributors)
6363
}
6464

6565
function replaceBadge(newContent) {
66-
return function(previousContent) {
66+
return function (previousContent) {
6767
const tagToLookFor = `<!-- ALL-CONTRIBUTORS-BADGE:`
6868
const closingTag = '-->'
6969
const startOfOpeningTagIndex = previousContent.indexOf(

src/util/__tests__/url.js

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
import url from '../url';
1+
import url from '../url'
22

33
test(`Result of protocol validation should be true`, () => {
4-
expect(url.isHttpProtocol('http:')).toBe(true)
5-
expect(url.isHttpProtocol('https:')).toBe(true)
4+
expect(url.isHttpProtocol('http:')).toBe(true)
5+
expect(url.isHttpProtocol('https:')).toBe(true)
66
})
77

88
test(`Result of protocol validation should be false`, () => {
9-
expect(url.isHttpProtocol('ftp:')).toBe(false)
9+
expect(url.isHttpProtocol('ftp:')).toBe(false)
1010
})
1111

1212
test(`Result of url validation should be true`, () => {
13-
expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true)
13+
expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true)
1414
})
1515

1616
test(`Result of url validation should be false when url uses wrong protocol`, () => {
17-
expect(url.isValidHttpUrl('git://git@github.com:all-contributors/all-contributors-cli.git')).toBe(false)
17+
expect(
18+
url.isValidHttpUrl(
19+
'git://git@github.com:all-contributors/all-contributors-cli.git',
20+
),
21+
).toBe(false)
1822
})
1923

2024
test(`Result of url validation should be false when input isn't url`, () => {
21-
expect(url.isValidHttpUrl('github-octocat')).toBe(false)
25+
expect(url.isValidHttpUrl('github-octocat')).toBe(false)
2226
})
2327

2428
test(`Result of parsed url should be equal`, () => {
25-
const input = 'https://api.github.com/users/octocat'
26-
const expected = 'https://api.github.com/users/octocat'
27-
expect(url.parseHttpUrl(input)).toBe(expected)
29+
const input = 'https://api.github.com/users/octocat'
30+
const expected = 'https://api.github.com/users/octocat'
31+
expect(url.parseHttpUrl(input)).toBe(expected)
2832
})
2933

3034
test(`Result of parsed url without protocol should be equal`, () => {
31-
const input = 'example.com'
32-
const expected = 'http://example.com/'
33-
expect(url.parseHttpUrl(input)).toBe(expected)
35+
const input = 'example.com'
36+
const expected = 'http://example.com/'
37+
expect(url.parseHttpUrl(input)).toBe(expected)
3438
})
3539

3640
test(`Throw an error when parsed input isn't a string`, () => {
37-
const input = 123
38-
expect(url.parseHttpUrl.bind(null, input)).toThrowError('input must be a string')
41+
const input = 123
42+
expect(url.parseHttpUrl.bind(null, input)).toThrowError(
43+
'input must be a string',
44+
)
3945
})
4046

4147
test(`Throw an error when parsed url has wrong protocol`, () => {
42-
const input = 'ftp://domain.xyz'
43-
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Provided URL has an invalid protocol')
48+
const input = 'ftp://domain.xyz'
49+
expect(url.parseHttpUrl.bind(null, input)).toThrowError(
50+
'Provided URL has an invalid protocol',
51+
)
4452
})
4553

4654
test(`Throw an error when parsed input isn't a URL`, () => {
47-
const input = 'some string'
48-
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL: http://some string')
55+
const input = 'some string'
56+
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL')
4957
})

0 commit comments

Comments
 (0)