question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make `max-attributes-per-line` work only when over maximum line length

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.16.0
  • eslint-plugin-vue Version: 4.2.0
  • Node Version: 9.2.0

Please show your full configuration:

.eslintrc.js
module.exports = {
  extends: [
    'standard',
    'plugin:vue/recommended',
    'prettier',
  ],
  plugins: ['prettier'],
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module',
  },
  env: {
    browser: true,
    jest: true,
  },
  rules: {
    'prettier/prettier': 'error',

    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? ['error'] : ['warn'],

    'no-param-reassign': ['error', { props: false }],

    'vue/html-closing-bracket-newline': [
      'error',
      {
        singleline: 'never',
        multiline: 'always',
      },
    ],

    'vue/html-closing-bracket-spacing': [
      'error',
      {
        startTag: 'never',
        endTag: 'never',
        selfClosingTag: 'always',
      },
    ],
  },
}

What did you do? Please include the actual source code causing the issue.

<MyComponent lorem="1" ipsum="2" />

<MyComponent lorem="1" ipsum="2" @click="longlonglonglonglonglongFunctionName" @change="longlonglonglonglonglongFunctionName2" />

What did you expect to happen? What i want is max-attributes-per-line rule should be available only when over maximum line length option, like printWidth defined in prettier.

For example, I set printWidth: 80 in prettier:

<MyComponent lorem="1"  ipsum="2" />

<MyComponent 
  lorem="1"
  ipsum="2"
  @click="longlonglonglonglonglongFunctionName" 
  @change="longlonglonglonglonglongFunctionName2"
/>

What actually happened? Please include the actual, raw output from ESLint.

As the default value of multilple option in max-attributes-per-line rule is 1, so the output will be:

<MyComponent
  lorem="1"
  ipsum="2"
/>

<MyComponent 
  lorem="1"
  ipsum="2"
  @click="longlonglonglonglonglongFunctionName" 
  @change="longlonglonglonglonglongFunctionName2"
/>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mysticateacommented, Feb 9, 2018

Since the value of attributes is statements or expressions, so it’s difficult to work together with other whitespace rules in ESLint.

Closing as no plan to add the option for now.

0reactions
harol-rodriguezcommented, Aug 12, 2019

use prettier

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable eslint rule max line length for paragraph in ...
Is there a way to disable lint for paragraph text like above? Also, how to increase the line length from 100 to 120?...
Read more >
vue/max-len
This rule enforces a maximum line length to increase code readability and maintainability. This rule is the similar rule as core max-len ...
Read more >
Maximum line length restriction - Discussions on Python.org
As per PEP, the maximum line length is still 79. Its time to update this. ... okay to occasionally go over the limit...
Read more >
max-line-length - Stylelint
Lines that exceed the maximum length but contain no whitespace (other than at the beginning of the line) are ignored. When evaluating the...
Read more >
The Black code style - Black 22.12.0 documentation
I hope some of the examples above show you that there are many ways in which you can do it. Line length#. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found