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.

Request to allow vue component js to optionally start at an indentation level of 1 when wrapped in <script></script>

See original GitHub issue

The version of ESLint you are using: v4.3.0

The version of eslint-plugin-vue you are using: 3.8.0

The problem you want to solve: Javascript in a vue component expects an initial indentation level of 0 despite being wrapped in <script></script>. The following currently reports an error:

<script>
    export default {

    };
</script>

Your take on the correct solution to problem: When modifying a vue component, the linter should optionally allow for an initial indentation level of 1 when wrapped in <script></script>.

The eslint-plugin-html plugin solves the indentation level issue for html files, and works nicely with eslint to only lint the javascript portion of vue components. Ideally eslint-plugin-vue could work in a similar way while also linting the template portion of the component (as it currently does).

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:20
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

17reactions
chrisvfritzcommented, Nov 24, 2017

I think it makes sense as a dedicated rule, because whether a project wants to start at indentation 0 or 1, they’ll probably want to enforce consistency. I think ideally, we’d also provide the ability to configure each tag type individually, because the most common convention I see is:

  • 1 for <template>
  • 0 for <script>
  • 0 for <style>

I’d also suggest that as the default, with the rule in the recommended category.

7reactions
MicroDroidcommented, Jan 11, 2018

It’s still unclear how to use this new vue/script-indent rule. I’ve added something like this to my .eslintrc:

"vue/script-indent": [
    "error",
    "tab",
    {"baseIndent": 1}
],

I still got warnings from the indent rule. I removed the indent rule, now other non-.Vue files don’t get indentation linting properly. Also vue/script-indent is also applying its indentation linting on non-.Vue files like .js files, causing my normal .js files to have indentation starting at 1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Components Basics - Vue.js
This documents all the events that a component emits and optionally validates them. It also allows Vue to avoid implicitly applying them as...
Read more >
CodeMirror 5 User Manual
CodeMirror is a code-editor component that can be embedded in Web pages. ... Modes are JavaScript programs that help color (and optionally indent)...
Read more >
Documentation Style Guide - GitLab Docs
Special styling is required. Reviewed and approved by a technical writer. Heading levels in Markdown. Each documentation page begins with a level 1...
Read more >
Node.js v19.3.0 Documentation
The store is accessible to any asynchronous operations created within the callback. The optional args are passed to the callback function. If the...
Read more >
Prettier 1.19: Long awaited Vue option, TypeScript 3.7 and ...
This release adds the long awaited `--vue-indent-script-and-style` option, support for TypeScript 3.7 and some cutting edge JavaScript ...
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