Prettier – Config for HTML and JS

Solution for Prettier – Config for HTML and JS
is Given Below:

I want to specify string lengths for HTML and JS in one config file .prettierrc.

 module.exports = {
  singleQuote: true,
  printWidth: 80,
  [HTML]: {
    printWidth: 150,

But in log i got:

ReferenceError: HTML is not defined

You should be using the .prettierrc format instead, visual studio code will also provide intellisense when you use this format.

You are getting the error because:

  • The file needs to be in the JSON format,
  • Any overrides need to be specified under the overrides JSON key

In your case the file should look like this:


  "singleQuote": true,
  "printWidth": 80,
  "overrides": [
      "files": ["**/*.html"],
      "options": {
        "printWidth": 150