代码之家  ›  专栏  ›  技术社区  ›  K.Rice

如何配置Prettier formatter-vscode插件与安装的npm模块不一致

  •  1
  • K.Rice  · 技术社区  · 7 年前

    例如,要求我保留字符串 compose(field('tags'), orEmpty, commaList, usertag())()(user),

    compose(
              field('tags'),
              orEmpty,
              commaList,
              usertag(),
            )()(user),
    

    我希望两者都像第二种情况。看起来像 parser 不适用于包.json... 以下是一些配置:

    包.json

      "prettier": {
        "parser": "flow",
        "printWidth": 80
      },
    "eslintConfig": {
        "parser": "babel-eslint",
        "extends": [
          "standard",
          "prettier",
          "plugin:import/recommended"
        ],
        "plugins": [
          "prettier",
          "simple-complexity",
          "import",
          "import-order-autofix",
          "filenames"
        ],
        "settings": {
          "import/resolver": "webpack",
          "import/ignore": [
            "node_modules"
          ]
        },
        "rules": {
          "filenames/match-exported": [
            "error"
          ],
          "import-order-autofix/order": [
            "error",
            {
              "newlines-between": "always"
            }
          ],
          "prettier/prettier": [
            "error",
            {
              "parser": "flow",
              "printWidth": 80,
              "singleQuote": true,
              "trailingComma": "all",
              "bracketSpacing": false,
              "semi": false,
              "requirePragma": true,
              "insertPragma": true
            }
          ],
          "comma-dangle": [
            "error",
            {
              "arrays": "always-multiline",
              "objects": "always-multiline",
              "imports": "always-multiline",
              "exports": "always-multiline",
              "functions": "always-multiline"
            }
          ],
          "complexity": [
            "error",
            {
              "max": 15
            }
          ],
          "max-nested-callbacks": [
            "error",
            {
              "max": 3
            }
          ],
          "max-statements": [
            "error",
            {
              "max": 10
            }
          ],
          "max-params": [
            "error",
            {
              "max": 4
            }
          ],
          "max-lines": [
            "error",
            {
              "max": 350,
              "skipBlankLines": true,
              "skipComments": true
            }
          ],
          "max-depth": [
            "error",
            {
              "max": 3
            }
          ],
          "simple-complexity/max-indent": [
            "error",
            {
              "max": 20
            }
          ]
        }
      },
    

    埃斯林特

    {
      "extends": "react-app",
      "plugins": [
        "prettier",
        "simple-complexity",
        "import",
        "import-order-autofix",
        "filenames"
      ],
      "rules": {
        "filenames/match-exported": ["error"],
        "import-order-autofix/order": [
          "error",
          {
            "newlines-between": "always"
          }
        ],
        "prettier/prettier": [
          "error",
          {
            "singleQuote": true,
            "trailingComma": "all",
            "bracketSpacing": false,
            "semi": false,
            "requirePragma": true,
            "insertPragma": true
          }
        ],
        "comma-dangle": [
          "error",
          {
            "arrays": "always-multiline",
            "objects": "always-multiline",
            "imports": "always-multiline",
            "exports": "always-multiline",
            "functions": "always-multiline"
          }
        ],
        "complexity": [
          "error",
          {
            "max": 15
          }
        ],
        "max-nested-callbacks": [
          "error",
          {
            "max": 3
          }
        ],
        "max-statements": [
          "error",
          {
            "max": 10
          }
        ],
        "max-params": [
          "error",
          {
            "max": 4
          }
        ],
        "max-lines": [
          "error",
          {
            "max": 350,
            "skipBlankLines": true,
            "skipComments": true
          }
        ],
        "max-depth": [
          "error",
          {
            "max": 3
          }
        ],
        "simple-complexity/max-indent": [
          "error",
          {
            "max": 20
          }
        ]
      }
    }
    

    {
        "[javascript]": {
            "editor.formatOnSave": true,
        },
        "prettier.eslintIntegration": true,
        "editor.tabSize": 2,
        "files.watcherExclude": {
            "**/.git/objects/**": true,
            "**/.git/subtree-cache/**": true,
            "**/node_modules/*/**": true
        },
    }
    

    My plugins

    0 回复  |  直到 7 年前