Registry / testing / gremlint

gremlint

JSON →
library3.8.1jsnpmunverified

Gremlint is a dedicated linter and code formatter for the Gremlin graph query language, currently at stable version 3.8.1. It follows Apache TinkerPop releases with a cadence tied to TinkerPop (approximately bi-annual major releases). Unlike general SQL formatters, it understands Gremlin's traversal semantics and syntax (including steps, lambdas, and closures), providing automatic formatting, style enforcement, and error detection. It is ESM-only and ships TypeScript type definitions. It requires Node.js 20+ and works in both CLI and programmatic modes.

npm install gremlint
INSTALL
IMPORT
SIG · GREMLINT
G
gremlint
testingjavascriptv3.8.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatGremlinQuery
import { formatGremlinQuery } from 'gremlint'
const { formatGremlinQuery } = require('gremlint')
ESM-only package; do not use require().
lintGremlinQuery
import { lintGremlinQuery } from 'gremlint'
import lintGremlinQuery from 'gremlint'
Named export, not default.
GremlintConfig
import type { GremlintConfig } from 'gremlint'
import { GremlintConfig } from 'gremlint'
GremlintConfig is a TypeScript type; only import as type.
GremlintError
import { GremlintError } from 'gremlint'
Class export for handling lint/format errors.

Demonstrates programmatic formatting of a Gremlin query string with indentation and line length options, plus basic error handling and CLI equivalent.

import { formatGremlinQuery } from 'gremlint'; const query = 'g.V().hasLabel("person").out("knows").values("name")'; try { const formatted = formatGremlinQuery(query, { indentation: 2, maxLineLength: 80 }); console.log(formatted); } catch (error) { if (error instanceof GremlintError) { console.error('Formatting failed:', error.message); } } // CLI usage example: // npx gremlint --format --file query.gremlin --indent 2 --max-len 80
Debug
Known issues
breakingESM-only since v3.0: require() throws ERR_REQUIRE_ESM.
fix
Switch to import or use dynamic import().
affects: >=3.0
breakingNode.js 20+ required; older versions fail with engine check.
fix
Update Node.js to v20 or higher.
affects: >=3.0
deprecatedformatGremlinQuery options object changed in v3.5: 'tabSize' renamed to 'indentation', 'maxLen' renamed to 'maxLineLength'.
fix
Use new option names: indentation (number) and maxLineLength (number).
affects: >=3.5
gotchalintGremlinQuery returns an array of lint diagnostics, not a boolean.
fix
Check diagnostics.length === 0 for success; array contains { line, column, message, severity } objects.
affects: >=1.0
gotchaDefault export removed in v2.0: use named exports only.
fix
Import specific named exports (formatGremlinQuery, lintGremlinQuery, etc.) instead of default import.
affects: >=2.0
breakingGremlintError constructor changed in v3.2; instantiating with new GremlintError() now requires a detail object.
fix
Use: new GremlintError({ message: '...', query: '...' })
affects: >=3.2
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.
Using CommonJS require() on an ESM-only package.
fix
Replace const x = require('gremlint') with import { x } from 'gremlint'
TypeError: gremlint.formatGremlinQuery is not a function
Attempted default import when only named exports exist.
fix
Use import { formatGremlinQuery } from 'gremlint' instead of import gremlint from 'gremlint'
Error: Unsupported engine: gremlint@3.8.1: wanted: {"node":">=20"} (current: {"node":"18.12.1","npm":"8.19.2"})
Node.js version below 20.
fix
Upgrade Node.js to version 20 or later.
SyntaxError: Unexpected token '.' in JSON at position ... while parsing query
Passing an invalid Gremlin query string (e.g., missing closing quotes or parentheses).
fix
Validate the query syntax before calling formatGremlinQuery; catch GremlintError for detailed diagnostics.
Upgrade
Version history
3.8.1latest on npm
Audit
Dependencies
gremlinoptionalRuntime dependency for parsing and validating Gremlin queries during linting
Agent activity
6 hits · last 30 days
node
6
Resources
gremlint — npm install gremlint · libregistry