angulartypescripteslintprettier

Why prettier asks to jump to a new line in constructor after updating to 3.1.0?


after updating prettier to version 3.1.0 it asks to Replace public·readonly·node:·Node,·public·readonly·position:·number,·private·readonly·schema:·Schema with ⏎········public·readonly·node:·Node,⏎········public·readonly·position:·number,⏎········private·readonly·schema:·Schema⏎···· prettier/prettier

error appears only in constructor if it has more than one property in them

my devDependencies

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

snippet where error appears

    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
}

which rule adjusts the length of a line in the constructor and how to fix it without line jumps?


Solution

  • Found explanation in documentation. Prettier has strict break on TypeScript parameter properties since version 3.0.