Skip to content

Instantly share code, notes, and snippets.

@cstumph
Created August 16, 2019 22:38
Show Gist options
  • Save cstumph/7d143e6ed803e91b2614aee6d08ea9e8 to your computer and use it in GitHub Desktop.
Save cstumph/7d143e6ed803e91b2614aee6d08ea9e8 to your computer and use it in GitHub Desktop.
linting_report.js
const fs = require('fs')
const text = fs.readFileSync('./lint errors').toString()
const txtArray = text.split('*')
function renderUniques (array) {
const set = new Set(array)
console.log(set)
return Array.from(set)
}
function renderCounts () {
const map = {}
txtArray.forEach((item) => {
const ruleName = item.split(' ').pop()
console.log('Rule:', ruleName)
!map[ruleName] ? map[ruleName] = 1 : map[ruleName]++
})
console.log(map)
}
function writeToFile (array, filename) {
const out = new Uint8Array(Buffer.from(array.join('\r\n')))
fs.writeFileSync(`./${filename}`, out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment