GithubHelp home page GithubHelp logo

isabella232 / fixmyjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jshint/fixmyjs

0.0 0.0 0.0 1.64 MB

Automatically fix silly lint errors.

Home Page: http://fixmyjs.com

License: Other

JavaScript 100.00%

fixmyjs's Introduction

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

fixmyjs's People

Contributors

adamjimenez avatar addyosmani avatar azich avatar fyockm avatar gitter-badger avatar goatslacker avatar gtramontina avatar hofmeister avatar ishowshao avatar ldong avatar lejenome avatar peterdavehello avatar richguan avatar samlecuyer avatar sindresorhus avatar struys avatar ubershmekel avatar valueof avatar xhmikosr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.