简体   繁体   English

标识符“aa_bb”不是驼峰式的

[英]identifier “aa_bb” is not in camel case

enter image description here在此处输入图片说明

I try to add the rule in the .eslintrc, But it does not work.我尝试在 .eslintrc 中添加规则,但它不起作用。

Please help.请帮忙。

I get 'aa_bb' from the api.我从 api 得到“aa_bb”。 I add the rule like the doc, and some ways.我像文档一样添加规则,以及一些方法。

It is still doesn't work.它仍然不起作用。 My classmate tell me to delete the eslint, he同学叫我删eslint,他

think that is superfluous.认为这是多余的。

oh, i can't add more detail......哦,我无法添加更多细节......

 { "parser": "babel-eslint", "extends": "airbnb", "plugins": ["compat"], "env": { "browser": true, "node": true, "es6": true, "mocha": true, "jest": true, "jasmine": true }, "rules": { "generator-star-spacing": [0], "consistent-return": [0], "react/forbid-prop-types": [0], "react/jsx-filename-extension": [1, { "extensions": [".js"] }], "global-require": [1], "import/prefer-default-export": [0], "react/jsx-no-bind": [0], "react/prop-types": [0], "react/prefer-stateless-function": [0], "react/jsx-wrap-multilines": ["error", { "declaration": "parens-new-line", "assignment": "parens-new-line", "return": "parens-new-line", "arrow": "parens-new-line", "condition": "parens-new-line", "logical": "parens-new-line", "prop": "ignore" }], "no-else-return": [0], "no-script-url": 0, "no-restricted-syntax": [0], "import/no-extraneous-dependencies": [0], "no-use-before-define": [0], "jsx-a11y/no-static-element-interactions": [0], "jsx-a11y/no-noninteractive-element-interactions": [0], "jsx-a11y/click-events-have-key-events": [0], "jsx-a11y/anchor-is-valid": [0], "no-nested-ternary": [0], "arrow-body-style": [0], "import/extensions": [0], "no-bitwise": [0], "no-cond-assign": [0], "import/no-unresolved": [0], "camelcase": [ "error", { "properties": "never" } ], "comma-dangle": ["error", { "arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "ignore" }], "object-curly-newline": [0], "function-paren-newline": [0], "no-restricted-globals": [0], "require-yield": [1], "compat/compat": "error", // "linebreak-style": ["error", "windows"] }, "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true } }, "settings": { "polyfills": ["fetch", "promises"] } }

Is that your entire .eslintrc file, or just a snippet?那是你的整个.eslintrc文件,还是只是一个片段? If the former, it looks like .eslintrc files need to start and end with curly braces.如果是前者,看起来.eslintrc文件需要以花括号开头和结尾。 So try:所以尝试:

{
    "rules": {
        "camelcase": ["error", {"properties": "never"}]
    }
}

If it's just a snippet, what version of ESLint are you using?如果它只是一个片段,那么您使用的是什么版本的 ESLint? I think in some of the earlier 1.x versions, instead of "error", you used a number representing the level:我认为在一些较早的 1.x 版本中,您使用了代表级别的数字而不是“错误”:

{
    "rules": {
        "camelcase": [2, {"properties": "never"}]
    }
}

camelCase is a naming convention in which each word within a compound word is capitalized except for the first word. camelCase 是一种命名约定,其中复合词中的每个单词都大写,但第一个单词除外。 Software developers often use camelCase when writing source code.软件开发人员在编写源代码时经常使用驼峰式命名法。

camelCase is useful in programming since element names cannot contain spaces. camelCase 在编程中很有用,因为元素名称不能包含空格。 The camelCase naming convention makes compound names more readable. camelCase 命名约定使复合名称更具可读性。 For example, myOneMethod is easier to read than myonemethod.例如,myOneMethod 比 myonemethod 更容易阅读。

add_bb for addFor

This moved forward, you can now flexibly allow certain identifiers (regexp also) to be non-camelcase:这向前推进,您现在可以灵活地allow某些标识符(也正则表达式)为非驼峰式:

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

See: https://eslint.org/docs/rules/camelcase#allow请参阅: https : //eslint.org/docs/rules/camelcase#allow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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