Skip to content

Issue #17487: Add ECMAScript6BestPractices#18158

Closed
Pankraz76 wants to merge 1 commit into
checkstyle:masterfrom
Pankraz76:pr-ECMAScript6BestPractices
Closed

Issue #17487: Add ECMAScript6BestPractices#18158
Pankraz76 wants to merge 1 commit into
checkstyle:masterfrom
Pankraz76:pr-ECMAScript6BestPractices

Conversation

@Pankraz76

@Pankraz76 Pankraz76 commented Nov 24, 2025

Copy link
Copy Markdown

Issue #17487: apply ECMAScript6BestPractices

Comment thread src/site/resources/js/checkstyle.js Outdated
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from ed6643c to 0615198 Compare November 24, 2025 11:40
@Pankraz76 Pankraz76 changed the title [rewrite] apply ECMAScript6BestPractices Issue #17487: [rewrite] apply ECMAScript6BestPractices Nov 24, 2025
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from 0615198 to d71b00a Compare November 24, 2025 11:44
@Pankraz76

Copy link
Copy Markdown
Author

nice to see rewrite also fixing .js stuff as well.

[INFO] Printing available datatables to: target/rewrite/datatables/2025-11-24_11-00-28-110 [WARNING] The recipe produced 20 warning(s). Please report this to the recipe author. [WARNING] Changes have been made to src/site/resources/js/anchors.js by:
[WARNING]     org.openrewrite.codemods.ecmascript.5to6.ECMAScript6BestPractices
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.varToLet
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/let.js}
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.noStrict
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/no-strict.js}
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.amdToEsm
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/amd.js}
[WARNING] Changes have been made to src/site/resources/js/checkstyle.js by:
[WARNING]     org.openrewrite.codemods.ecmascript.5to6.ECMAScript6BestPractices
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.noStrict
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/no-strict.js}
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.amdToEsm
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/amd.js}
[WARNING] Changes have been made to src/site/resources/styleguides/google-java-style-20180523/include/styleguide.js by:
[WARNING]     org.openrewrite.codemods.ecmascript.5to6.ECMAScript6BestPractices
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.varToLet
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/let.js}
[WARNING] Changes have been made to src/site/resources/styleguides/google-java-style-20220203/include/styleguide.js by:
[WARNING]     org.openrewrite.codemods.ecmascript.5to6.ECMAScript6BestPractices
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.varToLet
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/let.js}
[WARNING] Changes have been made to src/site/resources/styleguides/google-java-style-20250426/include/styleguide.js by:
[WARNING]     org.openrewrite.codemods.ecmascript.5to6.ECMAScript6BestPractices
[WARNING]         org.openrewrite.codemods.ecmascript.5to6.varToLet
[WARNING]             org.openrewrite.codemods.ApplyCodemod: {transform=5to6-codemod/transforms/let.js}
[WARNING] Please review and commit the results.
[WARNING] Estimate time saved: 25m
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:29 min
[INFO] Finished at: 2025-11-24T11:00:28+01:00
[INFO] ------------------------

@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from a6cec70 to 8899e60 Compare November 24, 2025 11:47
@Pankraz76

Copy link
Copy Markdown
Author

item

Finished at: 2025-11-24T11:58:12Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.1:site (default-site) on project sample: failed to get report for org.apache.maven.plugins:maven-checkstyle-plugin: Plugin org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1 or one of its dependencies could not be resolved:
[ERROR]         Could not find artifact com.puppycrawl.tools:checkstyle:jar:1.0.0-SNAPSHOT in apache.snapshots (https://repository.apache.org/snapshots)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.1:site (default-site) on project sample: failed to get report for org.apache.maven.plugins:maven-checkstyle-plugin
    at org.apache.

@Pankraz76 Pankraz76 changed the title Issue #17487: [rewrite] apply ECMAScript6BestPractices Issue #17487: apply ECMAScript6BestPractices Nov 24, 2025
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch 2 times, most recently from 27b8bfd to ed9d2fb Compare November 24, 2025 13:50
@Pankraz76

Copy link
Copy Markdown
Author

wait for enabler, thx.

@Pankraz76 Pankraz76 closed this Dec 5, 2025
@Pankraz76

Copy link
Copy Markdown
Author

@Pankraz76 Pankraz76 reopened this Dec 27, 2025
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch 3 times, most recently from be16a73 to 0fa1c73 Compare December 28, 2025 10:38
@Pankraz76

Copy link
Copy Markdown
Author

IO: [ERROR] exceptionMessage: "Connection refused"

@Pankraz76 Pankraz76 marked this pull request as ready for review December 28, 2025 10:47
@Pankraz76 Pankraz76 changed the title Issue #17487: apply ECMAScript6BestPractices Issue #17487: Add ECMAScript6BestPractices Dec 28, 2025
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from 0fa1c73 to 876727a Compare December 29, 2025 09:31

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items

Comment thread config/rewrite.yml Outdated
Comment thread config/rewrite.yml Outdated
@romani

romani commented Dec 29, 2025

Copy link
Copy Markdown
Member

@smita1078 , @stoyanK7 , do you agree with such js updates?

@smita1078

Copy link
Copy Markdown
Contributor

@smita1078 , @stoyanK7 , do you agree with such js updates?

I’m okay with these JS updates.
That said, these changes are not purely cosmetic:
var -> let changes scoping rules
"use strict" was removed, which weakens runtime safety guarantees

Even if the current behavior is unchanged, better to handle them in a separate PR

@romani

romani commented Dec 29, 2025

Copy link
Copy Markdown
Member

@smita1078 , if you think that some update should not be done, please state it and we will not do it.
Code should not become weaker , even it works same after update.

We show do update only if it is beneficial.

@Pankraz76

Copy link
Copy Markdown
Author

var -> let changes scoping rules

yes of course this is considered benefit as smallest scope possible always the best.

If not possible to use let this something is an issue or an valid ignore.

"use strict" was removed, which weakens runtime safety guarantees

yes then undo.

@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from 876727a to ac9ccad Compare December 30, 2025 09:16
@Pankraz76

Copy link
Copy Markdown
Author

var -> let changes scoping rules

After actually considering the code, most of the mutability turned out to be obsolete, as usual, so const seems to be a better fit. There are actually only two fields that change over time, coupling the whole code together.

Everything else has been boiled down to a minimal version, avoiding unnecessary coupling and promoting cohesion instead.

@Pankraz76 Pankraz76 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low quality, low cohesion, high violations, high coupling.

}

var name = anchorItem.previousSibling.previousElementSibling.id;
var link = "" + url + "#" + name + "";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dry

} else {
name = anchorItem.childNodes[0].name;
}
var link = "" + url + "#" + name + "";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dry 14 lines. C&P

Image Image

@Pankraz76 Pankraz76 requested a review from romani December 30, 2025 09:22
@smita1078

Copy link
Copy Markdown
Contributor

var -> let changes scoping rules

yes of course this is considered benefit as smallest scope possible always the best.

If not possible to use let this something is an issue or an valid ignore.

"use strict" was removed, which weakens runtime safety guarantees

yes then undo.

Agreed!, I think keeping strict mode avoids unnecessary risk. Better to not remove it. Thanks

Comment thread src/site/resources/js/anchors.js Outdated
Comment thread src/site/resources/js/anchors.js Outdated
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from ac9ccad to e27dc44 Compare December 30, 2025 11:07
Comment thread config/jsoref-spellchecker/whitelist.words
@Pankraz76 Pankraz76 force-pushed the pr-ECMAScript6BestPractices branch from e27dc44 to f9a106a Compare January 1, 2026 10:59
@romani

romani commented Jan 2, 2026

Copy link
Copy Markdown
Member

@smita1078 , please help to review this PR.

if you notice that this is no good direction, we can close this PR. JS is not primary in our repository, some not-perfect code is ok.

@Pankraz76

Copy link
Copy Markdown
Author

not-perfect code is ok

its not non perfect is has worst quality possible.

Its just working (by accident) just like the remaining code base, how needs this silly thing?

@Pankraz76 Pankraz76 closed this Jan 2, 2026
@smita1078

Copy link
Copy Markdown
Contributor

@smita1078 , please help to review this PR.

if you notice that this is no good direction, we can close this PR. JS is not primary in our repository, some not-perfect code is ok.

@romani I don’t think the discussion was moving in a productive direction anymore. From a review perspective, I also don’t think this change is needed right now since JS isn’t a primary focus for us.

@Pankraz76

Copy link
Copy Markdown
Author

JS isn’t a primary focus for us.

For me this text lacks a detailed explanation for why something is neither this nor that. It merely repeats the Romani excuse and fails to focus on the matter.

@romani

romani commented Jan 3, 2026

Copy link
Copy Markdown
Member

All changes should have clear definition of problem and clean and exact fix. Reviewers should see all clearly.
If not possible to be done now, ok, it will be done later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants