-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
no-unescaped-entities: Add exception for children content #1263
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
Comments
"This rule prevents characters that you may have meant as JSX escape characters from being accidentally injected as a text node in JSX statements." - it's not because those entities are invalid, it's because it's impossible to know from looking at it if you meant it, or made a mistake. In other words, they're not OK, because the programmer's intention is not clear. |
I see, more complicated than I thought. Can we add an This way I could for example ignore |
Why are you using straight quotes in your text? That's typographically invalid - you should only be using |
@ljharb 2 reasons:
|
If external resources provided you with text that had spelling and grammar errors, wouldn't you want to fix those? Using straight quotes in text is a typography error. Re point 2, you can trivially set up your computer to autocorrect straight quotes to curly quotes in non-code contexts. In general, I think that if you want exceptions to this rule, you'd be better off just disabling it. |
Just clicked the Terms link at the bottom of this page, are these I do agree with you, just trying to cope with reality. I would very much want to catch And thanks for the package in general, I really appreciate the work you guys are doing! |
Indeed, lots of sites use straight quotes when they shouldn't - linters are for those who want to do the right thing :-) I'd definitely not want an option that allowed for generic configurability, because many of the characters the rule blocks would be dangerous to allow - but I wouldn't block an option that specifically allowed straight quotes, if other collabs are inclined to add it. |
@ljharb Which direction are you claiming those |
@aij |
There is a "forbid" option, so we can easily configure the rule: |
@mkhazov That worked!
|
A PR to improve the docs is always appreciated :-) |
@ljharb PR'ed :-) |
The rule no-unescaped-entities warns on these characters inside JSX:
But it looks like Babel handles them pretty well when used as children content:
https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact&targets=&browsers=&builtIns=false&debug=false&code_lz=DwEwlgbgBAxgNgQwM5IHIILYFMC8AiACyzjgHs8A-AKCigEkAXAciSgHNSA7ThKAIyxReHUiCggEATygNRUgIQ0oFKACUwbAgwD8SgL5QkAVwBOgsKzwIA7llIYkWPFWAB6cBGpA&experimental=true&loose=false&spec=false
I've got a bunch of text I copy paste all the time (note I wrote
I've
, that's what ppl are used to).I would like to have warnings when I probably did an error, but in children content these characters are ok and refactoring them all the time is painful.
Right now the team just disabled this rule because of it.
Can we add an exception for children content (either an option or built in)?
Related #894
The text was updated successfully, but these errors were encountered: