🐛 `quoteStyle` is ignored for `noUnusedTemplateLiteral` suggestion
Environment information
CLI:
Version: 12.0.0
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
ROME_LOG_DIR: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v19.8.1"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "yarn/1.22.19"
Rome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: true
Workspace:
Open Documents: 0
What happened?
- Specifying
singlequote style and performing a lint check which returns anoUnusedTemplateLiteralwarning suggests double-quotes due to: https://github.com/rome/tools/blob/main/crates/rome_js_factory/src/make.rs#L22 which is hard-coded to double quotes. It should really use the specified quote style.
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
✖ Do not use template literals if interpolation and special-character handling are not needed.
328 │ // Something bad happened, throw exception.
> 329 │ throw new ServerError(`Could not update module.`);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
330 │ }
331 │
ℹ Suggested fix: Replace with string literal
329 │ → → throw·new·ServerError("Could·not·update·module.");
Expected result
noUnusedTemplateLiteral suggestion should use the specified quoteStyle
Code of Conduct
- [X] I agree to follow Rome's Code of Conduct
This should be fixed; you could try one of the latest nightlies. We are going to make a release soon: #4344
@ematipico This doesn't seem to be fixed, I just tried the playground for the PR you linked and it still displays double quotes when single quotes is specified.
Have you tried one of the nightlies?
The playground doesn't show the final fixes.
The final fixes pass through the formatter when you apply the fixes, if the formatter is enabled.
@ematipico I just tried v12.0.0-nightly.ff02317 locally, the issue is still present in the suggestion output but works upon applying. Thanks!
I'm sorry to report that this issue still occurs for me in vscode, using v12.1.3-nightly.4c8cf32 with extension v0.25.20230719. I have this relevant section in .json:
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "double"
}
}
I'm not sure if it's because of the extension or not. However, the "jsxQuoteStyle" property is correctly applied, so I know it's using the right nightly build.
Can someone create a reproduction? I am going to leave it open for a bit, but without a reproduction it would be difficult to help
How would I do that?
By the way, how do I enable debug tracing? I can try to dig around after I do that to see what's going on between vscode and the language server.
On Sun, Jul 30, 2023, 02:01 Emanuele Stoppa @.***> wrote:
Can someone create a reproduction? I am going to leave it open for a bit, but without a reproduction it would be difficult to help
— Reply to this email directly, view it on GitHub https://github.com/rome/tools/issues/4448#issuecomment-1657053016, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWCYT3UND4RGBGQ2SBV4KTXSX2DZANCNFSM6AAAAAAX3ABWWQ . You are receiving this because you commented.Message ID: @.***>
@kamiyo you can use the playground: set the correct options, a code sample and share the URL here. Make sure to check that the formatted output is incorrect.
If the playground doesn't have the bug, then you'll have to create a small repository.
I'll try it. By the way, this happens when using vscode code actions to fix the error (context menu / Ctrl + .). If I then format the line, it then changes the " to '. So I'm not sure this problem is going to show up on the playground.
On Sun, Jul 30, 2023, 10:24 Emanuele Stoppa @.***> wrote:
@kamiyo https://github.com/kamiyo you can use the playground https://docs.rome.tools/playground/: set the correct options, a code sample and share the URL here.
— Reply to this email directly, view it on GitHub https://github.com/rome/tools/issues/4448#issuecomment-1657187146, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWCYT3KNM525KJTEG74QLTXSZVARANCNFSM6AAAAAAX3ABWWQ . You are receiving this because you were mentioned.Message ID: @.***>
Oh, now I see what you mean.
That's expected by design. The linter doesn't know anything about the formatter, so it applies code actions using the hardcoded values.
Probably we might be able to call the formatter when applying the code actions in the LSP, but I would consider this an enhancement and not a bug.
Ah ok, didn't realize that was the case. Would it be appropriate to add that to the vscode extension docs (or is it already there and I missed it?
On Sun, Jul 30, 2023, 12:18 Emanuele Stoppa @.***> wrote:
Oh, now I see what you mean.
That's expected by design. The linter doesn't know anything about the formatter, so it applies code actions using the hardcoded values.
Probably we might be able to call the formatter when applying the code actions in the LSP, but I would consider an enhancement and not a bug.
— Reply to this email directly, view it on GitHub https://github.com/rome/tools/issues/4448#issuecomment-1657212084, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWCYT42CWJPZ5GHQYW6VFDXS2CNZANCNFSM6AAAAAAX3ABWWQ . You are receiving this because you were mentioned.Message ID: @.***>