Skip to content

Mixing max-attributes-per-line and a minimum number #1110

@jwillp

Description

@jwillp

I would like to do a mix of vue/max-attributes-per-line and a minimum, where I would prefer to have the attributes on one line instead of being multiline, but only up to a certain maximum number.
So somewhat of a mixture between min and max.

I haven't found a way to achieve this. Is there any way to do that?

Or at least, if it is not possible to force attributes to be on one line.

Tell us about your environment

  • ESLint version:
    6.8.0
  • eslint-plugin-vue version:
    6.2.2
  • Node version:
    v12.16.1 + yarn: 1.21.1

Please show your full configuration:

module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        'plugin:vue/essential',
        'plugin:vue/recommended',
        '@vue/standard',
        '@vue/typescript',
        '@vue/typescript/recommended'
    ],
    rules: {
        'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
        'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
        indent: ['error', 4],

        '@typescript-eslint/no-explicit-any': 'off',
        '@typescript-eslint/ban-ts-ignore': 'off',

        'vue/script-indent': ['warn', 4, { baseIndent: 0 }],
        'vue/html-indent': ['warn', 4, { baseIndent: 0, alignVertically: true }],
        'vue/max-attributes-per-line': ['error', {
            singleline: 4,
            multiline: {
                max: 4,
                allowFirstLine: true
            }
        }]
    },
    parserOptions: {
        parser: '@typescript-eslint/parser',
        ecmaVersion: 2020
    }
}

What did you do?

<div class="general-info">
    <figure
        class="avatar avatar-primary"
        data-initials="HW"
    />
</div>

What did you expect to happen?

<div class="general-info">
    <figure  class="avatar avatar-primary" data-initials="HW"  />
</div>

What actually happened?
Nothing, it stays unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions