npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

typo-scanner

v1.1.1

Published

A tool to detect and report typos in your JavaScript code

Readme

typo-scanner

A tool to detect and report typographical errors in your JavaScript code. It uses AST parsing along with spell-checking to identify potential typos in variable names, function names, comments, and more.

Table of Contents

Features

  • AST-Based Analysis: Leverages Babel to parse your JavaScript files and extract identifiers.
  • Spell-Checking Integration: Checks words against a dictionary and suggests corrections.
  • Duplicate Aggregation: Aggregates duplicate typo occurrences along with occurrence counts.
  • Customizable Whitelist: Easily configure a list of words (e.g., common JavaScript methods) to ignore.
  • HTML Report Generation: Generates a dark-themed HTML report with inline code highlights and tooltips.

Installation

Install the package via npm:

npm install typo-scanner

Or use it with npx:

npx typo-scanner <file-to-analyze.js>

Usage

Command-Line Interface

After installation, you can run the tool from the command line. For example:

typo-scanner sample.js

This command will analyze sample.js for typos and output the results in the console. If configured, it will also generate an HTML report in your project directory.

API Usage

You can also import and use typo-scanner programmatically in your Node.js projects:

const { analyzeFile } = require('typo-scanner');

const filePath = 'path/to/your/file.js';
const results = analyzeFile(filePath);

console.log(results);

Configuration

You can customize the behavior of typo-scanner by providing a configuration file (e.g., typoscanner.config.json) in your project root. This file may include:

  • Whitelist: Array of words that should not be flagged (e.g., ['forEach', 'map', 'filter', ...]).
  • Custom Dictionaries: Define additional words that are valid for your project.

Example configuration:

{
  "whitelist": [
    "forEach",
    "map",
    "filter",
    "reduce",
    "setTimeout",
    "clearTimeout",
    "console"
  ],
  "customDictionary": [
    "myCustomFunction",
    "myVariable"
  ]
}

Example

Consider a JavaScript file sample.js with the following content:

// This is a sampple JavaScript file with intentional typoes
function calcluateSum(a, b) {
  return a + b;
}

const numbrs = [1, 2, 3, 4];
let totl = 0;

numbrs.forEach(numbr => {
  totl += numbr;
});

console.log("The total is:", totl);

Running the command-line tool:

typo-scanner sample.js

Console-Based Analysis Output

Word: calcluateSum
Occurrences: 1
Suggestions: calculates
-> At line 3, column 9
   function calcluateSum(a, b) {
-----
Word: numbrs
Occurrences: 2
Suggestions: numbers, numbs, number's
-> At line 7, column 8
     const numbrs = [1, 2, 3, 4];
-> At line 10, column 2
     numbrs.forEach(numbr => {
-----
Word: totl
Occurrences: 3
Suggestions: total, tot, tots, toll, tote, toil, tool, tilt, tootle, toot
-> At line 8, column 6
     let totl = 0;
-> At line 11, column 4
       totl += numbr;
-> At line 14, column 31
     console.log("The total is:", totl);
-----
HTML report generated at: D:\NPM_Package_build\typo-scanner\src\report.html

HTML Report

If HTML reporting is enabled, an interactive report will be generated in your project directory. Below is a sample screenshot of the generated report:

Typo Scanner HTML Report

Testing

To run tests locally:

npm test

Make sure you have written tests (using Mocha, Jest, or another testing framework) to verify that your analyzer works as expected on a variety of sample inputs.

Contributing

Contributions are welcome! If you find a bug, have a feature request, or want to submit a pull request, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Write tests to cover your changes.
  4. Submit a pull request with a clear description of your changes.

Please refer to our CONTRIBUTING.md for more details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions, suggestions, or feedback, please open an issue on GitHub or contact [email protected].