-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Beautifier breaks ES6 nested template strings #797
Comments
+1 return `${err.name}${err.message?`: ${err.message}`:''}\n${stackLines}`; After: return `${err.name}${err.message?`: $ {
err.message
}
`:''}\n${stackLines}`; |
Please point to documentation of |
@GuilhermeReda // Note the "`" after the first "?"
`SELECT
nextval('${this.options.schema ? `${this.options.schema}.` : ''}"${this.tableName}_${this.autoIncrementField}_seq"'::regclass
) nextval;` I can't tell exactly what you want to do, but this is closer: `SELECT
nextval('${this.options.schema ? this.options.schema + '.' : ''} "${this.tableName}_${this.autoIncrementField}_seq"'::regclass
) nextval;` |
@INovozhilov return `${err.name}${err.message?`: ${err.message}`:''}\n${stackLines}`; What I think you meant: return `${err.name}${err.message ? err.message : ''}\n${stackLines}`; |
No, @bitwiseman, my code is correct. `: ${err.message}` in template: `${err.name}${err.message?...<mySubTemplate>...:''}\n${stackLines}` The ES6 specification is not prohibited to use nested templates describing them in a block of |
Here is a simple example of correct template: var a = '1';
var b = `a is ${ `${ a }` }`;
console.log(b); output:
|
Take a look at https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/ "The code in a template substitution can be any JavaScript expression, so function calls, arithmetic, and so on are allowed. (If you really want to, you can even nest a template string inside another template string, which I call template inception.)" |
Every time I think I've seen it all. Okay, I see what would be needed. Recursive Template string parsing. Considering this breaks the code in this case, I'll prioritize it. In the meanwhile, you'll need to use an annotation to disable beautification of that section. |
Can I ask how to "use an annotation to disable beautification of that section"? I can't find the answer from readme. |
Sorry, I meant "directives": |
I have another problem related to template string. let testTable = function() {
return `CREATE TABLE IF NOT EXISTS some_table (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
label VARCHAR(64) NOT NULL,
PRIMARY KEY (id)
) ENGINE=Aria DEFAULT CHARSET ascii;`;
}; It will add extra linebreak between return and the template which make the function return undefined. |
@MidnightWonderer - |
👍 good job |
Hi, I have a file with the following code.
When I format the file, that line becomes
it is putting a space between $ and {, and that breaks my code.
The text was updated successfully, but these errors were encountered: