Skip to content

Commit

Permalink
feat: complete prettier integration
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 16, 2018
1 parent 6e29daa commit 100c5c6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
21 changes: 17 additions & 4 deletions packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -77,7 +94,3 @@ test('lint on commit', async () => {
'*.vue': ['vue-cli-service lint', 'git add']
})
})

test('prettier', async () => {
// TODO
})
10 changes: 5 additions & 5 deletions packages/@vue/cli/lib/promptModules/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
// }
]
})

Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/eslint-config-prettier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
require.resolve('eslint-config-prettier')
],
rules: {
'prettier/prettier': 'error'
'prettier/prettier': 'warn'
}
}
2 changes: 1 addition & 1 deletion packages/@vue/eslint-config-prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 100c5c6

Please sign in to comment.