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

feat(typescript-estree): correct logic used to escape string literals #2995

Merged
merged 4 commits into from Feb 5, 2021

Conversation

armano2
Copy link
Member

@armano2 armano2 commented Feb 3, 2021

This PR add correct unescaping of xhml string literals and jsxText that is now applied only in jsx context.

logic for this PR has been crafted base on current implementaion of acorn-jsx and babel

https://github.com/acornjs/acorn-jsx/blob/master/index.js
https://github.com/babel/babel/blob/main/packages/babel-parser/src/plugins/jsx/index.js

notable changes:

  • instead of using lodash unescape funtion that offers limited number of escape characters &, <, >, ", ' we will now handle all valid values, additionally support for unescaping hex and decimal codepoints has been added.

see: https://github.com/lodash/lodash/blob/2f79053d7bc7c9c9561a30dda202b3dcd2b72b90/unescape.js#L2

#2279

@armano2 armano2 self-assigned this Feb 3, 2021
@typescript-eslint

This comment has been minimized.

@armano2 armano2 added dependencies Issue about dependencies of the package package: typescript-estree Issues related to @typescript-eslint/typescript-estree refactor PRs that refactor code only tests anything to do with testing and removed tests anything to do with testing labels Feb 3, 2021
@codecov
Copy link

codecov bot commented Feb 3, 2021

Codecov Report

Merging #2995 (9bd550f) into master (ee927ee) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2995   +/-   ##
=======================================
  Coverage   92.71%   92.72%           
=======================================
  Files         313      314    +1     
  Lines       10658    10663    +5     
  Branches     3019     3023    +4     
=======================================
+ Hits         9882     9887    +5     
  Misses        355      355           
  Partials      421      421           
Flag Coverage Δ
unittest 92.72% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/typescript-estree/src/convert.ts 98.37% <100.00%> (-0.01%) ⬇️
...ckages/typescript-estree/src/jsx/xhtml-entities.ts 100.00% <100.00%> (ø)
packages/typescript-estree/src/node-utils.ts 97.77% <100.00%> (+0.08%) ⬆️

@armano2 armano2 marked this pull request as ready for review February 3, 2021 02:26
@armano2 armano2 changed the title fix(typescript-estree): correct logic used to escape string literals feat(typescript-estree): correct logic used to escape string literals Feb 3, 2021
@bradzacher bradzacher added enhancement New feature or request and removed dependencies Issue about dependencies of the package refactor PRs that refactor code only labels Feb 5, 2021
@bradzacher bradzacher merged commit 3cb3aad into master Feb 5, 2021
@armano2 armano2 deleted the fix/unescape-literals branch February 5, 2021 17:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants