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

[no-unescaped-entities] single quote #894

Closed
tleunen opened this issue Oct 8, 2016 · 19 comments
Closed

[no-unescaped-entities] single quote #894

tleunen opened this issue Oct 8, 2016 · 19 comments
Labels

Comments

@tleunen
Copy link

tleunen commented Oct 8, 2016

I'm having the no-unescaped-entities thrown when a single quote is used.

Example

<div>I'm not ok</div>
@ljharb
Copy link
Member

ljharb commented Oct 8, 2016

That's correct. You should either:
a) use {"I'm not ok"} to make it explicit, or
b) use (a curly quote) because straight quotes are typographically incorrect.

@ljharb ljharb added the question label Oct 8, 2016
@tleunen
Copy link
Author

tleunen commented Oct 8, 2016

hmm I see. But writing with curly quotes is quite painful :)
Thanks for the quick answer!

@tleunen tleunen closed this as completed Oct 8, 2016
@ljharb
Copy link
Member

ljharb commented Oct 8, 2016

@tleunen on a mac, ⌥-] or ⌥-}, on windows, alt 0145 or alt 0146 :-p

@julienw
Copy link
Contributor

julienw commented Jul 5, 2017

b) use (a curly quote) because straight quotes are typographically incorrect.

I think you wanted to mention instead of :)

@duane
Copy link

duane commented Sep 21, 2017

Naturally, there are other uses for ' than contractions and right single quotes. It's disappointing to see a typographic defense of all things for restricting valid input.

@duane
Copy link

duane commented Sep 21, 2017

Notably, ASCII 39 (') is primarily apostrophe, aka &apos;. This is how most fonts render the glyph; the only subculture that uses this as a right quote are japanese fonts that render it as a right single quotation mark. Furthermore, using single quotation marks in prose is vanishingly rare these days, whereas english contractions and possessives are as common as ever. You're hamstringing prose to support the typographer for no demonstrative benefit in the general case.

@julienw
Copy link
Contributor

julienw commented Sep 21, 2017

You can disable the rule if you don't like it.

I'm finding it useful, especially because github highlighting engine goes crazy with an alone apostrophe.

@ljharb
Copy link
Member

ljharb commented Sep 21, 2017

@duane english contractions and possessives should only be curly quotes too. The benefit is that curly quotes can't enclose HTML attribute values, which means the presence of a curly quote is never a bug, but the presence of a straight quote might be one.

@duane
Copy link

duane commented Sep 21, 2017

@ljharb

@duane english contractions and possessives should only be curly quotes too.

This is incorrect; it's an apostrophe, and it is wildly different than a quotation mark.

@julienw
Copy link
Contributor

julienw commented Sep 21, 2017

There are a lot of symbols that look alike. The Wikipedia page is very clear.
You can use as an apostrophe. You're right, a quotation mark is not correct. Even if that looks alike in most fonts.

@ljharb
Copy link
Member

ljharb commented Sep 21, 2017

@duane technically ' is not an apostrophe; is. ' is only used for notating "minutes" in degree-minute-second notation.

@duane
Copy link

duane commented Sep 22, 2017

@ljharb, @julienw, check the ascii spec. ' is an apostrophe.

@ljharb, that is a right single quotation mark, not an apostrophe; you only use it for closing quotations that were started with a left single quotation mark.

@ljharb
Copy link
Member

ljharb commented Sep 22, 2017

I understand that's how computers describe it; however, typography, not the ASCII spec, determines what a character is, and what should be used.

@taion
Copy link
Contributor

taion commented Nov 7, 2017

See http://www.unicode.org/Public/10.0.0/ucd/NamesList.txt. The Unicode spec explicitly glosses U+2019 as the "preferred character to use for apostrophe":

2019	RIGHT SINGLE QUOTATION MARK
	= single comma quotation mark
	* this is the preferred character to use for apostrophe
	x (apostrophe - 0027)
	x (modifier letter apostrophe - 02BC)
	x (heavy single comma quotation mark ornament - 275C)

@taion
Copy link
Contributor

taion commented Nov 7, 2017

' (U+0027), the apostrophe, is also not the right character to use for minute notation, if we want to be specific. That's actually (U+2032), the prime character.

I`m not sure there are any cases where ' (U+0027) is the preferred character, though obviously it⁗s convenient and easy to use in many cases.

I think it's quite fair to discourage the use of that character via lint rules, though.

@jimrandomh
Copy link

For the benefit of other people who come across this: Put "react/no-unescaped-entities": 0 in the rules section of .eslintrc. This warning is enforcing a typography geek's pet peeve, and the problem is with the warning, not with your code.

jimrandomh added a commit to jimrandomh/Lesswrong2 that referenced this issue Sep 6, 2018
By default, eslint warns if you use an apostrophe in JSX text (without
wrapping it in a string literal). The `eslint-plugin-react` thread about
it is some typography geeks arguing about the unicode standard, and
reaching the conclusion that apostrophes are actually U+2019. This is
clearly insane, so disable that warning.

jsx-eslint/eslint-plugin-react#894
@ljharb

This comment has been minimized.

@macouella
Copy link

macouella commented Apr 15, 2020

You could also just disable quotes...

"react/no-unescaped-entities": [
    "error",
    {
      forbid: [">", "}"],
    },
  ],

Had to do it that way, because I still care about <div>>></div> :)

@gio-built
Copy link

I did forbid: [">", """, "}"]

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

No branches or pull requests

8 participants