【问题标题】:Identifier is not a camel case标识符不是驼峰式的
【发布时间】:2018-09-10 09:00:25
【问题描述】:

我必须从模块导入,但出现错误标识符 'locale_en' is not in camel case。我该如何解决这个问题。

import locale_en from 'react-intl/locale-data/en'

我使用模块“react-intl”并尝试在我的规则中添加:camelcase: ["error", {properties: "never"}],但它仍然无法正常工作

编辑:我找到了解决方案:规则是:"camelcase": [1, {"properties": "never"}]

【问题讨论】:

  • camelcase 不是骆驼案,但camelCase 是。
  • 找不到规则“camelCase”的定义...
  • 讽刺的是 the camelcase rule's name 不是骆驼式的。
  • 你试过别名吗?
  • 你在说什么别名? @user10340130

标签: javascript reactjs import eslint react-intl


【解决方案1】:

您现在可以灵活地将allow 某些标识符(也包括正则表达式)设为非驼峰式:

{
    "rules": {
        "camelcase": ["error", {"allow": ["aa_bb"]}]
    }
}

见:https://eslint.org/docs/rules/camelcase#allow

【讨论】:

    猜你喜欢
    • 2012-05-14
    • 2015-05-11
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    • 2020-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多