为什么 Prettier 更新到 3.1.0 后要求在构造函数中跳转到新行?

问题描述 投票:0回答:1

将 prettier 更新到版本 3.1.0 后,它要求将

public·readonly·node:·Node,·public·readonly·position:·number,·private·readonly·schema:·Schema
替换为
⏎········public·readonly·node:·Node,⏎········public·readonly·position:·number,⏎········private·readonly·schema:·Schema⏎····
prettier/prettier

仅当构造函数中包含多个属性时,错误才会出现

我的开发依赖项

"devDependencies": {
    "@angular-devkit/build-angular": "^17.0.5",
    "@angular-eslint/builder": "17.1.1",
    "@angular-eslint/eslint-plugin": "17.1.1",
    "@angular-eslint/eslint-plugin-template": "17.1.1",
    "@angular-eslint/schematics": "17.1.1",
    "@angular-eslint/template-parser": "17.1.1",
    "@angular/cli": "~17.0.5",
    "@angular/compiler-cli": "^17.0.5",
    "@types/jasmine": "~5.1.4",
    "@typescript-eslint/eslint-plugin": "^6.10.0",
    "@typescript-eslint/parser": "^6.10.0",
    "eslint": "^8.53.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-import-resolver-typescript": "^3.5.5",
    "eslint-plugin-angular": "^4.1.0",
    "eslint-plugin-html": "^7.1.0",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jsdoc": "^46.9.0",
    "eslint-plugin-ordered-imports": "^0.6.0",
    "eslint-plugin-prefer-arrow": "^1.2.3",
    "eslint-plugin-prettier": "^5.0.1",
    "eslint-plugin-rxjs": "^5.0.3",
    "eslint-plugin-rxjs-angular": "^2.0.1",
    "eslint-plugin-unused-imports": "^3.0.0",
    "jasmine-core": "~5.1.1",
    "karma": "~6.4.1",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "^2.0.1",
    "karma-junit-reporter": "^2.0.1",
    "ng-packagr": "^17.0.2",
    "prettier": "^3.1.0",
    "sonar-scanner": "^3.1.0",
    "stylelint": "^15.4.0",
    "stylelint-config-standard-scss": "^11.1.0",
    "stylelint-scss": "^5.3.1",
    "typescript": "~5.2.2"
  }

出现错误的片段

    constructor(public readonly node: Node, public readonly position: number, private readonly schema: Schema) {
        const children: NodeWrapper[] = [];
        node.descendants((childNode, pos, parent) => {
            if (parent === node) {
                children.push(new NodeWrapper(childNode, position + pos + 1, schema));
            }
        });

        this.children = children;
    }

.prettierrc.json

{
    "tabWidth": 4,
    "useTabs": false,
    "semi": true,
    "quoteProps": "as-needed",
    "trailingComma": "none",
    "bracketSpacing": true,
    "arrowParens": "avoid",
    "printWidth": 140,
    "proseWrap": "preserve",
    "htmlWhitespaceSensitivity": "strict",
    "singleQuote": true,
    "bracketSameLine": true
}

哪个规则调整了构造函数中行的长度以及如何修复它而不发生行跳转?

angular typescript eslint prettier
1个回答
0
投票

文档中找到解释。

© www.soinside.com 2019 - 2024. All rights reserved.