prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.47k stars 255 forks source link

Disable vue/html-self-closing #64

Closed ykzts closed 5 years ago

ykzts commented 6 years ago

Conflict with the Prettier.

lydell commented 6 years ago

Hi! Can you show a problematic example?

Edit: Never mind, I get it now. Not sure if this should be a special rule though, since you might want to enforce custom components to be self closing.

ykzts commented 6 years ago

package.json

{
  "devDependencies": {
    "eslint": "^5.9.0",
    "eslint-config-prettier": "^3.2.0",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-vue": "^4.7.1",
    "prettier": "^1.15.2"
  },
  "scripts": {
    "lint": "eslint index.vue",
    "lint2": "eslint index2.vue"
  }
}

.eslintrc.js

module.exports = {
  extends: [
    'plugin:vue/recommended',
    'plugin:prettier/recommended',
    'prettier/vue'
  ]
}

index.vue (with /)

<template>
  <img src="img.png" alt="" />
</template>

index2.vue (without /)

<template>
  <img src="img.png" alt="">
</template>

Result

$ yarn install
$ yarn lint
yarn run v1.12.1
warning package.json: No license field
$ eslint index.vue

/home/ykzts/local/src/aaa/index.vue
  2:3  error  Disallow self-closing on HTML void elements (<img/>)  vue/html-self-closing

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.$ yarn lint2
yarn run v1.12.1
warning package.json: No license field
$ eslint index2.vue

/home/ykzts/local/src/aaa/index2.vue
  2:28  error  Insert `·/`  prettier/prettier

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lydell commented 5 years ago

Released in 3.3.0. Thanks!

ykzts commented 5 years ago

Nice!