Skip to content

Instantly share code, notes, and snippets.

@JulianCataldo
Last active June 8, 2022 20:22
Show Gist options
  • Save JulianCataldo/86b9000ea59755a39c723771a7e32337 to your computer and use it in GitHub Desktop.
Save JulianCataldo/86b9000ea59755a39c723771a7e32337 to your computer and use it in GitHub Desktop.
Astro tooling : Prettier
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = false
[**/Makefile]
indent_style = tab
indent_size = 4
[*.md]
trim_trailing_whitespace = false
[{.*,*.md,*.json,*.toml,*.yml,}]
indent_style = space
/** @type {import("@types/prettier").Options} */
module.exports = {
printWidth: 80,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
plugins: ['./node_modules/prettier-plugin-astro'],
overrides: [
{
files: '*.astro',
options: {
parser: 'astro',
printWidth: 80,
},
},
{
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
options: {
useTabs: false,
},
},
{
files: ['**/*.css', '**/*.scss'],
options: {
singleQuote: false,
},
},
],
};
{
"scripts": {
"format": "prettier -w ./src ./src/**/*.astro"
},
"devDependencies": {
"@types/prettier": "^2.6.3",
"prettier": "^2.6.2",
"prettier-plugin-astro": "^0.0.12"
}
}
// VSCode
// Extensions: "esbenp.prettier-vscode", "editorconfig.editorconfig"
{
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.documentSelectors": ["**/*.astro"],
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
// "editor.formatOnPaste": false,
// "editor.formatOnType": false,
// "editor.formatOnSave": true,
// "editor.codeActionsOnSave": {
// "source.fixAll": true
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment