Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 quoteStyle is ignored for noUnusedTemplateLiteral suggestion #4448

Open
1 task done
garymathews opened this issue May 9, 2023 · 11 comments
Open
1 task done

🐛 quoteStyle is ignored for noUnusedTemplateLiteral suggestion #4448

garymathews opened this issue May 9, 2023 · 11 comments
Labels
A-LSP Area: language server protocol enhancement New feature request or improvement to existing functionality

Comments

@garymathews
Copy link

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?

"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

  • I agree to follow Rome's Code of Conduct
@garymathews garymathews added the S-To triage Status: user report of a possible bug that needs to be triaged label May 9, 2023
@garymathews garymathews changed the title 🐛 quoteStyle is ignored for noUnusedTemplateLiteral suggestion 🐛 quoteStyle is ignored for noUnusedTemplateLiteral suggestion May 9, 2023
@ematipico
Copy link
Contributor

ematipico commented May 9, 2023

This should be fixed; you could try one of the latest nightlies. We are going to make a release soon: #4344

@garymathews
Copy link
Author

@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.

@ematipico
Copy link
Contributor

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.

@garymathews
Copy link
Author

garymathews commented May 9, 2023

@ematipico I just tried v12.0.0-nightly.ff02317 locally, the issue is still present in the suggestion output but works upon applying. Thanks!

@kamiyo
Copy link

kamiyo commented Jul 29, 2023

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.

@ematipico ematipico reopened this Jul 30, 2023
@ematipico
Copy link
Contributor

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

@ematipico ematipico added S-Needs info Status: the issue needs more info in order to be triaged and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Jul 30, 2023
@kamiyo
Copy link

kamiyo commented Jul 30, 2023 via email

@ematipico
Copy link
Contributor

ematipico commented Jul 30, 2023

@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.

@kamiyo
Copy link

kamiyo commented Jul 30, 2023 via email

@ematipico
Copy link
Contributor

ematipico commented Jul 30, 2023

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.

@kamiyo
Copy link

kamiyo commented Jul 30, 2023 via email

@ematipico ematipico added enhancement New feature request or improvement to existing functionality A-LSP Area: language server protocol and removed S-Needs info Status: the issue needs more info in order to be triaged labels Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-LSP Area: language server protocol enhancement New feature request or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants