8000 `html-self-closing` with `--fix` doesn't normalise whitespace in opening tag · Issue #199 · vuejs/eslint-plugin-vue · GitHub
[go: up one dir, main page]

Skip to content

html-self-closing with --fix doesn't normalise whitespace in opening tag #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
axelboc opened this issue Oct 5, 2017 · 4 comments
Closed

Comments

@axelboc
Copy link
axelboc commented Oct 5, 2017
  • ESLint version: 4.8.0
  • eslint-plugin-vue version: 3.13.0
  • Node version: 6.11.3
{
  "extends": [
    "eslint-config-airbnb",
    "plugin:vue/recommended"
  ],
  "rules": {
    "vue/attribute-hyphenation": "error",
    "vue/html-quotes": "error",
    "vue/html-self-closing": "error",
    "vue/mustache-interpolation-spacing": "error",
    "vue/no-dupe-keys": "error",
    "vue/no-duplicate-attributes": "error",
    "vue/no-multi-spaces": "error",
    "vue/no-reserved-keys": "error",
    "vue/no-shared-component-data": "error",
    "vue/no-template-key": "error",
    "vue/order-in-components": "error",
    "vue/require-prop-types": "error",
    "vue/require-render-return": "error",
    "vue/require-valid-default-prop": "error",
    "vue/return-in-computed-property": "error",
    "vue/v-bind-style": "error",
    "vue/v-on-style": "error"
  }
}

Input

<input />
<slot />
<svg><use xlink:href="..."></use></svg>

Expected output

<input>
<slot></slot>
<svg><use xlink:href="..." /></svg>

Actual output

<input >
<slot ></slot>
<svg><use xlink:href="..."/></svg>

The rule just replaces /> with > (or > with />) in the opening tag without considering that a space may need to be removed or added.

@michalsnik
Copy link
Member

Good catch @axelboc , thank you for posting this issue :)

@michalsnik michalsnik added this to the v4.0.0 - Official release milestone Oct 9, 2017
@mysticatea
Copy link
Member
mysticatea commented Oct 20, 2017

Yes, the rule does not consider spacing. Another rule should handle spacing. Maybe vue/space-before-tag-closing rule.

"vue/space-before-tag-closing": ["error", {
    "normal": {
        "afterTagName": "always"/"never",
        "afterAttributeName": "always"/"never",
        "afterEqual": "always"/"never",
        "afterAttributeValue": "always"/"never",
    },
    "selfClosing": {
        "afterTagName": "always"/"never",
        "afterAttributeName": "always"/"never",
        "afterEqual": "always"/"never",
        "afterAttributeValue": "always"/"never",
    }
}]

@michalsnik
Copy link
Member

Sounds like a good idea to me @mysticatea. Each rule should fix what it reports, but if we'd change the fix method here to apply proper spacing it would additionally fix something it wouldn't normally report.

Seems like there is a similar rule for JSX: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md

I think we should do the same :) I'll create a dedicated proposal in separate issue. I also think it can land in 4.1

@michalsnik
Copy link
Member

Closing in favor of #229

< 6DF9 /div>

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

No branches or pull requests

3 participants
0