Skip to content

Disable vue/html-self-closing#64

Closed
ykzts wants to merge 1 commit intoprettier:masterfrom
ykzts:html-self-closing
Closed

Disable vue/html-self-closing#64
ykzts wants to merge 1 commit intoprettier:masterfrom
ykzts:html-self-closing

Conversation

@ykzts
Copy link
Copy Markdown

@ykzts ykzts commented Nov 10, 2018

Conflict with the Prettier.

@lydell
Copy link
Copy Markdown
Member

lydell commented Nov 11, 2018

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
Copy link
Copy Markdown
Author

ykzts commented Nov 11, 2018

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 lydell closed this in d14d111 Nov 11, 2018
@ykzts ykzts deleted the html-self-closing branch November 11, 2018 11:03
@lydell
Copy link
Copy Markdown
Member

lydell commented Nov 11, 2018

Released in 3.3.0. Thanks!

@ykzts
Copy link
Copy Markdown
Author

ykzts commented Nov 11, 2018

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants