Skip to content

Commit cac2914

Browse files
committed
chore: linting
1 parent c42e1f2 commit cac2914

12 files changed

+81
-16375
lines changed

.npmignore

-2
This file was deleted.

git-host-info.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
'use strict'
23
const maybeJoin = (...args) => args.every(arg => arg) ? args.join('') : ''
34
const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : ''
@@ -13,7 +14,7 @@ const defaults = {
1314
shortcuttemplate: ({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin('#', committish)}`,
1415
pathtemplate: ({ user, project, committish }) => `${user}/${project}${maybeJoin('#', committish)}`,
1516
bugstemplate: ({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`,
16-
hashformat: formatHashFragment
17+
hashformat: formatHashFragment,
1718
}
1819

1920
const gitHosts = {}
@@ -45,7 +46,7 @@ gitHosts.github = Object.assign({}, defaults, {
4546
}
4647

4748
return { user, project, committish }
48-
}
49+
},
4950
})
5051

5152
gitHosts.bitbucket = Object.assign({}, defaults, {
@@ -68,7 +69,7 @@ gitHosts.bitbucket = Object.assign({}, defaults, {
6869
}
6970

7071
return { user, project, committish: url.hash.slice(1) }
71-
}
72+
},
7273
})
7374

7475
gitHosts.gitlab = Object.assign({}, defaults, {
@@ -95,7 +96,7 @@ gitHosts.gitlab = Object.assign({}, defaults, {
9596
}
9697

9798
return { user, project, committish: url.hash.slice(1) }
98-
}
99+
},
99100
})
100101

101102
gitHosts.gist = Object.assign({}, defaults, {
@@ -136,7 +137,7 @@ gitHosts.gist = Object.assign({}, defaults, {
136137
},
137138
hashformat: function (fragment) {
138139
return fragment && 'file-' + formatHashFragment(fragment)
139-
}
140+
},
140141
})
141142

142143
gitHosts.sourcehut = Object.assign({}, defaults, {
@@ -166,7 +167,7 @@ gitHosts.sourcehut = Object.assign({}, defaults, {
166167
}
167168

168169
return { user, project, committish: url.hash.slice(1) }
169-
}
170+
},
170171
})
171172

172173
const names = Object.keys(gitHosts)

index.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const protocolToRepresentationMap = {
99
'git+ssh:': 'sshurl',
1010
'git+https:': 'https',
1111
'ssh:': 'sshurl',
12-
'git:': 'git'
12+
'git:': 'git',
1313
}
1414

1515
function protocolToRepresentation (protocol) {
@@ -21,10 +21,11 @@ const authProtocols = {
2121
'https:': true,
2222
'git+https:': true,
2323
'http:': true,
24-
'git+http:': true
24+
'git+http:': true,
2525
}
2626

27-
const knownProtocols = Object.keys(gitHosts.byShortcut).concat(['http:', 'https:', 'git:', 'git+ssh:', 'git+https:', 'ssh:'])
27+
const knownProtocols = Object.keys(gitHosts.byShortcut)
28+
.concat(['http:', 'https:', 'git:', 'git+ssh:', 'git+https:', 'ssh:'])
2829

2930
module.exports.fromUrl = function (giturl, opts) {
3031
if (typeof giturl !== 'string') {
@@ -52,7 +53,10 @@ function fromUrl (giturl, opts) {
5253
}
5354

5455
const gitHostShortcut = gitHosts.byShortcut[parsed.protocol]
55-
const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.') ? parsed.hostname.slice(4) : parsed.hostname]
56+
const gitHostDomain =
57+
gitHosts.byDomain[parsed.hostname.startsWith('www.') ?
58+
parsed.hostname.slice(4) :
59+
parsed.hostname]
5660
const gitHostName = gitHostShortcut || gitHostDomain
5761
if (!gitHostName) {
5862
return
@@ -172,11 +176,14 @@ const isGitHubShorthand = (arg) => {
172176
const colonOnlyAfterHash = firstColon === -1 || (firstHash > -1 && firstColon > firstHash)
173177
const secondSlashOnlyAfterHash = secondSlash === -1 || (firstHash > -1 && secondSlash > firstHash)
174178
const hasSlash = firstSlash > 0
175-
// if a # is found, what we really want to know is that the character immediately before # is not a /
179+
// if a # is found, what we really want to know is that the character
180+
// immediately before # is not a /
176181
const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== '/' : !arg.endsWith('/')
177182
const doesNotStartWithDot = !arg.startsWith('.')
178183

179-
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash && doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash && secondSlashOnlyAfterHash
184+
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash &&
185+
doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash &&
186+
secondSlashOnlyAfterHash
180187
}
181188

182189
// attempt to correct an scp style url so that it will parse with `new URL()`

0 commit comments

Comments
 (0)