简体   繁体   English

如何解决无法加载配置“更漂亮”以进行扩展。 在反应 Js

[英]How to Resolve Failed to load config “prettier” to extend from. in react Js

I am very new to React JS, and now i am using Core-ui template for study purpose.我对 React JS 很陌生,现在我正在使用 Core-ui 模板进行学习。

here im facing the issue like我在这里面临这样的问题

Failed to load config "prettier" to extend from.无法加载要扩展的配置“更漂亮”。

在此处输入图片说明

在此处输入图片说明

Package.json包.json

 }, "devDependencies": { "eslint": "^5.8.0", "eslint-plugin-prettier": "^3.4.0", "prettier": "2.3.2" }

.eslintrc.js .eslintrc.js

 plugins: ['prettier'], rules: { 'prettier/prettier': ['error', { endOfLine: 'auto' }], // Use our .prettierrc file as source 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'off', // 'simple-import-sort/imports': 'error', // 'simple-import-sort/exports': 'error', }, }

Try adding eslint-config-prettier .尝试添加eslint-config-prettier

npm install --save-dev eslint-config-prettier

In your .eslintrc you'll need to add "prettier" to the extends array as the last item.在您的.eslintrc您需要将“ .eslintrc ”作为最后一项添加到 extends 数组中。

there are two type of packages per say plugins and configs them plugins go into the plugins section they have all the rules and stuff and the configs they go into the extends section有两种类型的packages每说pluginsconfigs他们插件进入他们有各种各样的规则和东西和插件部分configs他们进入extends部分

module.exports = {
    extends: ["eslint:recommended","eslint-config-prettier"],
    env: {
        node: true,
        commonjs: true,
        es6: true,
    },
    parser: "babel-eslint",
    parserOptions: {
        ecmaVersion: 2018,
        sourceType: "module",
        ecmaFeatures: {
            impliedStrict: true,
            jsx: true,
        },
    },
    settings: {
        polyfills: ["promises"],
        "import/resolver": {
            node: {
                moduleDirectory: "node_modules",
            },
        },
    },
    plugins: ["import", "babel","eslint-plugins-prettier"],
    rules: {
        indent: ["error", "tab"],
        quotes: ["error", "double"],
        semi: ["error", "always"],
        "space-before-function-paren": ["error", "always"],
        "keyword-spacing": [
            "error",
            {
                before: true,
                after: true,
            },
        ],
        "arrow-body-style": ["error", "as-needed"],
        "arrow-parens": ["error", "always"],
        "comma-spacing": [
            "error",
            {
                before: false,
                after: true,
            },
        ],
        "object-curly-spacing": [
            "error",
            "always",
            {
                arraysInObjects: false,
            },
        ],
        "template-curly-spacing": ["error", "always"],
        "comma-dangle": [
            "error",
            {
                arrays: "never",
                objects: "always",
                imports: "never",
                exports: "never",
                functions: "ignore",
            },
        ],
        "block-spacing": ["error", "always"],
        "no-else-return": "error",
        "no-nested-ternary": "error",
        "require-await": "error",
        "arrow-spacing": [
            "error",
            {
                before: true,
                after: true,
            },
        ],
        "prefer-const": "error",
        "no-var": "error",
        "no-use-before-define": "error",
        "linebreak-style": ["error", "unix"],
    },
};

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

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