GitHub 8
Skip to content

ESLint integration

Lint JavaScript, TypeScript, Vue templates, YAML and JSON locales, comments, and identifiers against your glossary with ESLint flat config.

glosslint/eslint checks JavaScript, TypeScript, Vue templates, YAML and JSON locale files, comments, and declared identifiers. It requires ESLint 9.15 or later and reads .agents/glossary.md by default.

For Nuxt projects using @nuxt/eslint and vue-i18n, see Nuxt and vue-i18n.

Spread glosslint() into your flat config after the parsers your project uses:

import glosslint from "glosslint/eslint";
import tseslint from "typescript-eslint";
import vueParser from "vue-eslint-parser";
import * as yamlParser from "yaml-eslint-parser";

export default [
  { files: ["**/*.ts"], languageOptions: { parser: tseslint.parser } },
  {
    files: ["**/*.vue"],
    languageOptions: { parser: vueParser, parserOptions: { parser: tseslint.parser } },
  },
  { files: ["**/*.yml"], languageOptions: { parser: yamlParser } },
  ...glosslint({ files: ["src/**/*.{ts,vue}", "locales/en.yml"] }),
];
eslint.config.ts

glosslint sets no parser of its own. Supply typescript-eslint for .ts, vue-eslint-parser for .vue, yaml-eslint-parser for YAML locales, and jsonc-eslint-parser for JSON locales. Scope locale files to your source locale. Plain JavaScript needs no extra parser.

Pass glossary to read another path, or corpus to pass a defineCorpus object instead. Passing both throws GLOSSLINT_C012.

import { defineCorpus, fromGlossary } from "glosslint";
import glosslint from "glosslint/eslint";

const corpus = defineCorpus({ extends: [fromGlossary()], wholeLabel: true });

export default [
  // ...parsers
  ...glosslint({ corpus, files: ["src/**/*.{ts,vue}", "locales/en.yml"] }),
];
eslint.config.ts

Note

ESLint needs jiti or --flag unstable_native_nodejs_ts_config to load eslint.config.ts. An eslint.config.mjs with the same contents needs neither on Node 22.18+.

All options on glosslint(options?) are optional.

Default: ".agents/glossary.md".

Path resolved from process.cwd(), or a URL, to your glossary file, read once when the config builds. Cannot be combined with corpus.

Default: none.

A Corpus object from defineCorpus to use instead of reading a glossary file. Cannot be combined with glossary.

Default: every file.

Glob patterns limiting which files the rules run on.

Default: ["endsWith", "startsWith", "includes", "querySelector*"].

Functions whose first argument is never checked. A trailing * matches a prefix, and passing a list replaces the default. t, $t, te, and tm are always skipped.

Default: false.

Reports avoid words inside declared names too. Off by default because renaming an identifier touches every caller.

Default: none.

Decides a string's kind before glosslint's built-in classifier runs. See Casing rules.

To change rule severities or disable a rule, add a config object after the spread:

export default [
  // ...parsers
  ...glosslint({ files: ["src/**/*.{ts,vue}", "locales/en.yml"] }),
  { rules: { "glosslint/identifier": "off" } },
];
eslint.config.ts
RuleSeverityReportsFix
glosslint/termerrorGLOSSLINT_TERM, GLOSSLINT_CASE in stringsautofix, or a suggestion where the text's shape set its kind
glosslint/avoiderrorGLOSSLINT_AVOID in stringssuggestion
glosslint/commenterrorall three codes in commentsautofix for spelling and casing, suggestion for avoid words
glosslint/identifierwarnhow a declared name splits into wordsnone, the message names the rename

Both rules check JS/TS string and template literals, Vue template text and static attributes, and YAML or JSON string values. glosslint/term autofixes spelling and casing, falling back to a suggestion when a context term's kind was guessed from text shape, while glosslint/avoid always offers an editor suggestion. See Casing rules and What glosslint doesn't check for skipped code strings, Vue attributes, and blanked spans.

Checks line, block, and Vue HTML comments for spellings, avoid words, and exact or abbreviated casing, ignoring context casing and tool directives like eslint-disable. Spelling and casing findings autofix; avoid words offer a suggestion.

Checks how declared variable, function, parameter, class, and property names split multi-word non-exact terms, keeping camel, snake, kebab, or SCREAMING_SNAKE style. It skips shorthand destructuring, never autofixes, and checks avoid words only when identifierAvoid is true.

Each diagnostic is one line combining the headline, the avoid or term reason, Term: description, the nuance, and See <url> when those fields exist. Its ESLint messageId is the finding code, listed in Findings.

With the eslint.config.ts above and the bike-share .agents/glossary.md, these three files:

# locales/en.yml
station:
  title: Buy a day pass
  description: Check-out starts when the dock lets go.
locales/en.yml
<!-- src/StationCard.vue -->
<template>
  <button title="Buy a Day pass">Find a hub near you</button>
</template>
src/StationCard.vue
// src/rides.ts
// Free the rack when the ride ends.
export const endRide = () => "Return your e-bike to any dock.";
export const daypassTotal = 2;
src/rides.ts

produce this output from eslint .:

locales/en.yml
  2:16  error  "day pass" is written "Day Pass" in labels  glosslint/term
  3:16  error  "Check-out" is spelled "Checkout"           glosslint/term

src/StationCard.vue
  2:24  error  "Day pass" is written "Day Pass" in labels                                                                                                               glosslint/term
  2:41  error  Use "station" instead of "hub". Riders confuse it with the depot. Station: A group of docks on one street corner. See https://example.com/docs/stations  glosslint/avoid

src/rides.ts
  1:13  error    Use "dock" instead of "rack". Racks are unpowered. Dock: A powered stand where one bike is locked. A station is a group of docks. See https://example.com/docs/docks  glosslint/comment
  2:43  error    "e-bike" is spelled "eBike"                                                                                                                                           glosslint/term
  3:14  warning  Rename "daypass" to "dayPass": the term is "Day Pass"                                                                                                                 glosslint/identifier

✖ 7 problems (6 errors, 1 warning)
  4 errors and 0 warnings potentially fixable with the `--fix` option.
txt

Running eslint --fix applies the four autofixable glosslint/term findings: it rewrites locales/en.yml to title: Buy a Day Pass and description: Checkout starts when the dock lets go., fixes "Day pass" in src/StationCard.vue and "e-bike" in src/rides.ts, and leaves "hub" and "rack" as suggestions for a person alongside the daypassTotal rename warning.