Soon enough fixmyjs 2.0 will land on master and npm and with it we’ll get quite a few things.
This post is a guide on what’s changing in 2.0 and what’s left to get there.
This part is important. I attempted to avoid breaking changes but some tough decisions needed to happen.
This is definitely the biggest change. The reason for this is that it is not actively maintained. It’ll continue to be available on the 1.0 version.
Originally, fixmyjs used jshint to determine which errors it needed to fix. It would then use jshint’s reporting of line number and character positioning to perform a series of transformations on the source code string. These transformations are a set of regular expressions which aren’t easy to write or maintain. This also doesn’t have full coverage, for example, rewriting all your variables to use one-var style was impossible.
At some point this mode became “legacy” mode, yes the name is terrible. Fixmyjs adapted a new mode which did transformations on the AST and then regenerated the code again.
The problem was that this was a destructive operation since all the code had to be rewritten and this change turned out to be a mistake.
I still believe AST is the right path since it allows fixmyjs the freedom of better transformations. The real magic comes from a library called recast.
Recast generates only the parts of AST that have changed, thus making any destructions manageable. Couple recast along with esformatter and you have a tool that fixes your code and then beautifies it according to a set style guide. This is the future of fixmyjs and why legacy is no more.
The next large change is where you put your config.
Back when jshint powered fixmyjs all the configurations were pulled from a .jshintrc
file. Since we don’t rely on jshint any more it doesn’t make sense to continue to enforce a jshintrc file. This also makes it easier for fixmyjs to introduce new option names for fixing code.
The config object now lives in your package.json
. This is great because you probably have a package.json file already in your tree.
You can check out an example config in the fixmyjs project. Fixmyjs will use those set of options when transforming your files unless otherwise specified/overwritten.
This one is an artifact from jshint which in turn is an artifact from jslint. Some rules you enable via the flag true
, others via false
. This is confusing and difficult to remember. All rules are now enabled when true.
This obviously is an issue for rules such as snakecase
and camelcase
but if you have both enabled fixmyjs will throw an Error.
es3
The option has changed to enable no-comma-dangle
as well as new option parseIntRadix
.
The es3
option used to add the radix parameter to parseInt
. Now it removes trailing commas as well. In the future it’ll be a catch-all for all other es3 type transformations.
Well there’s quite a bit of testing I’d still like to do and some more docs and posts I intend to write about how to use fixmyjs.
Until then, feel free to sound off @goatslacker with any feature requests, comments, or concerns. Or open up a ticket on github.