Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

JSHint can catch many JavaScript mistakes before code runs by analyzing source files and reporting errors or potential problems. To make its warnings useful, configure it for your project’s ECMAScript version and runtime, enable relevant checks such as undef and unused, and run it consistently. It is a static-analysis aid—not a substitute for tests or runtime checks.

What JSHint can—and cannot—catch

JSHint analyzes JavaScript source and reports findings through its command-line interface (CLI) or JavaScript API. Its rules can flag issues such as references to undefined names and declarations that are never used. That gives you a chance to investigate problems during development, before relying on the code at runtime. See the official options reference, API documentation and CLI documentation.

Linting does not execute your program, prove that its behavior is correct, or guarantee that every bug will be reported. A finding may be a genuine mistake, a mismatch between the configuration and the project, or a rule that does not suit the code. Conversely, code can pass linting and still fail at runtime. Use JSHint alongside tests and runtime validation.

Choose rules that target likely mistakes

Start with checks that help reveal correctness problems, then adjust based on the project’s needs:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • undef reports references to names that have not been defined in the code or declared as globals.
  • unused identifies declarations that are not used.
  • curly and eqeqeq can flag patterns associated with mistakes, but choose them in light of your codebase and team conventions.

Check the current options reference before adopting a configuration: JSHint marks some options as deprecated, so old example configurations may not be appropriate.

Match the configuration to your JavaScript project

Set the syntax level

Use esversion to specify the ECMAScript syntax level the project targets. A mismatch can produce misleading results: a linter that does not recognize syntax your project uses may report noise, while a configuration that does not reflect the project’s target can make checks less useful. Confirm the available values in the options reference.

Select the runtime environment and declare globals

Configure the environment for the code being linted, such as browser or Node.js, and declare project-specific globals. This helps JSHint distinguish intended external names from accidental undefined variables. The globals setting can mark a name writable or read-only; choose the appropriate access for each name rather than broadly allowing undeclared identifiers. The options reference explains these settings: JSHint options.

Keep exceptions narrow

If a warning is safe to ignore, make the exception as limited as possible and document the reason. Broadly suppressing a rule can hide a later mistake; a warning should prompt you to check the code and the configuration before deciding it is harmless. JSHint documents inline configuration and related controls in its options reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Share one configuration and run it consistently

A common project configuration makes results more consistent between contributors and automated checks. JSHint’s CLI documentation describes configuration through a .jshintrc file, package.json, or an explicitly supplied configuration path. The CLI can also lint a directory recursively, making it practical to cover a project rather than only the file currently open. See the CLI documentation and configuration options.

For repeatable use, run the CLI from a project script or another automated check so the same configured analysis is available locally and in your development workflow. If a tool needs to analyze source programmatically, JSHint’s JavaScript API accepts source code, options and predefined globals; consult the API documentation for its usage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Investigate a warning instead of treating it as a verdict

  1. Check the reported code and determine whether it points to a real mistake, such as an accidental misspelling or an unused declaration.
  2. If the name is intentional, verify that the configured runtime and globals match the file’s actual environment.
  3. If the rule does not fit the project, review the current option documentation and make a narrow, documented adjustment rather than suppressing unrelated findings.
  4. Run the project’s tests and validate behavior at runtime; a clean lint result alone does not establish correctness.

JSHint’s documentation notes that even a missing comma may not produce a syntax error, and a linter cannot know whether the resulting function call was intentional. That illustrates the boundary: static analysis can highlight suspicious code, but some questions require understanding intent and checking actual behavior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.