LogoopenSUSE Build Service > Projects
Sign Up | Log In

Automatically fixes your JavaScript based on lint rule
https://www.npmjs.com/package/fixmyjs

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

Usage


fixmyjs your_file.js


Programatically

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

Options

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

Truthy

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

Falsy

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.

CLI

fixmyjs --legacy your_file.js

Programatically

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.

License

MIT

Source Files

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

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