English 中文(简体)
Prettier编成的代码被记为不符合规定。
原标题:The code formatted by Prettier is being flagged as non-compliant

我使用ESLint和Prettier自动编印成字典,但格式化编码仍然被贴上旗号,因为不符合《规则》。

我的es:

module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  settings: {
     import/resolver : {
       typescript : {}
    }
  },
  extends: [
     prettier ,
  ],
  parser:  @typescript-eslint/parser ,
  parserOptions: {
    ecmaVersion:  latest ,
    sourceType:  module ,
    project: true,
    tsconfigRootDir: __dirname,
  },
  plugins: [ react-refresh ,  prettier ],
  rules: {
     max-len : [ error , { code: 120 }],
     prettier/prettier : [
       error ,
      {
        printWidth: 120,
        tabWidth: 2,
        useTabs: false,
        semi: false,
        singleQuote: true,
        quoteProps:  as-needed ,
        jsxSingleQuote: false,
        trailingComma:  all ,
        bracketSpacing: true,
        bracketSameLine: false,
        jsxBracketSameLine: false,
        arrowParens:  avoid ,
        requirePragma: false,
        insertPragma: false,
        proseWrap:  preserve ,
        htmlWhitespaceSensitivity:  ignore ,
        endOfLine:  lf ,
        singleAttributePerLine: true,
      }
    ],
     no-confusing-arrow :  off ,
     arrow-body-style :  off ,
     prefer-arrow-callback :  off ,
  },
}

我的守则之一是:

type BasicDataStructureType =  Integer  |  Float  |  Double  |  Enumeration  |  Boolean  |  Array  |  Struct 

序号:

type BasicDataStructureType =
  |  Integer 
  |  Float 
  |  Double 
  |  Enumeration 
  |  Boolean 
  |  Array 
  |  Struct 

格式编码为:替换<条码>。 采购处 Double ⏎ : . . . .·. Boolean ⏎ ·. Array ⏎ with Integer • 法学士 • 双重 • 计算 • Boo http://www.ohchr.org。

另一种形式的不遵守守则是:

const Api = {
  getDataStructureVersions: (param: { name: string; namespaceId: number }) =>
    request({ url: `/struct/version/list?${queryString.stringify(param)}`, method:  GET  }),
}

缩略语为: 删除< 代码> ·->-

我的lin子或 pre子是否没有适当配置? 谁能帮助我解决这一问题? 否则,我不得不去除Prettier。

问题回答

OK,I solved myself. I use Prettier vscode plugin instead of eslint-plugin-prettier. But I still don t know why eslint-plugin-prettier doesn t work around with my prettier config. As long as I set printWidth to 105 or set singleAttributePerLine to true, my code was flagged as not compliant.





相关问题
vsCode issue with husky

我的项目配置了胡斯基。 它将使用“倾斜器”在每项承诺之前对守则进行格式。

找不到更漂亮模块

我更新了所有软件包, 但在运行 npm 运行服务后仍然会收到错误 : 模块构建失败 (来自./ node_ modules/ eslint-loader/ index. js): 错误 : 找不到更漂亮的模块...

热门标签