LogoopenSUSE Build Service > Projects
Sign Up | Log In

Automatically fixes your JavaScript based on lint rule

Meant to automatically fix your JavaScript errors in a non-destructive way.


fixmyjs your_file.js


var fixmyjs = require('fixmyjs')
var stringFixedCode = fixmyjs.fix(stringOfCode, objectOfOptions)


These options are mostly named after their JSHINT counterparts.

Built in

delete - Removes deletion of variables
emptyStatement - Removes empty statements
initUndefined - Rewrites variable initializations to undefined
invalidConstructor - Does not allow you to initialize built-in primitive constructors
isNaN - Replaces equality to NaN with isNaN
useLiteral - Rewrites your primitives to use their literal form


When these are set to true the options apply.

camelcase - Converts all identifiers to camelCase
curly - Adds curly braces to all statements that don't have them
es3 - Adds a radix parameter to parseInt
nonew - Removes new when using it for side effects
snakecase - Convert all identifiers to snake_case
multivar - Replace single var with multi line var
plusplus - Converts ++ and -- to += 1 || -= 1
eqeqeq - Enforce strict equality


When these are set to false the options apply.

debug - Removes debugger statements
sub - Dot notation conversion

Legacy Mode

fixmyjs supports a legacy mode which can be used via the CLI and programatically.


fixmyjs --legacy your_file.js


var jshint = require('jshint').JSHINT
var fixmyjs = require('fixmyjs')
jshint(stringOfCode, objectOfOptions)
var stringFixedCode = fixmyjs(jshint.data(), stringOfCode, objectOfOptions).run()

Legacy uses JSHINT to determine what needs to be fixed and then uses a combination of regular expressions and string replacements to non-destructively fix any errors. While non-legacy supports more options, it is more prone to being destructive since the JavaScript is rewritten by the program.

Why is it legacy?

We're planning on moving away from code string transformations and into transforming the AST directly because these rules are easier to write, maintain, and offers flexibility in terms of what can be supported. 2.0 release will have fixmyjs using recast which will make fixmyjs more performant and less destructive, esformatter will also be included to perform any style changes.



Source Files

Filename Size Changed Actions
amdefine-1.0.0.tgz 7.33 KB Download File
balanced-match-0.4.2.tgz 2.49 KB Download File
brace-expansion-1.1.6.tgz 3.79 KB Download File
cli-1.0.0.tgz 14.2 KB Download File
commander-2.9.0.tgz 13.1 KB Download File
concat-map-0.0.1.tgz 2.21 KB Download File
console-browserify-1.1.0.tgz 3.42 KB Download File
core-util-is-1.0.2.tgz 6.85 KB Download File
date-now-0.1.4.tgz 2.47 KB Download File
deep-is-0.1.3.tgz 3.41 KB Download File
diff-1.4.0.tgz 8.33 KB Download File
domelementtype-1.0.0.tgz 548 Bytes Download File
domhandler-2.3.0.tgz 7.06 KB Download File
domutils-1.5.0.tgz 6.45 KB Download File
entities-1.0.0.tgz 16.8 KB Download File
escodegen-1.8.1.tgz 19.6 KB Download File
esprima-1.2.5.tgz 78.9 KB Download File
esprima-2.7.3.tgz 40.1 KB Download File
estraverse-1.9.3.tgz 8.15 KB Download File
esutils-2.0.2.tgz 9.08 KB Download File
exit-0.1.2.tgz 14.9 KB Download File
fast-levenshtein-1.1.4.tgz 4.05 KB Download File
fixmyjs-1.0.3.tgz 14.5 KB Download File
fixmyjs.changes 143 Bytes Download File
fixmyjs.json 6.71 KB Download File
fixmyjs.license 113 Bytes Download File
fixmyjs.source 3.4 KB Download File
fixmyjs.spec 5.78 KB Download File
fs.realpath-1.0.0.tgz 4.33 KB Download File
fu-0.1.0.tgz 12.2 KB Download File
glob-7.0.6.tgz 15 KB Download File
htmlparser2-3.8.3.tgz 25.2 KB Download File
inflight-1.0.5.tgz 1.76 KB Download File
inherits-2.0.0.tgz 1.91 KB Download File
inherits-2.0.1.tgz 2.07 KB Download File
isarray-0.0.1.tgz 2.68 KB Download File
jshint-2.9.3.tgz 713 KB Download File
levn-0.3.0.tgz 7.78 KB Download File
lodash-3.7.0.tgz 168 KB Download File
lru-cache-2.0.0.tgz 4.45 KB Download File
minimatch-1.0.0.tgz 17.5 KB Download File
minimatch-3.0.3.tgz 11.1 KB Download File
once-1.3.3.tgz 1.54 KB Download File
optionator-0.8.1.tgz 15.8 KB Download File
path-is-absolute-1.0.0.tgz 1.8 KB Download File
prelude-ls-1.1.2.tgz 9.08 KB Download File
readable-stream-1.1.14.tgz 20.1 KB Download File
shelljs-0.3.0.tgz 23.5 KB Download File
sigmund-1.0.1.tgz 3.72 KB Download File
source-map-0.2.0.tgz 43.7 KB Download File
string_decoder-0.10.31.tgz 3.52 KB Download File
strip-json-comments-1.0.4.tgz 2.53 KB Download File
type-check-0.3.2.tgz 6.57 KB Download File
wordwrap-1.0.0.tgz 14.2 KB Download File
wrappy-1.0.0.tgz 1.91 KB Download File

Comments for home:illuusio:nodejs-bundle (0)

Login required, please login or signup in order to comment