javascript
JavaScript files: the shipped lint rules, type checks through JSDoc, and no unused code. Guide: JavaScript and TypeScript.
Selected when
Section titled “Selected when”A scope has file extensions .js, .jsx, .mjs, or .cjs, or a file with a shebang for node, or a project file package.json. Also when astro, cloudflare, drizzle, express, jest, react, react-hook-form, supabase, svelte, tanstack-query, testing-library, translations, trpc, typescript, vitest, vue, zod, or zustand requires it.
Checks
Section titled “Checks”eslint
Section titled “eslint”Runs the shipped ESLint rules on JavaScript, TypeScript, component files, and package.json.
Runs at the commit stage, and needs the installed npm dependencies. gspot check --fix fixes what it can.
ESLint catches mistakes that the runtime accepts: unused code, unsafe patterns, and functions that only forward.
What to do
Section titled “What to do”Run the fix: command that the report prints for the rules that fix themselves, then read each remaining line; gspot explain javascript/eslint <rule> links the rule documentation.
Example
Section titled “Example”The declaration const unused = 1; reports no-unused-vars. Delete the variable.
Turn it off
Section titled “Turn it off”gspot ignore javascript/eslint --paths "<path>" --reason "<why>"gspot ignore javascript/eslint --rule <rule> --reason "<why>"To silence one place, write a comment such as:
// eslint-disable-next-line no-console -- reason: the command prints its resultimport-cycles
Section titled “import-cycles”Reports import cycles between modules.
Runs at the push stage, with eslint.
A cycle makes the start order of a module depend on which file loads first.
What to do
Section titled “What to do”Move the code that both files share to a module that imports neither of them.
Example
Section titled “Example”a.ts imports b.ts, and b.ts imports a.ts: import-x/no-cycle reports each import. Move the shared code to a third module.
Turn it off
Section titled “Turn it off”gspot ignore javascript/import-cycles --paths "<path>" --reason "<why>"gspot ignore javascript/import-cycles --rule <rule> --reason "<why>"Type-checks plain JavaScript through its JSDoc comments.
Runs at the push stage, once per scope, and needs the installed npm dependencies.
A wrong call in JavaScript crashes at run time, and written types let the checker catch it first.
What to do
Section titled “What to do”Add or fix the JSDoc type that the error names.
Example
Section titled “Example”Passing a number to a JSDoc string parameter reports a type error. Pass a string, or fix the JSDoc.
Turn it off
Section titled “Turn it off”gspot ignore javascript/tsc --paths "<path>" --reason "<why>"gspot ignore javascript/tsc --rule <rule> --reason "<why>"To silence one place, write a comment such as:
// @ts-expect-error reason: the library types omit this overloadFinds files, exports, and dependencies nothing uses.
Runs at the push stage, once per scope, and loads your code and needs the installed npm dependencies.
Code that nothing uses still gets read, maintained, and shipped.
What to do
Section titled “What to do”Import the file from the code or test that uses it. Delete it when nothing will. For a file that a tool loads by path, add it to javascript.entry_files.
Example
Section titled “Example”An export that no entry point uses reports a finding. Remove it, or list a dynamically loaded file in javascript.entry_files.
Turn it off
Section titled “Turn it off”gspot ignore javascript/knip --paths "<path>" --reason "<why>"gspot ignore javascript/knip --rule <rule> --reason "<why>"Checks the cognitive complexity of each function against limits.javascript.max_cognitive_complexity and limits.typescript.max_cognitive_complexity.
Runs at the commit stage, only at the all level.
Nested control flow makes a function harder to follow and change.
What to do
Section titled “What to do”Separate the tasks in the reported function to reduce its cognitive complexity.
Example
Section titled “Example”Nested conditions raise the cognitive score. Move each independent task into its own function.
Turn it off
Section titled “Turn it off”gspot ignore javascript/biome --paths "<path>" --reason "<why>"gspot ignore javascript/biome --rule <rule> --reason "<why>"A suppression comment is refused; use gspot ignore.
Settings
Section titled “Settings”| Setting | What it sets |
|---|---|
javascript.script_files |
The files that may print to the console and call process.exit. |
javascript.import_boundaries |
Folders that a relative import may not leave, such as src/features/*. An import of a file outside them takes the alias, and eslint --fix writes it. |
javascript.externals |
Import specifiers that the runtime provides, such as ../../scripts/app.js in a host application. Globs match several. |
javascript.import_extension |
The import suffix in this scope: js for compiled ESM, ts for Deno and Bun, or extensionless for code that a bundler builds. |
javascript.banned_imports |
Imports that this repository refuses, each with a name and a message. |
javascript.entry_files |
Entry points knip starts from beyond the ones the framework configuration declares. |
javascript.allowed_unused_dependencies |
Exact package names that knip does not report as unused; new names need a reason, and a scope list applies to that project only. |
tools.eslint.rules |
Option arrays by ESLint rule ID, without a severity, for rules that the level runs. gspot refuses options for any other rule. Ignore a finding with gspot ignore javascript/eslint --rule <rule> --reason "<why>". |
tools.eslint.override |
Lint rule options for repository-relative paths, in order, with ignores applied last. |
tools.eslint.plugins |
ESLint plugins of your own: a rule prefix as name, a tracked .js or .mjs module as path or a pinned npm package as package and version, and the rules that turn on as errors. |
Lint rules turned off
Section titled “Lint rules turned off”| Lint rules | Files | Why |
|---|---|---|
import-x/no-default-export, unicorn/no-top-level-side-effects |
**/*.config.* |
A tool reads the default export of its config file, which the file builds when it loads. |
Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/COMPONENTS.md |
The repository has a dependency on astro, svelte, vue, or react. |
.gspot/rules/DENO.md |
The repository has filenames deno.json, deno.jsonc, or **/supabase/config.toml, or a JavaScript runtime deno. |
.gspot/rules/JAVASCRIPT.md |
Always |
.gspot/rules/PLAYWRIGHT.md |
The repository has a filename playwright.config.*, or a dependency on @playwright/test. |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| eslint | 10.13.0 |
| biome | 2.6.3 |
| @eslint/js | 10.0.1 |
| @gspothq/eslint-plugin | 0.3.2 |
| eslint-plugin-unicorn | 78.0.0 |
| eslint-plugin-security | 4.2.0 |
| eslint-plugin-perfectionist | 5.12.1 |
| eslint-plugin-n | 18.4.1 |
| eslint-plugin-jsdoc | 65.3.11 |
| eslint-plugin-regexp | 3.3.1 |
| eslint-plugin-import-x | 4.17.1 |
| eslint-import-resolver-typescript | 4.4.5 |
| eslint-plugin-boundaries | 7.2.1 |
| eslint-plugin-package-json | 1.10.1 |
| eslint-config-prettier | 10.1.8 |
| globals | 17.13.0 |
| knip | 6.41.0 |
| tsc | 5.9.3 |
Files gspot writes
Section titled “Files gspot writes”eslint.config.mjs, .gspot/configurations/javascript/eslint/eslint.mjs, .gspot/configurations/javascript/jsconfig.json, .gspot/configurations/javascript/biome.json, .gspot/configurations/javascript/knip.json, .gspot/configurations/javascript/eslint/functions.mjs, .gspot/configurations/javascript/eslint/fixes.mjs, and .gspot/configurations/javascript/eslint/import-cycles.mjs
Paths that must stay out of Git
Section titled “Paths that must stay out of Git”**/node_modules/** and **/bower_components/**. repository/local-files reports a tracked file at these paths.