Eslint-plugin-vue: Provide an option of vue/html-indent to disable the indentation level of 1

Created on 17 Dec 2017  路  5Comments  路  Source: vuejs/eslint-plugin-vue

Tell us about your environment

Please show your full configuration:

{
    extends: 'plugin:vue/recommended',
    parser: 'vue-eslint-parser',
    plugins: ['vue'],
    rules: {
        'vue/html-indent': [2, 4, {
            attribute: 1,
            closeBracket: 0,
        }],
    }
}

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

<template>
    <div class="article">
        <div v-if="foo"></div>
        <slot></slot>
    </div>
</template>

<script>
export default {
    name: 'article',
};
</script>

What did you expect to happen?

<template>
<div class="article">
    <div v-if="foo"></div>
    <slot></slot>
</div>
</template>

<script>
export default {
    name: 'article',
};
</script>

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

I don't want to indent first level node of <template> because it's inconsistent with that in <script>. And sometimes I have to concat no-indentation *.html, *.js, *.css into *.vue. That means that I want they are in the same format.

accepted proposition enhancement indent

Most helpful comment

Thank you for the proposal.

I can do. I'm writing vue/script-indent rule which has baseIndent option now. We can reuse the option for vue/html-indent.

All 5 comments

Hey, thanks for posting this proposal @rainfore :)

@mysticatea what do you think about this? You worked on this rule, so you should be able to quickly estimate effort needed for such an additional setting.
Personally I think it might be kinda useful, being able to set consistent indentation per different code blocks makes sense.

Thank you for the proposal.

I can do. I'm writing vue/script-indent rule which has baseIndent option now. We can reuse the option for vue/html-indent.

@mysticatea I noticed vue/script-indent was added to the README and appears to have been merged and added to the project. However, after updating to 4.1.0 I don't see it included in the rules folder. Will it be added soon? Thanks so much! =)

Hey @mysticatea , I think reusing baseIndent option is a good way. Is this work in progress?
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prograhammer picture prograhammer  路  3Comments

apertureless picture apertureless  路  4Comments

chrisvfritz picture chrisvfritz  路  3Comments

Hyzual picture Hyzual  路  3Comments

casprwang picture casprwang  路  4Comments