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.

[vue/html-indent] wrong indentation reported with just one prop/attr

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.16.0
  • eslint-plugin-vue Version: 4.2.2

Please show your full configuration:

module.exports = {
  root: true,
  extends: [
    'plugin:vue/recommended'
  ],
  parserOptions: {
    parser: 'babel-eslint'
  },
  plugins: ['vue'],
  rules: {
    'vue/html-indent': ['error', 2,  {
      alignAttributesVertically: true
    }],
    'vue/html-self-closing': ['error', {
      html: {
        void: 'never',
        normal: 'never',
        component: 'never'
      }
    }],
    'vue/max-attributes-per-line': ['error', {
      singleline: 3,
      multiline: {
        max: 1,
        allowFirstLine: false,
      }
    }],
  },
};

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

<template>
  <div>
    <my-component
      :foo="true">
    </my-component>
  </div>
</template>

Reproduction online

What did you expect to happen?

I expect vue/html-indent error to not being reported in that case

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

 4:1 Expected indentation of 4 spaces but found 6 spaces. (vue/html-indent)

But if you add another prop after foo then it works as expected:

<my-component
  :foo="true"
  :bar="false">
</my-component>

Am i missing something in my configuration? 🤔

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
mysticateacommented, Feb 3, 2018

Thank you for the report.

I confirmed it, and I will fix it.

0reactions
iujlakicommented, Mar 26, 2018

Hi,

The versions are:

“eslint-plugin-vue”: “4.2.2”, “vue-eslint-parser”: “2.0.2”

and our .eslintrc.js file contains:

// https://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true,
  },
  // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
  // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
  extends: ['plugin:vue/recommended', 'airbnb-base'],
  // required to lint *.vue files
  plugins: [
    'vue'
  ],
  // check if imports actually resolve
  settings: {
    'import/resolver': {
      webpack: {
        config: 'build/webpack.base.conf.js'
      }
    }
  },
  // add your custom rules here
  rules: {
    // don't require .vue extension when importing
    'import/extensions': ['error', 'always', {
      js: 'never',
      vue: 'never'
    }],
    // disallow reassignment of function parameters
    // disallow parameter object manipulation except for specific exclusions
    'no-param-reassign': ['error', {
      props: true,
      ignorePropertyModificationsFor: [
        'state', // for vuex state
        'acc', // for reduce accumulators
        'e' // for e.returnvalue
      ]
    }],
    // allow optionalDependencies
    'import/no-extraneous-dependencies': ['error', {
      optionalDependencies: ['test/unit/index.js']
    }],
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
}

Many thanks! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/html-indent
This rule enforces a consistent indentation style in <template> . ... If this is a number, it's the number of spaces for one...
Read more >
vue eslint html,[vue/html-indent] wrong indentation reported ...
Hi,. The versions are: "eslint-plugin-vue": "4.2.2",. "vue-eslint-parser": "2.0.2". and our .eslintrc.js file contains:.
Read more >
Wrong indentation of <script> and <style> in .vue files
Content of <script> and <style> are indented. Workaround: Add "script" and "style" entries into settings "Editor > Code Style > HTML | Other...
Read more >
@vue/eslint-plugin - npm
Start using @vue/eslint-plugin in your project by running `npm i ... @vue/html-indent, enforce consistent indentation in <template>.
Read more >
Changelog - Cypress Documentation
The Chrome web security configuration tooltip will now be shown only if chromeWebSecurity is set to false when using a non-chromium browser. Fixes...
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