mozilla / eslint-plugin-no-unsanitized

Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike
Mozilla Public License 2.0
228 stars 37 forks source link

Document usage of custom escape methods #134

Open LukeWood opened 4 years ago

LukeWood commented 4 years ago

Any example of this can be found here: https://github.com/mozilla/eslint-plugin-no-unsanitized/blob/master/tests/rules/property.js#L142

Is it possible to get documentation showing an example of this in an eslint rc?

mozfreddyb commented 4 years ago

Yeah, that's a variation of docs/rules/customization.md, which is admittedly full of TODOs.

I hope this will do:

{
    "plugins": ["no-unsanitized"],
    "rules": {
        "no-unsanitized/method": [
            "error",
            {
                escape: {
                    methods: ["myHTMLEscape"]
                    taggedTemplates: ["myHTMLTemplate"]
                }
            },
        ],
        "no-unsanitized/property": [
            "error",
            {
                escape: {
                    methods: ["myHTMLEscape"]
                    taggedTemplates: ["myHTMLTemplate"]
                }
            },
        ]
    }
}
LukeWood commented 4 years ago

Thanks for your quick response Frederik!