Eslint-如何缩进导入导出语句 [英] Eslint - How to Indent Import Export Statements

查看:101
本文介绍了Eslint-如何缩进导入导出语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间后,我刚刚升级了Eslint,突然之间,我有很多错误.值得注意的下面提出的问题是 indentation .也许值得一提的是,我使用 tabs 而不是 spaces 进行缩进

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

问题:我的导入值按照eslint缩进术语"first"缩进.第一个"基本上意味着,所有其他声明都缩进以与第一个属性对齐.看到这个:

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:

我尝试过的解决方案:这是我的缩进规则在".eslintrc"文件中的样子:

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"
}],

即使我使用 tab ,而不是 space 进行说明,我仍然必须使用上面的 VariableDeclarator 规则来对齐所有变量/lets/constants等.但是, import & export 仍被标记,我找不到任何解决这些缩进的规则.那么,如何缩进导入/导出语句?

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?

推荐答案

indent 规则的这种增强已经做了一些工作.请在此处进行对话: https://github.com/eslint/eslint/pull/8955

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

这篇关于Eslint-如何缩进导入导出语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆