My question is: Are there any best practices for migrating code from ECMAScript 5.1 to ECMAScript 2021+? Are there any up-to-date and recommended tutorials on this? Or maybe there are even automated ways?
The way you write rules in JS Scripting is a lot different from Nashorn because the Helper Library that comes with JS Scripting is really good.
The link @JustinG provided is kind of a “make the fewest changes to my Nashorn scripts so they work in JS Scripting”. That is a valid approach.
However, you will find you will have dozens and dozens of lines of code that can be replaced with one call to a function in the helper library. Because of that and other significant changes in how the Helper Library works, you will likely want to rewrite from scratch those rules eventually to take advantage of the helper library.