File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 26
26
"babel-eslint" : " ^8.2.3" ,
27
27
"eslint" : " ^4.19.1" ,
28
28
"eslint-loader" : " ^2.0.0" ,
29
- "eslint-plugin-vue" : " ^4.5.0"
29
+ "eslint-plugin-vue" : " ^4.5.0" ,
30
+ "launch-editor" : " ^2.2.1"
30
31
}
31
32
}
Original file line number Diff line number Diff line change 1
1
module . exports = api => {
2
+ const CONFIG = 'eslintrc'
3
+
2
4
// Config file
3
5
api . describeConfig ( {
4
- id : 'eslintrc' ,
6
+ id : CONFIG ,
5
7
name : 'ESLint configuration' ,
6
8
description : 'eslint.config.eslint.description' ,
7
9
link : 'https://github.com/vuejs/eslint-plugin-vue' ,
@@ -226,4 +228,37 @@ module.exports = api => {
226
228
if ( answers . noFix ) args . push ( '--no-fix' )
227
229
}
228
230
} )
231
+
232
+ const OPEN_ESLINTRC = 'vue-eslint-open-eslintrc'
233
+
234
+ api . onViewOpen ( ( { view } ) => {
235
+ if ( view . id !== 'vue-project-configurations' ) {
236
+ removeSuggestions ( )
237
+ }
238
+ } )
239
+
240
+ api . onConfigRead ( ( { config } ) => {
241
+ if ( config . id === CONFIG ) {
242
+ api . addSuggestion ( {
243
+ id : OPEN_ESLINTRC ,
244
+ type : 'action' ,
245
+ label : 'eslint.suggestions.open-eslintrc.label' ,
246
+ handler ( ) {
247
+ const file = config . foundFiles . eslint . path
248
+ console . log ( 'open' , file )
249
+ const launch = require ( 'launch-editor' )
250
+ launch ( file )
251
+ return {
252
+ keep : true
253
+ }
254
+ }
255
+ } )
256
+ } else {
257
+ removeSuggestions ( )
258
+ }
259
+ } )
260
+
261
+ function removeSuggestions ( ) {
262
+ [ OPEN_ESLINTRC ] . forEach ( id => api . removeSuggestion ( id ) )
263
+ }
229
264
}
Original file line number Diff line number Diff line change 461
461
"description" : " Lints and fixes files" ,
462
462
"noFix" : " Do not fix errors"
463
463
}
464
+ },
465
+ "suggestions" : {
466
+ "open-eslintrc" : {
467
+ "label" : " Open eslintrc"
468
+ }
464
469
}
465
470
},
466
471
"pwa" : {
You can’t perform that action at this time.
0 commit comments