Registry / devops / npm-groovy-lint

npm-groovy-lint

JSON →
library17.0.4jsnpmunverified

Lint, format, and auto-fix Groovy, Jenkinsfile, and Gradle files. Current stable version 17.0.4 (released Dec 2024). Based on CodeNarc, it provides out-of-the-box linting with over 300 rules, formatting (--format), and auto-fixing (--fix). Unlike the Groovy compiler or code-narc CLI, it integrates directly into Node.js workflows, CI/CD pipelines, and editor extensions (VS Code). Ships TypeScript types. Release cadence is irregular with multiple patches per year. Requires Node >= 22.0.0 and Java (17-24) for CodeNarc.

npm install npm-groovy-lint
INSTALL
IMPORT
SIG · NPM-GROOVY-LINT
N
npm-groovy-lint
devopsjavascriptv17.0.4
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.

default
import groovyLint from 'npm-groovy-lint'
const groovyLint = require('npm-groovy-lint')
ESM-only since v17; types included.
NpmGroovyLint
import { NpmGroovyLint } from 'npm-groovy-lint'
import NpmGroovyLint from 'npm-groovy-lint'
Named export for the class; preferred over default import.
LinterOptions
import { LinterOptions } from 'npm-groovy-lint'
TypeScript export for type checking.

Demonstrates linting a Groovy source string with auto-fix and formatting enabled.

import { NpmGroovyLint } from 'npm-groovy-lint'; const linter = new NpmGroovyLint({ source: 'def x = 1', fix: true, format: true, rulesets: ['/path/to/ruleset.groovy'], }); const result = await linter.run(); console.log(JSON.stringify(result, null, 2)); // Expected output contains lintResult.files[0].errors and warnings
npm-groovy-lint --version
Debug
Known issues
breakingDropped support for Node < 22; v17 requires Node >= 22.
fix
Upgrade Node.js to version 22 or later.
affects: >=17.0.0
deprecatedCommonJS require style no longer works; package is ESM-only since v17.
fix
Use import statements; ensure package.json has "type": "module".
affects: >=17.0.0
gotchaJava must be installed (Java 17-24); CodeNarc runs on JVM.
fix
Install Java runtime and set JAVA_HOME if not already set.
affects: >=16.0.0
breakingCodeNarc upgrade to 3.7.0 in v16 may change rule behavior.
fix
Review rule configurations; run with --verbose to see rule changes.
affects: >=16.0.0
gotchaAutofix may produce invalid code in some cases (e.g., Spock data providers).
fix
Review fixed output manually; upgrade to v15.2.2+ for partial fixes.
affects: <17.0.0
gotchaDocker images now available on ghcr.io; older Docker Hub tags may not be updated.
fix
Pull from ghcr.io/nvuillam/npm-groovy-lint instead of Docker Hub.
affects: >=16.2.0
Errors
Common errors & fixes
Error: Cannot find module 'npm-groovy-lint'
Package not installed or import path incorrect.
fix
Run `npm install npm-groovy-lint` and ensure using ESM import (e.g., `import { NpmGroovyLint } from 'npm-groovy-lint'`).
TypeError: (0 , _npmGroovyLint.NpmGroovyLint) is not a constructor
Using CommonJS require or incorrect import syntax.
fix
Change to `import { NpmGroovyLint } from 'npm-groovy-lint'` (ESM) or `const { NpmGroovyLint } = await import('npm-groovy-lint')`.
java.lang.NoClassDefFoundError: org/codehaus/groovy/control/MultipleCompilationErrorsException
Missing or incompatible Java version.
fix
Install Java 17-24 and set JAVA_HOME. Verify with `java -version`.
Upgrade
Version history
17.0.4latest on npm
Audit
Dependencies
javarequiredCodeNarc runs on JVM; Java 17-24 must be installed separately
Agent activity
2 hits · last 30 days
node
2
Resources