Coder Social home page Coder Social logo

fixmyjs's Introduction

JSHint, A Static Code Analysis Tool for JavaScript

[ Use it onlineDocsFAQInstallContributeBlogTwitter ]

NPM version Linux Build Status Windows Build status Coverage Status

JSHint is a community-driven tool that detects errors and potential problems in JavaScript code. Since JSHint is so flexible, you can easily adjust it in the environment you expect your code to execute. JSHint is publicly available and will always stay this way.

Our goal

The project aims to help JavaScript developers write complex programs without worrying about typos and language gotchas.

Any code base eventually becomes huge at some point, so simple mistakes — that would not show themselves when written — can become show stoppers and add extra hours of debugging. So, static code analysis tools come into play and help developers spot such problems. JSHint scans a program written in JavaScript and reports about commonly made mistakes and potential bugs. The potential problem could be a syntax error, a bug due to an implicit type conversion, a leaking variable, or something else entirely.

Only 15% of all programs linted on jshint.com pass the JSHint checks. In all other cases, JSHint finds some red flags that could've been bugs or potential problems.

Please note, that while static code analysis tools can spot many different kind of mistakes, it can't detect if your program is correct, fast or has memory leaks. You should always combine tools like JSHint with unit and functional tests as well as with code reviews.

Reporting a bug

To report a bug simply create a new GitHub Issue and describe your problem or suggestion. We welcome all kinds of feedback regarding JSHint including but not limited to:

  • When JSHint doesn't work as expected
  • When JSHint complains about valid JavaScript code that works in all browsers
  • When you simply want a new option or feature

Before reporting a bug, please look around to see if there are any open or closed tickets that discuss your issue, and remember the wisdom: pull request > bug report > tweet.

Who uses JSHint?

Engineers from these companies and projects use JSHint:

And many more!

License

JSHint is licensed under the MIT Expat license.

Prior to version 2.12.0 (release in August 2020), JSHint was partially licensed under the non-free JSON license. The 2020 Relicensing document details the process maintainers followed to change the license.

The JSHint Team

JSHint is currently maintained by Rick Waldron, Caitlin Potter, Mike Pennisi, and Luke Page. You can reach them via [email protected].

Previous Maintainers

Originating from the JSLint project in 2010, JSHint has been maintained by a number of dedicated individuals. In chronological order, they are: Douglas Crockford, Anton Kovalyov, and Mike Sherov. We appreciate their long-term commitment!

Thank you!

We really appreciate all kinds of feedback and contributions. Thanks for using and supporting JSHint!

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fixmyjs's Issues

Enable api to fix one error at a time

Blindly auto-fixing an entire file can cause problems.
I've integrated autofix into ShiftEdit and set it so that that you can fix one error at a time.
In order to get this to work I had to heavily bastardise the script. Would be cool if the API supported a way to check if a single error is fixable and then return the fixed line.

package / examples / license

Be great if there was a packaged js file for this and some demos that could be viewed.
Also what license is this under?

Very interesting project, look forward to your reply.

duplicates vars in one line

The following line:

  var aw, ah, i, j, c, a, cw, ch, x, w, h, a, col, colWidth, offset, availablePercentWith = viewSize.width,

was transformed to:

  aw, ah, i, j, c, a, cw, ch, x, w, h, a, col, colWidth, offset, availablePercentWith = viewSize.width,

causing all variables to become global. Because "a" is declared twice, it doesn't work well in the context of multiple variables under a single var.

Can you look into this issue?

Bugs with "['{a}'] is better written in dot notation." fix

JSHint will report two ['foo'] is better written in dot notation. warnings for this line:

window['foo'] = window['foo'] || function () {};

fixMyJS will fix both of them but in the wrong order, throwing off character offsets

"['foo'] is better written in dot notation." (at 1:24)
fix: "window.foo = window['foo'] || function () {};"

"['foo'] is better written in dot notation." (at 1:8)
fix: "window.foo = window.foo || function () {};"

Additionally fixMyJS won't fix the dot notation error for this because of the whitespace:

window[ 'foo' ] = function () {};

With the white option on, the dot notation error has a character offset greater than the unexpected space after [ error. I think the offset for the dot notation is incorrect so I have filed a JSHint bug: jshint/jshint#601

You might be able to just eat the whitespace between the brackets but with the white flag on, you may have to account for some unexpected space errors that will be irrelevant at that point.

leading dot

I got the following line:

              var ratio = parseFloat(a.replace('%', ''))*.01;

converted to:

              var ratio = parseFloat(a0.replace('%', ''))*.01;

It seems like it used the first (.) instead of the second one. I'd recommend using a stronger regex pattern for the replacement.

Incorrect space insertion

I found a strange issue where if I have a line like the below with mixed spaces and tabs at the beginning of the line, it adds a space between the 'r' and 'e' in redis, adds a semicolon at the end of the line, adds an extra space before 'response', and doesn't remove the tab:

                    redis_client.set(key, JSON.stringify(doc), function(redis_err, response) {

... is changed to:

                    redis_client.set(key, JSON.stringify(doc), function(r edis_err,  response) {;

Great tool so far though, it's coming in handy.

add newline fixes

function bind(fn, ctx) {
  return function() {
    fn.apply(ctx, arguments); };
}

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.