简体   繁体   中英

Eslint - How to Indent Import Export Statements

I just upgraded my Eslint after a long time and all of a sudden, I have a lot of errors. Of note & issues raised below is indentation . Maybe its worth mentioning that I use tabs instead of spaces for my indentation

Problem: My import values are indented as per the eslint indentation terminology "first". "first" basically means, all additional declarations are indented to align with the first property. See this:

在此处输入图片说明

Solutions I tried: Here is what my indentation rules look like within '.eslintrc' file:

"indent" : [ 1, "tab", {
    "FunctionExpression": {
        "body": 1,
        "parameters": "first" },
    "VariableDeclarator": {
        "var" : 2,
        "let" : 2,
        "const" : 3
    },
    "MemberExpression": 0,
    "FunctionDeclaration": {
        "parameters": "first" },
    "ObjectExpression" : "first"
}],

Even though I am using tab , not space for indetation, I still had to use the VariableDeclarator rule above to align all the vars/lets/constants etc. However, import & export are still flagged up and I cannot find any rule which resolve these indentations. So, how do I indent import/export statements?

There has been some work for this enhancement to indent rule. Please follow the conversation here: https://github.com/eslint/eslint/pull/8955

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM