The plugin allows a limit back-tracing of variables. This will be used to check code like here:
const greeting_template = `<p>Hello World!</p>`;
// ... lots of other code in between ...
someElemenet.innerHTML = greeting_template;
Currently, backtracing will only allow const and let variables that contain string literals only. Further assignments to these variables will also be checked for validation.
Backtracing can be disabled by setting the boolean
option variableTracing
to false
.
Both values are supported and tested in CI.
You can customize the way this rule works in various ways.
html
function by specifically checking input for the first function parameter{
"rules": {
"no-unsanitized/method": [
"error",
{
},
{
"html": {
"properties": [0]
}
}
]
}
}
{
"plugins": ["no-unsanitized"],
"rules": {
"no-unsanitized/method": [
"error",
{
disableDefault: true,
escape: {
taggedTemplates: ["safeHTML"]
}
},
{
html: {
properties: [0]
}
}
],
"no-unsanitized/method": [
"error",
{
escape: {
taggedTemplates: ["safeHTML"]
}
},
{
innerHTML: {
objectMatches: ["document.*"]
}
}
]
}
}
TBD