Skip to content

Commit

Permalink
fix: upgrade eslint to v5
Browse files Browse the repository at this point in the history
N.b. needs to manually run patterns to lint through the glob module
before linting until eslint/eslint#10587 is resolved. Which might
not be.
  • Loading branch information
achingbrain committed Nov 21, 2018
1 parent a491376 commit 9b0dbf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -56,12 +56,12 @@
"detect-node": "^2.0.4",
"documentation": "^9.0.0-alpha.1",
"es6-promisify": "^6.0.1",
"eslint": "^4.19.0",
"eslint-config-standard": "^11.0.0",
"eslint": "^5.9.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"execa": "^1.0.0",
"filesize": "^3.6.1",
"findup-sync": "^2.0.0",
Expand Down
17 changes: 14 additions & 3 deletions src/lint.js
Expand Up @@ -4,6 +4,8 @@ const CLIEngine = require('eslint').CLIEngine
const path = require('path')
const formatter = CLIEngine.getFormatter()
const userConfig = require('./config/user')
const promisify = require('util').promisify
const glob = promisify(require('glob'))

const FILES = [
'*.js',
Expand Down Expand Up @@ -69,16 +71,25 @@ function checkDependencyVersions () {
}

function runLinter (opts = {}) {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
const cli = new CLIEngine({
useEslintrc: true,
baseConfig: require('./config/eslintrc'),
fix: opts.fix
})

const config = userConfig()
const files = (config.lint && config.lint.files) || FILES
const report = cli.executeOnFiles(files)
const patterns = (config.lint && config.lint.files) || FILES
const files = await Promise.all(patterns.map(pattern => glob(pattern)))
const deduped = Object.keys(files.reduce((acc, cur) => {
cur.forEach(file => {
acc[file] = 1
})

return acc
}, {}))

const report = cli.executeOnFiles(deduped)

console.log(formatter(report.results))

Expand Down

0 comments on commit 9b0dbf6

Please sign in to comment.