diff --git a/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js b/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js index 10a2d2c6a2..a4c87079f4 100644 --- a/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js +++ b/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js @@ -48,6 +48,23 @@ test('standard', async () => { expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-standard') }) +test('prettier', async () => { + const { pkg } = await generateWithPlugin({ + id: 'eslint', + apply: require('../generator'), + options: { + config: 'prettier' + } + }) + + expect(pkg.scripts.lint).toBeTruthy() + expect(pkg.eslintConfig).toEqual({ + extends: ['plugin:vue/essential', '@vue/prettier'] + }) + expect(pkg.devDependencies).toHaveProperty('eslint-plugin-vue') + expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-prettier') +}) + test('lint on save', async () => { const { pkg } = await generateWithPlugin({ id: 'eslint', @@ -77,7 +94,3 @@ test('lint on commit', async () => { '*.vue': ['vue-cli-service lint', 'git add'] }) }) - -test('prettier', async () => { - // TODO -}) diff --git a/packages/@vue/cli/lib/promptModules/linter.js b/packages/@vue/cli/lib/promptModules/linter.js index b0b8cad03b..fbe8084fa4 100644 --- a/packages/@vue/cli/lib/promptModules/linter.js +++ b/packages/@vue/cli/lib/promptModules/linter.js @@ -31,12 +31,12 @@ module.exports = cli => { name: 'ESLint + Standard config', value: 'standard', short: 'Standard' + }, + { + name: 'ESLint + Prettier', + value: 'prettier', + short: 'Prettier' } - // { - // name: 'ESLint + Prettier', - // value: 'prettier', - // short: 'Prettier' - // } ] }) diff --git a/packages/@vue/eslint-config-prettier/index.js b/packages/@vue/eslint-config-prettier/index.js index 93b228d827..440fc6896d 100644 --- a/packages/@vue/eslint-config-prettier/index.js +++ b/packages/@vue/eslint-config-prettier/index.js @@ -4,6 +4,6 @@ module.exports = { require.resolve('eslint-config-prettier') ], rules: { - 'prettier/prettier': 'error' + 'prettier/prettier': 'warn' } } diff --git a/packages/@vue/eslint-config-prettier/package.json b/packages/@vue/eslint-config-prettier/package.json index cb0b83036f..1e4a6cfdf6 100644 --- a/packages/@vue/eslint-config-prettier/package.json +++ b/packages/@vue/eslint-config-prettier/package.json @@ -22,7 +22,7 @@ "homepage": "https://github.com/vuejs/vue-cli/packages/@vue/eslint-config-prettier#readme", "dependencies": { "eslint-config-prettier": "^2.9.0", - "eslint-plugin-prettier": "^2.4.0", + "eslint-plugin-prettier": "^2.5.0", "prettier": "^1.10.2" } } diff --git a/yarn.lock b/yarn.lock index f8da2757e8..4ba0f1f16e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3221,9 +3221,9 @@ eslint-plugin-node@^5.2.1: resolve "^1.3.3" semver "5.3.0" -eslint-plugin-prettier@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.4.0.tgz#85cab0775c6d5e3344ef01e78d960f166fb93aae" +eslint-plugin-prettier@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.5.0.tgz#39a91dd7528eaf19cd42c0ee3f2c1f684606a05f" dependencies: fast-diff "^1.1.1" jest-docblock "^21.0.0"