Skip to content

Move Prettier config to it's on file according to best practicesΒ #32222

@L-X-T

Description

@L-X-T

Command

new

Description

The included Angular Prettier config should go into it's own file, instead of being added to the package.json.

package.json

{
  "prettier": {
    "printWidth": 100,
    "singleQuote": true,
    "overrides": [
      {
        "files": "*.html",
        "options": {
          "parser": "angular"
        }
      }
    ]
  }
}

Describe the solution you'd like

While ".prettierrc" is the most common variant, I recommend using the modern approach "prettier.config.js" - this aligns with other tools like ESLint, Cypress or Playwright and allows comments:

prettier.config.js

module.exports = {
  bracketSameLine: true, // default: false; true for fewer lines in .html
  printWidth: 120, // default: 80; adjust to your team's preference
  singleQuote: true, // default: false; true for JS community style
  overrides: [
    {
      files: '*.html',
      options: {
        parser: 'angular',
      },
    },
  ],
};

Additionally, ".prettierignore" should be added with the minimal content like this:

.prettierignore

/.angular
/coverage
/dist
/node_modules

Describe alternatives you've considered

If you don't like "bracketSameLine: true" and insist on "printWidth: 100" that's okay, then we would have:

prettier.config.js

module.exports = {
  printWidth: 100, // default: 80; adjust to your team's preference
  singleQuote: true, // default: false; true for JS community style
  overrides: [
    {
      files: '*.html',
      options: {
        parser: 'angular',
      },
    },
  ],
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions