mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-20 03:00:57 -05:00
feat(ui): open eslintrc suggestion
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
"babel-eslint": "^8.2.3",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-loader": "^2.0.0",
|
||||
"eslint-plugin-vue": "^4.5.0"
|
||||
"eslint-plugin-vue": "^4.5.0",
|
||||
"launch-editor": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
module.exports = api => {
|
||||
const CONFIG = 'eslintrc'
|
||||
|
||||
// Config file
|
||||
api.describeConfig({
|
||||
id: 'eslintrc',
|
||||
id: CONFIG,
|
||||
name: 'ESLint configuration',
|
||||
description: 'eslint.config.eslint.description',
|
||||
link: 'https://github.com/vuejs/eslint-plugin-vue',
|
||||
@@ -226,4 +228,37 @@ module.exports = api => {
|
||||
if (answers.noFix) args.push('--no-fix')
|
||||
}
|
||||
})
|
||||
|
||||
const OPEN_ESLINTRC = 'vue-eslint-open-eslintrc'
|
||||
|
||||
api.onViewOpen(({ view }) => {
|
||||
if (view.id !== 'vue-project-configurations') {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
api.onConfigRead(({ config }) => {
|
||||
if (config.id === CONFIG) {
|
||||
api.addSuggestion({
|
||||
id: OPEN_ESLINTRC,
|
||||
type: 'action',
|
||||
label: 'eslint.suggestions.open-eslintrc.label',
|
||||
handler () {
|
||||
const file = config.foundFiles.eslint.path
|
||||
console.log('open', file)
|
||||
const launch = require('launch-editor')
|
||||
launch(file)
|
||||
return {
|
||||
keep: true
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
function removeSuggestions () {
|
||||
[OPEN_ESLINTRC].forEach(id => api.removeSuggestion(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,6 +461,11 @@
|
||||
"description": "Lints and fixes files",
|
||||
"noFix": "Do not fix errors"
|
||||
}
|
||||
},
|
||||
"suggestions": {
|
||||
"open-eslintrc": {
|
||||
"label": "Open eslintrc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pwa": {
|
||||
|
||||
Reference in New Issue
Block a user