eslint-plugin-vue-pug icon indicating copy to clipboard operation
eslint-plugin-vue-pug copied to clipboard

Indentation broken when "vue/max-attributes-per-line" reformats line

Open sid-6581 opened this issue 3 years ago • 10 comments

When vue/max-attributes-per-line reformats the line, the attributes end up completely unindented:

  a(href="link" @click="click")

becomes:

  a(
href="link"
@click="click")

when ideally it should be:

  a(
    href="link"
    @click="click"
  )

I'm not sure if this plugin alone is enough to lint things like indentation for the pug templates in SFCs? I know I can use prettier/plugin-pug with prettier, but I would prefer to avoid prettier altogether and rely on just eslint.

sid-6581 avatar May 20 '22 19:05 sid-6581

I am planning to add some pug-specific rules to this plugin, for example for attribute delimiters. I need to look into indentation too. I think in eslint-plugin-vue this rule just adds a newline and then another rule fixes indentation (even in html just a newline would look weird). Since the pug parser seems to understand the unindented version I will probably create a rule that lints pug attribute indents. In eslint-plugin-vue this is handled by vue/html-indent I think, which is currently disabled for eslint-plugin-vue-pug because it has some issues with pug templates.

rashfael avatar May 20 '22 22:05 rashfael

That would be fantastic. Handling the indentation, and also the closing parenthesis on a new line, would be a great improvement. I'd be happy to contribute if needed, feel free to ping me if so.

sid-6581 avatar May 21 '22 16:05 sid-6581

@sid-6581 @rashfael any news on this? We're currently trying to integrate with this plugin and we're having the exact same issue 🙏

bjufre avatar Sep 06 '22 20:09 bjufre

I've been quite busy with some other projects these last few months, but adding pug indent rules is definitely on my list of things to do. I can't tell you when, though, sorry.

rashfael avatar Sep 07 '22 06:09 rashfael

@rashfael any news on this? is this issue still in work or abandoned?

Cl0ser01 avatar Nov 27 '23 19:11 Cl0ser01

I haven't done any work on this issue, but the plugin is not abandoned. I'm still using it and pug myself.

rashfael avatar Nov 28 '23 09:11 rashfael

Same issue and finnally used vim visual selection and regex to fix indent manually😂

Tipwheal avatar Feb 06 '24 04:02 Tipwheal

I'm disabling these rules alongside with prettier-plugin-pug to enforcing them

      "vue/first-attribute-linebreak": ["off"]
      "vue/html-closing-bracket-newline": ["off"]
      "vue/html-closing-bracket-spacing": ["off"]
      "vue/max-attributes-per-line": ["off"]
      "vue/multiline-html-element-content-newline": ["off"]
      "vue/mustache-interpolation-spacing": ["off"]
      "vue/no-multi-spaces": ["off"]
      "vue/no-spaces-around-equal-signs-in-attribute": ["off"]
      "vue/singleline-html-element-content-newline": ["off"]
      "vue/attributes-order": ["off"]
      "vue/component-tags-order": ["off"]
      "vue/order-in-components": ["off"]
      "vue/html-comment-content-newline": ["off"]
      "vue/html-comment-content-spacing": ["off"]
      "vue/html-comment-indent": ["off"]
      "vue/new-line-between-multi-line-property": ["off"]
      "vue/padding-line-between-tags": ["off"]
      "vue/padding-line-between-blocks": ["off"]

SkyaTura avatar Feb 26 '24 18:02 SkyaTura

@rashfael Any news about fixing this issue?

icebob avatar Aug 05 '24 14:08 icebob