Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document usage of custom escape methods #134

Open
LukeWood opened this issue Jun 22, 2020 · 2 comments
Open

Document usage of custom escape methods #134

LukeWood opened this issue Jun 22, 2020 · 2 comments

Comments

@LukeWood
Copy link
Contributor

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
Copy link
Collaborator

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

  • the property methods specifies a list of functions that accept a string a return a sanitized string.
  • the property taggedTemplates specifices a list of functions that are used with tagged template strings (e.g., myHTMLTemplate`<p>${hello}</p>`;). Those should also return a sanitized string

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
Copy link
Contributor Author

Thanks for your quick response Frederik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants