There are 2 optional ways.
1)
Change the global delimiters of EJS.
const ejs = require("ejs");
ejs.delimiter = '/';
ejs.openDelimiter = '[';
ejs.closeDelimiter = ']';
Update your script.
<script>
const post= [/- JSON.stringify(post) /];
</script>
2)
Add this property to settings.json in VSCode.
"html.validate.scripts": false
Change the global delimiters of EJS.
const ejs = require("ejs");
ejs.delimiter = '?';
ejs.openDelimiter = '[';
ejs.closeDelimiter = ']';
Update your script.
<script>
const post= [?- JSON.stringify(post) ?];
</script>
Note: Auto format will work correctly in 2 ways.
Note: I prefer the first one because I can use both auto format and scripts validation and I don't need any EJS extension.