I ran ddev prettier on a custom module, and it incorrectly flagged a .inc file.
In Drupal code, .inc files are PHP, but prettier parses them as HTML by default.
Drupal core has two ways to run prettier:
- npm/yarn script in package.json.
This command is exclusive to css/js.
It also has some custom exclusions in .prettierignore.
- Run on postcss compiled css by compile.js.
Change record
A lot of our code should actually be checked by eslint and phpcs/phpcbf, which raises the question - what do we actually want to check with a prettier ddev command?
A conversation with claude says that it should only be used for .md and .json. However, core doesn't do this.
Another consideration is that we'll want to have config we can use in our IDEs. So we probably want to make the change in .prettierignore, and not in the ddev command.
Therefore, I think the most straightforward fix is to add .inc to .prettierignore.
I ran
ddev prettieron a custom module, and it incorrectly flagged a .inc file.In Drupal code, .inc files are PHP, but prettier parses them as HTML by default.
Drupal core has two ways to run prettier:
This command is exclusive to css/js.
It also has some custom exclusions in .prettierignore.
Change record
A lot of our code should actually be checked by eslint and phpcs/phpcbf, which raises the question - what do we actually want to check with a prettier ddev command?
A conversation with claude says that it should only be used for .md and .json. However, core doesn't do this.
Another consideration is that we'll want to have config we can use in our IDEs. So we probably want to make the change in .prettierignore, and not in the ddev command.
Therefore, I think the most straightforward fix is to add .inc to .prettierignore.