Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
JSHint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules. It helps developers identify potential errors and enforce coding standards.
Basic Linting
This feature allows you to perform basic linting on a piece of JavaScript code. The code sample demonstrates how to use JSHint to check a simple JavaScript snippet for errors.
const jshint = require('jshint').JSHINT;
const code = 'var a = 1;';
const options = { esversion: 6 };
jshint(code, options);
console.log(jshint.errors);
Custom Configuration
JSHint allows you to customize the linting process with various options. This example shows how to enable the 'undef' option to check for the use of undefined variables.
const jshint = require('jshint').JSHINT;
const code = 'var a = 1;';
const options = { esversion: 6, undef: true };
jshint(code, options);
console.log(jshint.errors);
Using JSHint with Configuration File
You can use a configuration file (e.g., .jshintrc) to define your linting rules. This example demonstrates how to read a JavaScript file and a JSHint configuration file, then lint the code using the specified rules.
const fs = require('fs');
const jshint = require('jshint').JSHINT;
const code = fs.readFileSync('path/to/your/file.js', 'utf8');
const config = JSON.parse(fs.readFileSync('.jshintrc', 'utf8'));
jshint(code, config);
console.log(jshint.errors);
ESLint is another popular JavaScript linting tool that is highly configurable and supports custom rules. It provides more flexibility and a larger ecosystem of plugins compared to JSHint.
JSCS (JavaScript Code Style) is a code style linter for JavaScript. It focuses more on enforcing coding style conventions rather than finding potential errors. It has been merged with ESLint, but older versions are still in use.
TSLint is a linter for TypeScript, which is a superset of JavaScript. It provides similar functionality to JSHint but is specifically designed for TypeScript code. TSLint is now deprecated in favor of ESLint with TypeScript support.
JSHint is a community-driven tool to detect errors and potential problems in JavaScript code and to enforce your team's coding conventions. We made JSHint very flexible so you can easily adjust it to your particular coding guidelines and the environment you expect your code to execute in.
Our goal is to help JavaScript developers write complex programs without worrying about typos and language gotchas.
We believe that static code analysis programs—as well as other code quality tools—are important and beneficial to the JavaScript community and, thus, should not alienate their users.
For general usage and hacking information, visit our website: http://jshint.com/.
Some bugs are so important to us, we will pay you if you fix them! Go to our page on BountySource to see which bugs have bounties behind them.
Really want to have something fixed but don't have time? You can add your own bounty to any JSHint bug and make it more attractive for potential contributors!
Rule: A bug is considered fixed only after it has been merged into the master branch of the main JSHint repository.
To report a bug simply create a new GitHub Issue and describe your problem or suggestion. We welcome all kind of feedback regarding JSHint including but not limited to:
Before reporting a bug look around to see if there are any open or closed tickets that cover your issue. And remember the wisdom: pull request > bug report > tweet.
If you're using so-called smart tabs
then we have an option smarttabs
for you. Otherwise, your solution is to
run JSHint with a custom reporter that discards any warnings you don't like.
For example, this example reporter
discards all warnings about mixed tabs and spaces.
Look for a file named CONTRIBUTING.md
in this repository. It contains our
contributing guidelines. We also have
a mailing list.
JSHint is distributed under the MIT License. One file and one file only (src/stable/jshint.js) is distributed under the slightly modified MIT License.
Core Team members:
Maintainer: Anton Kovalyov
We really appreciate all kind of feedback and contributions. Thanks for using and supporting JSHint!
2.0.0 (2013-05-08)
WARNING: This release introduces backwards incompatible changes.
JSHint 2.0.0 is out! This version hits a pretty big milestone for the project: this is the first JSHint release for which I'm not the biggest contributor. I personally believe this fact validates JSHint as a successful open source project. And I'm extremely thankful to all you who file bug reports and send patches—you're all awesome.
The first and foremost: starting with this version JSHint will assume ES5 as
the default environment. Before, JSHint was checking all the code per ES3
specification with an option to enable ES5 mode. Now ES5 mode is the default
mode and if you want to check your code against the ES3 specification (useful
when developing for super old browsers such as Internet Explorer 6) you will
have to use es3:true
.
Special thanks to Rick Waldron for championing this change.
Thanks to our newest core contributor, Bernard Pratz, JSHint now has partial
support for Mozilla JavaScript extensions (moz
option) and ES6 (esnext
option):
const
let
blocks and expressionsfor ... of
loopsWe have more patches in queue that add support for classes and other nifty ES6 things. Stay tuned!
.jshintrc
in the directory being linted.
(#833)For non-Node system we upgraded to the latest version of Browserify. This resolves some performance issues we had with Rhino.
Added SVG globals to the browser environment.
Option smarttabs
now ignores mixed tabs and spaces within single-
and multi-line comments.
Added a new pragma to unignore a warning:
/*jshint -W096 */
// All warnings about keys producing unexpected results will
// be ignored here.
/*jshint +W096 */
// But not here.
JSHint now ignores unrecognized JSLint options.
Fixed a bug where indent:false
was triggering indentation warnings.
(#1035)
Fixed a regression bug where unused
was not behaving correctly.
(#996)
Plus lots and lots of other, smaller bug fixes.
And last but not least: starting with this version, I'm switching JSHint to a more rapid release schedule. This simply means that I will be publishing new versions of JSHint more often. I will try my best to follow semver recommendations and ship working software. But as our license says, no guarantees.
Thanks to Bernarnd Pratz, Michelle Steigerwalt, Yuya Tanaka, Matthew Flaschen, Juan Pablo Buritica, Matt Cheely, Steve Mosley, Stephen Sorensen, Rick Waldron, Hugues Malphettes, Jeff Thompson, xzyfer, Lee Leathers, croensch, Steven Benner, James Allardice, Sindre Sorhus, Jordan Harband, Stuart Knightley and Kevin Locke for sending patches!
<a name="1.1.0"></a>
FAQs
Static analysis tool for JavaScript
The npm package jshint receives a total of 657,966 weekly downloads. As such, jshint popularity was classified as popular.
We found that jshint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.