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

Replace strings with correct concatenation #6736

Closed
aljesusg opened this issue Oct 18, 2023 · 5 comments
Closed

Replace strings with correct concatenation #6736

aljesusg opened this issue Oct 18, 2023 · 5 comments
Labels
good first issue Needs a contributor. Good starter issue help wanted Needs a contributor. Useful but outside maintainer backlog maintenance Development tasks, like refactoring, performance improvement, any non-user facing changes.

Comments

@aljesusg
Copy link
Collaborator

aljesusg commented Oct 18, 2023

There are multiple sentences in code with old concatenation, replace them with the new one `<string>` (Require template literals instead of string concatenation):

Rule:

In ES2015 (ES6), we can use template literals instead of string concatenation.

var str = "Hello, " + name + "!";
var str = `Hello, ${name}!`;

Example in kiali code:

text: prefix + ': ' + (thresholdStatus.status === NA ? 'No requests' : thresholdStatus.value.toFixed(2) + '%'),

that would be great to replace with

text: `${prefix}:${thresholdStatus.status === NA ? 'No requests' : `${thresholdStatus.value.toFixed(2)}%`}`

More information: http://eslint.org/docs/rules/prefer-template

@aljesusg aljesusg added good first issue Needs a contributor. Good starter issue maintenance Development tasks, like refactoring, performance improvement, any non-user facing changes. help wanted Needs a contributor. Useful but outside maintainer backlog labels Oct 18, 2023
@jshaughn
Copy link
Collaborator

I agree that the new way is better, and I would encourage the change as we work on the code, but I'm -1 for a straight refactor unless there is some benefit other than just nicer looking code. I do already change this when I see it, but you have to be careful not to make a mistake.

@jmazzitelli
Copy link
Collaborator

I agree with jay - we don't want a bunch of one-line PRs from random people that is just refactor string concat code.

@aljesusg
Copy link
Collaborator Author

Well...the point is that I am doing these changes for backstage effort, I must do it by repo rules (logically methods and some components with material-ui instead pf are identical - copy/paste).

I agree that it makes no sense make all the changes and I opened the issue looking for a contributor. If you want we can close it.

@jmazzitelli
Copy link
Collaborator

I believe this is getting taken care of with the linter stuff we now have in place. I'm seeing PRs that are getting created with these changes. So this issue may be getting implemented as time marches forward and the linter forces devs to make these changes.

@jshaughn
Copy link
Collaborator

+1, I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Needs a contributor. Good starter issue help wanted Needs a contributor. Useful but outside maintainer backlog maintenance Development tasks, like refactoring, performance improvement, any non-user facing changes.
Projects
None yet
Development

No branches or pull requests

3 participants