- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 681
Request to allow vue component js to optionally start at an indentation level of 1 when wrapped in <script></script> #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same proposition.
|
@armano2 That seems to be talking about the indentation level of html elements in the |
@prurigro it has to be done on parser level -> right now code is parsed first by html parser after that part of code is passed to espree (eslint) and they are dealing with it, adding this feature has to be done before passing code into espree. its possbile, but i don't think so that there is going to be anyone to do that before new parser will be released, #116. @mysticatea can you confirm/deny this? |
Thank you for this issue. I confirmed. As far as I know, the For now, you can use {
"indent": "off",
"indent-legacy": ["error", 4]
} |
In #145, I'm making almost full-spec indent rule eventually because |
#145 is now merged and we could work on this, but replacing core rule with tailored one seem not like the best solution to me. Can we perhaps somehow alter the parsed AST so that the core rule sees different indentation @mysticatea ? |
No, it cannot do in Plugin preprocessor can modify source code text and the linting result. The plugins which have preprocessor can support autofix since <script>
aaa()
bbb()
ccc()
ddd()
</script> I think it cannot be unindented because |
I'm not sure I understand you @mysticatea I think we should detect indentation of the first line and treat it as the base indentation, so the |
You are right. But I think that we cannot make AST like that the core |
Ah now I get it @mysticatea. Makes sense, though I'm wondering how did guys figured it out in |
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:
I'd also suggest that as the default, with the rule in the |
Okay, that being said I don't think it's something that blocks us from releasing 4.0. We can work on this simultaneously and for now put information in readme that if someone wants to have extra indent in script, he might just use indent-legacy rule from eslint. |
Especially if in the end we're going to put this in |
Agreed. 👍 |
Hi, just question, whether this issue was fixed yet? |
@tronjs It would have been closed if it was. |
* Chore: extract common part of indent * Chore: refactor tests of html-indent * New: vue/script-indent (fixes #118) * Chore: upgrade deps * Chore: fix test script - To dedupe deps * Chore: revive lost tests * Update: add alignAttributesVertically * change category * add comments
It's still unclear how to use this new "vue/script-indent": [
"error",
"tab",
{"baseIndent": 1}
], I still got warnings from the |
@MicroDroid Would you open new issue with details? |
@mysticatea I just tried again and removed the |
But the Also, it seems you cannot use |
I actually ended up with #344 (Posting here so people having the same issue in this conversation can link to there) |
Is there a solution for this? |
I opened #418 for more compatibility with indent. |
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: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!
The text was updated successfully, but these errors were encountered: