Skip to content

Commit b9ef7db

Browse files
committed
chore: lint
1 parent 38e56b2 commit b9ef7db

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

src/domain/getLabelConfigs.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ const getFilePath = (configurationPath: string): string | undefined => {
3131
}
3232
}
3333

34-
const compareArray = (arr?: string[]) => Array.isArray(arr) ? arr : undefined
35-
const compareBoolean = (bool?: boolean) => typeof bool === 'boolean' ? bool : undefined
36-
const compareObject = (obj?: Record<string, string[]>) => typeof obj === 'object' && !Array.isArray(obj) ? obj : undefined
34+
const compareArray = (arr?: string[]) => (Array.isArray(arr) ? arr : undefined)
35+
const compareBoolean = (bool?: boolean) =>
36+
typeof bool === 'boolean' ? bool : undefined
37+
const compareObject = (obj?: Record<string, string[]>) =>
38+
typeof obj === 'object' && !Array.isArray(obj) ? obj : undefined
3739

3840
export const getLabelConfigs = (configurationPath: string): Config | {} => {
3941
const filePath = getFilePath(configurationPath)

src/domain/parseText.spec.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ describe('getIssueLabels function', () => {
1111
})
1212

1313
test('should return just scoped body', () => {
14-
const body =
15-
'Body with labels <!-- Label3 --> Label1 Label2'
14+
const body = 'Body with labels <!-- Label3 --> Label1 Label2'
1615
const result = parseText(body, '', true, false)
1716

1817
expect(result).toEqual('Body with labels Label1 Label2')
1918
})
2019

2120
test('should return just scoped body', () => {
22-
const body =
23-
'Body with labels <!-- Label3 --> Label1 Label2'
21+
const body = 'Body with labels <!-- Label3 --> Label1 Label2'
2422
const result = parseText(body, 'Title', true, true)
2523

2624
expect(result).toEqual('Title Body with labels Label1 Label2')

src/domain/parseText.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
export const parseText = (body: string, title: string, ignoreComments?: boolean, includeTitle?: boolean): string => {
1+
export const parseText = (
2+
body: string,
3+
title: string,
4+
ignoreComments?: boolean,
5+
includeTitle?: boolean
6+
): string => {
27
let parsedBody = body
38
if (parsedBody.includes('AUTO-LABEL:START')) {
49
const [_ignore, ...bodySplit] = body.split('AUTO-LABEL:START')
5-
parsedBody = bodySplit.map(elem => elem.split('AUTO-LABEL:END')[0]).join(' ')
10+
parsedBody = bodySplit
11+
.map((elem) => elem.split('AUTO-LABEL:END')[0])
12+
.join(' ')
613
}
714

8-
915
if (ignoreComments && parsedBody.includes('<!--')) {
1016
parsedBody = parsedBody.replace(/\<!--(.|\n)*?-->/g, '')
1117
}

src/runner.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ export async function run() {
1717
const token = core.getInput('repo-token', { required: true })
1818
const octokit = github.getOctokit(token)
1919
const issue = github.context.payload.issue!
20-
const { labelsNotAllowed, defaultLabels, labelsSynonyms, ignoreComments, includeTitle } =
21-
getConfigFile()
20+
const {
21+
labelsNotAllowed,
22+
defaultLabels,
23+
labelsSynonyms,
24+
ignoreComments,
25+
includeTitle
26+
} = getConfigFile()
2227
core.endGroup()
2328

2429
core.startGroup('Getting repository labels')
@@ -29,11 +34,15 @@ export async function run() {
2934
core.info(`Considered labels: ${filteredLabels.length}`)
3035
core.endGroup()
3136

32-
core.startGroup(`Parsing body${ includeTitle ? 'and Title' : ''}`)
33-
const parsedBody = parseText(issue.body || '', issue.title || '', ignoreComments, includeTitle)
37+
core.startGroup(`Parsing body${includeTitle ? 'and Title' : ''}`)
38+
const parsedBody = parseText(
39+
issue.body || '',
40+
issue.title || '',
41+
ignoreComments,
42+
includeTitle
43+
)
3444
core.startGroup('Getting repository labels')
3545

36-
3746
core.startGroup('Looking for labels')
3847
const issueLabels: string[] = getIssueLabels(
3948
parsedBody,

src/scraper/text.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ describe('getIssueLabels function', () => {
3131
})
3232

3333
test('should check if there is any synonym for the labels available', () => {
34-
const body =
35-
'Body with labels: Synonym1'
34+
const body = 'Body with labels: Synonym1'
3635
const labels = ['Label1', 'Label2']
3736
const labelsSynonyms = { Label1: ['Synonym1'], Label2: ['Synonym2'] }
3837

0 commit comments

Comments
 (0)