Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upgrade eslint to v5 #298

Merged
merged 2 commits into from Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pls change to https://www.npmjs.com/package/globby which already has a promise api and is based on https://github.com/mrmlnc/fast-glob which is faster than glob

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


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