Skip to content

Commit a651a74

Browse files
authored
Merge pull request #10 from mohe2015/lint-fixes
2 parents 97eedd8 + e8a706f commit a651a74

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

.github/workflows/test.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
name: "test-local"
2-
on: push
2+
on: [push, pull_request]
33
jobs:
44
test:
5-
runs-on: ubuntu-latest
5+
runs-on: ubuntu-20.04
66
steps:
7-
- uses: actions/checkout@v1
7+
- uses: actions/checkout@v2
88
- run: npm ci
9+
- name: Testing / Linting
10+
run: npm run test
11+
- name: Package
12+
run: npm run package
13+
- name: "Check that packaging didn't create any changes"
14+
run: '[ -z "$(git status --porcelain)" ];'
915
- name: Annotate
16+
if: github.event_name == 'push'
1017
uses: ./
1118
with:
1219
repo-token: ${{ secrets.GITHUB_TOKEN }}

dist/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ const createCheck = async function (octokit, owner, repo, title, ref) {
321321
repo,
322322
name: title,
323323
head_sha: ref,
324-
status: 'in_progress',
324+
status: 'in_progress'
325325
})
326326
return checkRunId
327327
} catch (err) {
@@ -365,9 +365,9 @@ const stats = function (annotations) {
365365
annotations.push(annotation)
366366
return acc
367367
}, {})
368-
const failureCount = (annotationsPerLevel['failure'] || []).length || 0
369-
const warningCount = (annotationsPerLevel['warning'] || []).length || 0
370-
const noticeCount = (annotationsPerLevel['notice'] || []).length || 0
368+
const failureCount = (annotationsPerLevel.failure || []).length || 0
369+
const warningCount = (annotationsPerLevel.warning || []).length || 0
370+
const noticeCount = (annotationsPerLevel.notice || []).length || 0
371371
return { failureCount, warningCount, noticeCount }
372372
}
373373

@@ -399,15 +399,15 @@ const booleanValue = function (input) {
399399
return /^\s*(true|1)\s*$/i.test(input)
400400
}
401401

402-
const readAnnotationsFile= async function(inputPath) {
402+
const readAnnotationsFile = async function (inputPath) {
403403
const ignoreMissingFileValue = Object(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('ignore-missing-file', { required: false }) || 'true'
404404
const ignoreMissingFile = booleanValue(ignoreMissingFileValue)
405405
try {
406406
const inputContent = await fs__WEBPACK_IMPORTED_MODULE_2__.promises.readFile(inputPath, 'utf8')
407407
return JSON.parse(inputContent)
408408
} catch (err) {
409409
if (err.code === 'ENOENT' && ignoreMissingFile) {
410-
Object(_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Ignoring missing file at '${inputPath}' because \'ignore-missing-file\' is true`)
410+
Object(_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Ignoring missing file at '${inputPath}' because 'ignore-missing-file' is true`)
411411
return null
412412
} else {
413413
throw err
@@ -421,7 +421,7 @@ async function run () {
421421
const inputPath = Object(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('input', { required: true })
422422
const title = Object(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('title', { required: false })
423423

424-
const octokit = new _actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit(repoToken)
424+
const octokit = Object(_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(repoToken)
425425
const pullRequest = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.payload.pull_request
426426
let ref
427427
if (pullRequest) {
@@ -457,7 +457,7 @@ async function run () {
457457
start_line: annotation.line,
458458
end_line: annotation.line,
459459
...annotation,
460-
annotation_level: annotationLevel,
460+
annotation_level: annotationLevel
461461
}
462462
})
463463
await updateCheck(octokit, owner, repo, checkRunId, conclusion, title, summary, annotations)

index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const createCheck = async function (octokit, owner, repo, title, ref) {
3838
repo,
3939
name: title,
4040
head_sha: ref,
41-
status: 'in_progress',
41+
status: 'in_progress'
4242
})
4343
return checkRunId
4444
} catch (err) {
@@ -82,9 +82,9 @@ const stats = function (annotations) {
8282
annotations.push(annotation)
8383
return acc
8484
}, {})
85-
const failureCount = (annotationsPerLevel['failure'] || []).length || 0
86-
const warningCount = (annotationsPerLevel['warning'] || []).length || 0
87-
const noticeCount = (annotationsPerLevel['notice'] || []).length || 0
85+
const failureCount = (annotationsPerLevel.failure || []).length || 0
86+
const warningCount = (annotationsPerLevel.warning || []).length || 0
87+
const noticeCount = (annotationsPerLevel.notice || []).length || 0
8888
return { failureCount, warningCount, noticeCount }
8989
}
9090

@@ -116,15 +116,15 @@ const booleanValue = function (input) {
116116
return /^\s*(true|1)\s*$/i.test(input)
117117
}
118118

119-
const readAnnotationsFile= async function(inputPath) {
119+
const readAnnotationsFile = async function (inputPath) {
120120
const ignoreMissingFileValue = getInput('ignore-missing-file', { required: false }) || 'true'
121121
const ignoreMissingFile = booleanValue(ignoreMissingFileValue)
122122
try {
123123
const inputContent = await fs.readFile(inputPath, 'utf8')
124124
return JSON.parse(inputContent)
125125
} catch (err) {
126126
if (err.code === 'ENOENT' && ignoreMissingFile) {
127-
info(`Ignoring missing file at '${inputPath}' because \'ignore-missing-file\' is true`)
127+
info(`Ignoring missing file at '${inputPath}' because 'ignore-missing-file' is true`)
128128
return null
129129
} else {
130130
throw err
@@ -138,7 +138,7 @@ async function run () {
138138
const inputPath = getInput('input', { required: true })
139139
const title = getInput('title', { required: false })
140140

141-
const octokit = new getOctokit(repoToken)
141+
const octokit = getOctokit(repoToken)
142142
const pullRequest = context.payload.pull_request
143143
let ref
144144
if (pullRequest) {
@@ -174,7 +174,7 @@ async function run () {
174174
start_line: annotation.line,
175175
end_line: annotation.line,
176176
...annotation,
177-
annotation_level: annotationLevel,
177+
annotation_level: annotationLevel
178178
}
179179
})
180180
await updateCheck(octokit, owner, repo, checkRunId, conclusion, title, summary, annotations)

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"lint": "standard index.js",
8+
"lint-fix": "standard --fix index.js",
89
"package": "ncc build index.js -o dist",
910
"test": "npm run lint"
1011
},

0 commit comments

Comments
 (0)