fixmyjs 0,1,0,0,0,0,1 travis-ci npm

Automatically fix silly lint errors.

2 years after MIT

fixmyjs

Join the chat at https://gitter.im/jshint/fixmyjs

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

Build Status Coverage Status NPM version Dependency Status devDependency Status Download Count

Installing

npm install fixmyjs -g

Usage

fixmyjs your_file.js

Programatically

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

Tools

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

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

Related Repositories

essential-gulp-plugins

essential-gulp-plugins

Living list of most useful plugins for Gulp ...

essential-grunt-plugins

essential-grunt-plugins

Living list of most useful plugins for Grunt ...

atom-fixmyjs

atom-fixmyjs

Automagically fix JSHint lint warnings ...

gulp-fixmyjs

gulp-fixmyjs

Automatically fix JSHint results with fixmyjs ...

grunt-fixmyjs

grunt-fixmyjs

Automatically fix js-hint errors. ...


Top Contributors

goatslacker XhmikosR albertjan addyosmani azich samlecuyer lejenome adamjimenez fyockm hofmeister jlturner valueof gtramontina struys ldong PeterDaveHello richguan sindresorhus gitter-badger ubershmekel ishowshao

Dependencies

package version
commander ^2.3.0
diff ^1.0.7
escodegen ^1.4.1
esprima ^1.2.2
fu ^0.1.x
jshint ^2.5.6
minimatch ^1.0.0
dev coveralls ^2.11.2
ghooks ^0.2.2
istanbul ^0.3.5
testla ^0.1.x

Releases

-   v0.13.7 zip tar
-   v0.13.6 zip tar
-   v0.13.5 zip tar
-   v0.13.4 zip tar
-   v0.13.3 zip tar
-   v0.13.2 zip tar
-   v0.13.1 zip tar
-   v0.13.0 zip tar
-   v0.12.0 zip tar
-   v0.11.0 zip tar
-   v0.10.6 zip tar
-   v0.10.5 zip tar
-   v0.10.4 zip tar
-   v0.10.3 zip tar
-   v0.10.2 zip tar
-   v0.10.1 zip tar
-   v0.10.0 zip tar
-   v0.9.3 zip tar
-   v0.9.2 zip tar
-   v0.9.1 zip tar
-   v0.6.9 zip tar
-   v0.6.4 zip tar
-   v0.6.3 zip tar
-   v0.6.1 zip tar
-   v0.5.0 zip tar
-   v0.4.5 zip tar
-   v0.4.0 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar