Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>JS Error FinderNew to Visual Studio Code? Get it now.
JS Error Finder

JS Error Finder

Dineshkumar

|
32 installs
| (0) | Free
Finds undefined and undeclared variables in JS files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JS Error Finder

A lightweight VS Code extension that detects undefined and undeclared variables in JavaScript files (.js). It is designed to act as a simple "spell checker" for your variable names, helping you catch typos and scope errors without the complexity of setting up TypeScript or ESLint.

Features

  • Real-time Error Detection: Analyzes your code as you type or save.
  • Scope Awareness: Correctly handles:
    • Function scope (var)
    • Block scope (let, const)
    • Nested functions and blocks
    • Function parameters
  • Multi-Environment Support: Pre-configured to recognize global variables for:
    • Browser (window, document, console, alert, fetch, etc.)
    • Node.js (module, exports, require, process, __dirname, Buffer, etc.)
    • ES6+ Standards (Promise, Map, Set, Symbol, etc.)

Usage

  1. Install the extension.
  2. Open any .js file.
  3. The extension will automatically scan your code.
  4. Red squiggly lines will appear under variables that appear to be undefined or undeclared.
  5. Hover over the error to see the message: Variable 'xyz' is likely undeclared or undefined.

Examples

Catching Typos

const myConfig = { port: 3000 };
// Error: 'myConfg' is likely undeclared
console.log(myConfg.port); 

Scope Errors

function test() {
    let secret = "hidden";
}
// Error: 'secret' is likely undeclared (it is scoped to the function)
console.log(secret); 

Node.js Support

// Valid - no errors
const fs = require('fs');
console.log(process.env.NODE_ENV);
console.log(__dirname);

Advanced Analytics

Security Checks

The extension monitors your code for potential security vulnerabilities:

  • Eval Warning: eval("...") is flagged as a security risk.
  • Indirect Eval: setTimeout("...", 1000) allows code injection and is flagged.
  • Arbitrary Code Execution: new Function(...) is flagged.
  • XSS Prevention: Assignments to innerHTML or outerHTML triggers a warning to prevent Cross-Site Scripting.

Logic & Quality Capabilities

  • Const Reassignment:
    const PI = 3.14;
    PI = 3; // Error: Assignment to constant variable
    
  • Unused Variables:
    let data = "foo"; // Warning: 'data' is declared but never read
    

How it Works

This extension uses acorn to parse your JavaScript code into an Abstract Syntax Tree (AST). It builds a comprehensive scope map (Global, Function, Block, Class, Catch) and tracks:

  1. Declarations: Where variables are defined and their specific type (var/let/const/param/class).
  2. Usages: Where variables are referenced.
  3. Pattern Matching: Detecting specific AST nodes like CallExpression with 'eval' or AssignmentExpression to innerHTML.

Limitations

  • This is a static analysis tool and may not catch dynamic variable injections.
  • It assumes standard declaration patterns.
  • It is "loose" with globals—valid Node.js globals are accepted in client-side code and vice-versa, to prevent false positives in mixed-code workspaces.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft