Skip to content

Commit

Permalink
update: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
TOsmanov committed Dec 19, 2024
1 parent d5949c6 commit a03c475
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,33 +408,32 @@ function execute (command, verbose = false, debug = false, allowFailure = false,
let start = false
let linkcheck = false
let filename = ''
let ver = false
let results = ''
let markdownlintResults = []
let counterError = 0

function printLincheckReport (result) {
function printLincheckReport (result, filename) {
let l = []

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (macos-latest, 18.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (macos-latest, 19.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (macos-latest, 20.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (ubuntu-latest, 18.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (ubuntu-latest, 19.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (ubuntu-latest, 20.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (windows-latest, 18.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (windows-latest, 19.x)

'l' is never reassigned. Use 'const' instead

Check failure on line 416 in linter.js

View workflow job for this annotation

GitHub Actions / buildAndTest (windows-latest, 20.x)

'l' is never reassigned. Use 'const' instead
if (result.match(regexBad)) {
const arr = result.replace(/^\s+|\s+$/g, '').split('\n')
for (const l in arr) {
const str = arr[l]
let ver = false
for (const i in arr) {
const str = arr[i]
if (str.match(regexError)) {
ver = true
}
if (ver && str.match(regexBad)) {
spinnerLint.stop(true)
if (filename) {
counterError += 1
console.log(`${clc.red('✖')} ${counterError}. ${filename.replace(/^\s+|\s+$/g, '').substring(6)}`)
filename = ''
ver = false
l.push(`${clc.red('✖')} ${counterError}. ${filename.replace(/^\s+|\s+$/g, '').substring(6)}`)
}
console.log(` ${str.replace(/^\s+|\s+$/g, '').substring(4)}`)
filename = ''
spinnerLint.start()
l.push(` ${str.replace(/^\s+|\s+$/g, '').substring(4)}`)
}
}
}
spinnerLint.stop(true)
console.log(l.join('\n'))
spinnerLint.start()
}

function printMarkdownReport (markdownlintResults, counterError) {
Expand Down Expand Up @@ -482,7 +481,9 @@ function execute (command, verbose = false, debug = false, allowFailure = false,
}
if (linkcheck) {
if (s.match(regexFile)) {
printLincheckReport(`${results}\n`)
if (results.length > 0) {
printLincheckReport(`${results}\n`, filename)
}
results = ''
filename = s
}
Expand Down Expand Up @@ -514,7 +515,7 @@ function execute (command, verbose = false, debug = false, allowFailure = false,
counterError = printMarkdownReport(markdownlintResults, counterError)
markdownlintResults = []
}
printLincheckReport(results)
printLincheckReport(`${results}\n`, filename)
spinnerLint.stop(true)
if (verbose) {
console.log(`Subprocess "Linter" exited with code ${code}`)
Expand Down

0 comments on commit a03c475

Please sign in to comment.