prettier-plugin-templ-script
Advanced tools
Comparing version
22
index.js
@@ -15,2 +15,4 @@ import prettier from 'prettier'; | ||
astFormat: 'templ', | ||
locStart: () => 0, | ||
locEnd: (node) => node.text.length, | ||
}, | ||
@@ -27,2 +29,6 @@ }; | ||
const singleIndent = options.useTabs | ||
? '\t' | ||
: ' '.repeat(options.tabWidth); | ||
try { | ||
@@ -48,3 +54,3 @@ for (const [ | ||
.split('\n') | ||
.map((line) => `${leadingWhitespace}\t${line}`) | ||
.map((line) => `${leadingWhitespace}${singleIndent}${line}`) | ||
.join('\n'); | ||
@@ -56,3 +62,11 @@ | ||
} catch (err) { | ||
console.error('Error formatting script:', err.message); | ||
console.error( | ||
`Error formatting script content within .templ file: ${err.message}`, | ||
); | ||
if (err.loc) { | ||
console.error( | ||
`Location: Line ${err.loc.start.line}, Column ${err.loc.start.column}`, | ||
); | ||
} | ||
throw err; | ||
@@ -65,1 +79,5 @@ } | ||
}; | ||
export const defaultOptions = { | ||
useTabs: true, | ||
}; |
{ | ||
"name": "prettier-plugin-templ-script", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Prettier plugin for `<script>` elements in templ.", | ||
@@ -5,0 +5,0 @@ "repository": { |
3734
13.15%67
28.85%