From d84df9ac1351259830ad7efeadb8a141bc1f7227 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 15 Jan 2018 20:11:49 -0500 Subject: [PATCH] feat: support Prettier eslint config (pending) waiting on https://github.com/prettier/eslint-plugin-prettier/pull/78 --- packages/@vue/cli-plugin-eslint/generator.js | 5 +++- packages/@vue/eslint-config-prettier/index.js | 9 ++++++ .../@vue/eslint-config-prettier/package.json | 7 ++++- yarn.lock | 30 +++++++++++++++++-- 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 packages/@vue/eslint-config-prettier/index.js diff --git a/packages/@vue/cli-plugin-eslint/generator.js b/packages/@vue/cli-plugin-eslint/generator.js index 15b5f2bb6b..88f3328311 100644 --- a/packages/@vue/cli-plugin-eslint/generator.js +++ b/packages/@vue/cli-plugin-eslint/generator.js @@ -26,7 +26,10 @@ module.exports = (api, { config, lintOn = [] }) => { '@vue/eslint-config-standard': '^3.0.0-alpha.1' }) } else if (config === 'prettier') { - // TODO + pkg.eslintConfig.extends.push('@vue/prettier') + Object.assign(pkg.devDependencies, { + '@vue/eslint-config-prettier': '^3.0.0-alpha.1' + }) } else { // default pkg.eslintConfig.extends.push('eslint:recommended') diff --git a/packages/@vue/eslint-config-prettier/index.js b/packages/@vue/eslint-config-prettier/index.js new file mode 100644 index 0000000000..93b228d827 --- /dev/null +++ b/packages/@vue/eslint-config-prettier/index.js @@ -0,0 +1,9 @@ +module.exports = { + plugins: ['prettier'], + extends: [ + require.resolve('eslint-config-prettier') + ], + rules: { + 'prettier/prettier': 'error' + } +} diff --git a/packages/@vue/eslint-config-prettier/package.json b/packages/@vue/eslint-config-prettier/package.json index 4cf5511f66..cb0b83036f 100644 --- a/packages/@vue/eslint-config-prettier/package.json +++ b/packages/@vue/eslint-config-prettier/package.json @@ -19,5 +19,10 @@ "bugs": { "url": "https://github.com/vuejs/vue-cli/issues" }, - "homepage": "https://github.com/vuejs/vue-cli/packages/@vue/eslint-config-prettier#readme" + "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", + "prettier": "^1.10.2" + } } diff --git a/yarn.lock b/yarn.lock index cbd0c767bd..f8da2757e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1153,7 +1153,7 @@ babel-plugin-syntax-object-rest-spread@^6.13.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5" -babel-plugin-transform-es2015-modules-commonjs@^6.24.1, babel-plugin-transform-es2015-modules-commonjs@^6.26.0: +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" dependencies: @@ -3141,6 +3141,12 @@ eslint-config-airbnb-base@^12.1.0: dependencies: eslint-restricted-globals "^0.1.1" +eslint-config-prettier@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" + dependencies: + get-stdin "^5.0.1" + eslint-config-standard@^11.0.0-beta.0: version "11.0.0-beta.0" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-11.0.0-beta.0.tgz#f8afe69803d95c685a4b8392b8793188eb03cbb3" @@ -3215,6 +3221,13 @@ 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" + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + eslint-plugin-promise@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz#54b7658c8f454813dc2a870aff8152ec4969ba75" @@ -3558,6 +3571,10 @@ fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + fast-extend@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/fast-extend/-/fast-extend-0.0.2.tgz#f5ec42cf40b9460f521a6387dfb52deeed671dbd" @@ -3963,6 +3980,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stdin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" + get-stream@^2.2.0: version "2.3.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" @@ -5125,6 +5146,10 @@ jest-diff@^22.1.0: jest-get-type "^22.1.0" pretty-format "^22.1.0" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + jest-docblock@^22.1.0: version "22.1.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-22.1.0.tgz#3fe5986d5444cbcb149746eb4b07c57c5a464dfd" @@ -7182,7 +7207,7 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@^1.7.0: +prettier@^1.10.2, prettier@^1.7.0: version "1.10.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93" @@ -9223,7 +9248,6 @@ vue-jest@yyx990803/vue-jest: version "1.4.0" resolved "https://codeload.github.com/yyx990803/vue-jest/tar.gz/2ce12141b70161893982325ea72f1f2dcfdc6f04" dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.26.0" chalk "^2.1.0" find-babel-config "^1.1.0" js-beautify "^1.6.14"