Ensure code examples in documentation and comments are syntactically correct and properly marked with the appropriate language identifier. This maintains a professional appearance and prevents readers from copying incorrect code.
Ensure code examples in documentation and comments are syntactically correct and properly marked with the appropriate language identifier. This maintains a professional appearance and prevents readers from copying incorrect code.
Key guidelines:
Example - INCORRECT:
function myPlugin() {
const state = new Map<Environment, { count: number }>()
return {
name: 'my-plugin',
buildStart() {
state.set(this.environment, { count: 0 })
// Missing comma here!
transform(code) {
// ...
}
}
}
Example - CORRECT:
function myPlugin() {
const state = new Map<Environment, { count: number }>()
return {
name: 'my-plugin',
buildStart() {
state.set(this.environment, { count: 0 })
}, // Proper comma after function
transform(code) {
// ...
}
}
}
Or alternatively with plain JS:
function myPlugin() {
const state = new Map()
return {
name: 'my-plugin',
buildStart() {
state.set(this.environment, { count: 0 })
},
transform(code) {
// ...
}
}
}
Enter the URL of a public GitHub repository