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.

script-indent make me crazy!!!!!!!

See original GitHub issue

Tell us about your environment

  • ESLint Version: ^4.15.0
  • eslint-plugin-vue Version: ^4.0.0
  • Node Version: ^8.9.0
  • IDE: webstorm 2017.2.5

Please show your full configuration:

// https://eslint.org/docs/user-guide/configuring
module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true
  },
  extends: [
    // 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.
    'plugin:vue/essential',
    // https://github.com/standard/standard/blob/master/docs/RULES-en.md
    'standard'
  ],
  // required to lint *.vue files
  plugins: [
    'vue'
  ],
  // add your custom rules here
  rules: {
    // // 没找到解决方案, 一格式化webstorm script标签下面就会缩进,一缩进,eslint就报警。
    // // 只能从根源把他且了。
    // 'indent': ['off'],
    // allow async-await
    'generator-star-spacing': 'off',
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
}

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

<template>
  <div id="app">
    
  </div>
</template>

<script>
 export default {
   name: 'App'
 }
</script>

What did you expect to happen?

<template>
  <div id="app">
    
  </div>
</template>

<script>
  // attension here. it is about 2 indent before javascript code
   export default {
     name: 'App'
   }
</script>

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

This happend when i command in npm run dev

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 0 spaces but found 2  
  src\App.vue:10:1
    export default {
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 2 spaces but found 4  
  src\App.vue:11:1
      name: 'App'
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 0 spaces but found 2  
  src\App.vue:12:1
    }
   ^

As you can see above. This is not my expect things. Does any config to avoid these happen?

Otherwise, i may closing the indent config.although it is not a good experience.

Issue Analytics

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

github_iconTop GitHub Comments

99reactions
BarryZhancommented, Apr 3, 2018

If you are using webstorm, you can File => Setting => Editor => Code Style => HTML add Do not indent children of rule to script

85reactions
leeuwdcommented, Jul 20, 2018

When working with *.vue files, this seems a better option to me: to disable the indent rule only for Vue files and set a base indent:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  'extends': [
    'plugin:vue/strongly-recommended'
  ],
  rules: {
    'indent': ['error', 2],
    'vue/script-indent': [
      'error',
      2,
      { 'baseIndent': 1 }
    ],
  },
  'overrides': [
    {
      'files': ['*.vue'],
      'rules': {
        'indent': 'off'
      }
    }
  ]
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-cli3 eslint vue/script-indent conflicting with compiler
error: Expected indentation of 32 spaces but found 24 spaces (vue/script-indent). What's causing this weird conflict?
Read more >
vue/script-indent
Rule Details #. This rule enforces a consistent indentation style in <script> . The default style is 2 spaces.
Read more >
Roblox Script Not Auto Indenting? - Code Review - DevForum
When ever I create a new line when i'm scripting, it doesn't automatically indent and it's driving me crazy and it wastes alot...
Read more >
Vue 设置Script 标签首层不缩进 - 简书
script-indent make me crazy !!!!!!! #362 · enforce consistent indentation in <script> (vue/script-indent).
Read more >
How To Configure Vue Cli 4 With Eslint + Airbnb Rules + ...
Create a project with Vue CLI 3 Select TypeScript support + ESLint + Airbnb config this will result in the ... eslint plugin...
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