fixmyjs
Meant to automatically fix your JavaScript errors in a non-destructive way.
Installing
npm install fixmyjs -g
Usage
fixmyjs your_file.js
Programatically
var fixmyjs = var stringFixedCode = fixmyjs
Tools
Options
When the options are set to true they are enabled. To get a breakdown of what is enabled by default check out package.json
camelcase
- Converts all identifiers to camelCasecurly
- Adds curly braces to all statements that don't have themcurlyfor
- Adds curly braces only to for statementscurlyif
- Adds curly braces only to if/if-else statementscurlywhile
- Adds curly braces only to while statementsdebug
- Removes debugger statementsdecimals
- Adds a leading0
for decimals or removes trailing zero if decimal is wholedelete
- Removes deletion of variablesemptyStatement
- Removes empty statementseqeqeq
- Enforce strict equalityes3
- EnforcesparseIntRadix
as well asno-comma-dangle
hoist
- Hoists all your vars to the top of the functioninitUndefined
- Rewrites variable initializations to undefinedinvalidConstructor
- Does not allow you to initialize built-in primitive constructorsinvokeConstructors
- Adds()
to any new expressionsisNan
- Replaces equality to NaN with isNaNmultivar
- Replace single var with multi line varno-comma-dangle
- Removes trailing commasnonew
- Removes new when using it for side effectsonevar
- Make multi var into one varparseIntRadix
- Adds a radix parameter to parseIntplusplus
- Converts++
and--
to+= 1
||-= 1
rmdelete
- Removes the deletion of variablesrmempty
- Removes empty statementssnakecase
- Convert all identifiers to snake_casesub
- Dot notation conversionuseLiteral
- Rewrites your primitives to use their literal form
Breaking Changes in 2.0
- Legacy mode has been removed.
- You now put your config inside package.json. You can check out an example in this project.
- All rules have been made truthy because having some rules be truthy and others falsy is weird.
- Option
es3
now enablesno-comma-dangle
as well as new optionparseIntRadix
.