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

Tagged Template literals #1244

Closed
laggingreflex opened this issue Sep 11, 2017 · 7 comments
Closed

Tagged Template literals #1244

laggingreflex opened this issue Sep 11, 2017 · 7 comments

Comments

@laggingreflex
Copy link

Description

Are there any rules that apply to Tagged Template literals?

Specifically:

  • Case 1:

    Input

    fn`tagged`
    

    Expected: no change

    fn`tagged`
    

    Actual: space inserted

    fn `tagged`
      ^ space inserted
    
  • Case 2:

    Input

    fn()`tagged`
    

    Expected: no change

    fn()`tagged`
    

    Actual: newline inserted

    fn()
    `tagged`
    ^ newline inserted
    
@bitwiseman
Copy link
Member

Not currently supported. Didn't even know this existed. Thanks!

@bitwiseman bitwiseman added this to the v1.9.x milestone Jan 24, 2019
@bitwiseman bitwiseman modified the milestones: v1.9.x, v1.10.x Apr 29, 2019
@bitwiseman bitwiseman modified the milestones: v1.10.x, v1.10.xx Jan 14, 2020
@bitwiseman bitwiseman modified the milestones: v1.10.x, v1.11.x Apr 5, 2020
@bitwiseman bitwiseman modified the milestones: v1.11.x, v1.12.x Aug 13, 2020
@bitwiseman bitwiseman modified the milestones: v1.12.x, 1.13.x Aug 20, 2020
@JuanFML
Copy link
Contributor

JuanFML commented Nov 30, 2020

Hello everyone, I am new here, is there a chance I can try this as my first issue?

@bitwiseman
Copy link
Member

bitwiseman commented Nov 30, 2020

@JuanFML
You are welcome to give it a try, but it may be a little tricky. You'll probably want to make the change in this method:

https://github.com/beautify-web/js-beautify/blob/97caa308491e1379b226c514f677fa4f278e15d4/js/src/javascript/beautifier.js#L1059-L1077

If the STRING token that is about to be processed is a backtick string and is preceded by a literal with no space in between, then do not add a space or newline.

@JuanFML
Copy link
Contributor

JuanFML commented Dec 1, 2020

Ok! I will be trying it out, thank you! If I get stuck I will let you know

@JuanFML
Copy link
Contributor

JuanFML commented Dec 2, 2020

Hi @bitwiseman, I've been working on this, but I would like to know if I am doing it right, so far I figure out a condition and added it in the method you mentioned, I opend a PR as the test passed with make jstest, but when I run make I am having troubles to solve the other implementations.

JuanFML added a commit to JuanFML/js-beautify that referenced this issue Dec 3, 2020
Added validations to prevent tagged literals from being modified
@JuanFML JuanFML mentioned this issue Dec 3, 2020
6 tasks
@JuanFML
Copy link
Contributor

JuanFML commented Dec 3, 2020

@JuanFML
Copy link
Contributor

JuanFML commented Dec 3, 2020

I have solved the remaining tests and fixed errors that appeared on my PR in Azure DevOps, please let me know if the changes are ok

JuanFML added a commit to JuanFML/js-beautify that referenced this issue Dec 21, 2020
bitwiseman added a commit that referenced this issue Jan 8, 2021
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

3 participants