1

我正在使用 Prettier 1.14.0 和 Prettier Formatter for Visual Studio Code。我遇到了函数参数格式不稳定的问题。例如要求我保持字符串compose(field('tags'), orEmpty, commaList, usertag())()(user),内联,而第二个强制它是这样的

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

我希望两者都像第二种情况。它看起来parser不适用于 package.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
        }
      ]
    }
  },

.eslintrc

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

.vscode/设置

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

我的插件

4

0 回答 0