@@ -4,6 +4,8 @@ jest.mock('inquirer')
44const invoke = require ( '../lib/invoke' )
55const { expectPrompts } = require ( 'inquirer' )
66const create = require ( '@vue/cli-test-utils/createTestProject' )
7+ const stringifyJS = require ( 'javascript-stringify' )
8+ const toJS = v => `module.exports = ${ stringifyJS ( v , null , 2 ) } `
79
810async function createAndInstall ( name ) {
911 const project = await create ( name , {
@@ -26,11 +28,11 @@ async function assertUpdates (project) {
2628 'pre-commit' : 'lint-staged'
2729 } )
2830
29- const eslintrc = JSON . parse ( await project . read ( '.eslintrc' ) )
30- expect ( eslintrc ) . toEqual ( {
31+ const eslintrc = await project . read ( '.eslintrc.js' )
32+ expect ( eslintrc ) . toEqual ( toJS ( {
3133 root : true ,
3234 extends : [ 'plugin:vue/essential' , '@vue/airbnb' ]
33- } )
35+ } ) )
3436
3537 const lintedMain = await project . read ( 'src/main.js' )
3638 expect ( lintedMain ) . toMatch ( ';' ) // should've been linted in post-generate hook
@@ -78,11 +80,11 @@ test('invoke with existing files', async () => {
7880 // mock existing vue.config.js
7981 await project . write ( 'vue.config.js' , `module.exports = { lintOnSave: true }` )
8082
81- const eslintrc = JSON . parse ( await project . read ( '.eslintrc' ) )
82- expect ( eslintrc ) . toEqual ( {
83+ const eslintrc = await project . read ( '.eslintrc.js' )
84+ expect ( eslintrc ) . toEqual ( toJS ( {
8385 root : true ,
8486 extends : [ 'plugin:vue/essential' , 'eslint:recommended' ]
85- } )
87+ } ) )
8688
8789 await project . run ( `${ require . resolve ( '../bin/vue' ) } invoke eslint --config airbnb --lintOn commit` )
8890
@@ -104,13 +106,13 @@ test('invoke with existing files (yaml)', async () => {
104106 pkg . devDependencies [ '@vue/cli-plugin-eslint' ] = '*'
105107 await project . write ( 'package.json' , JSON . stringify ( pkg , null , 2 ) )
106108
107- const eslintrc = JSON . parse ( await project . read ( '.eslintrc' ) )
108- expect ( eslintrc ) . toEqual ( {
109+ const eslintrc = await project . read ( '.eslintrc.js' )
110+ expect ( eslintrc ) . toEqual ( toJS ( {
109111 root : true ,
110112 extends : [ 'plugin:vue/essential' , 'eslint:recommended' ]
111- } )
113+ } ) )
112114
113- await project . rm ( `.eslintrc` )
115+ await project . rm ( `.eslintrc.js ` )
114116 await project . write ( `.eslintrc.yml` , `
115117root: true
116118extends:
0 commit comments