{"id":27184,"library":"npm-groovy-lint","title":"npm-groovy-lint","description":"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.","status":"active","version":"17.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/nvuillam/npm-groovy-lint","tags":["javascript","groovy","lint","jenkinsfile","codenarc","format","linter","formatter","auto-fix","typescript"],"install":[{"cmd":"npm install npm-groovy-lint","lang":"bash","label":"npm"},{"cmd":"yarn add npm-groovy-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add npm-groovy-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"CodeNarc runs on JVM; Java 17-24 must be installed separately","package":"java","optional":false}],"imports":[{"note":"ESM-only since v17; types included.","wrong":"const groovyLint = require('npm-groovy-lint')","symbol":"default","correct":"import groovyLint from 'npm-groovy-lint'"},{"note":"Named export for the class; preferred over default import.","wrong":"import NpmGroovyLint from 'npm-groovy-lint'","symbol":"NpmGroovyLint","correct":"import { NpmGroovyLint } from 'npm-groovy-lint'"},{"note":"TypeScript export for type checking.","wrong":"","symbol":"LinterOptions","correct":"import { LinterOptions } from 'npm-groovy-lint'"}],"quickstart":{"code":"import { NpmGroovyLint } from 'npm-groovy-lint';\n\nconst linter = new NpmGroovyLint({\n  source: 'def x = 1',\n  fix: true,\n  format: true,\n  rulesets: ['/path/to/ruleset.groovy'],\n});\n\nconst result = await linter.run();\nconsole.log(JSON.stringify(result, null, 2));\n// Expected output contains lintResult.files[0].errors and warnings","lang":"typescript","description":"Demonstrates linting a Groovy source string with auto-fix and formatting enabled."},"warnings":[{"fix":"Upgrade Node.js to version 22 or later.","message":"Dropped support for Node < 22; v17 requires Node >= 22.","severity":"breaking","affected_versions":">=17.0.0"},{"fix":"Use import statements; ensure package.json has \"type\": \"module\".","message":"CommonJS require style no longer works; package is ESM-only since v17.","severity":"deprecated","affected_versions":">=17.0.0"},{"fix":"Install Java runtime and set JAVA_HOME if not already set.","message":"Java must be installed (Java 17-24); CodeNarc runs on JVM.","severity":"gotcha","affected_versions":">=16.0.0"},{"fix":"Review rule configurations; run with --verbose to see rule changes.","message":"CodeNarc upgrade to 3.7.0 in v16 may change rule behavior.","severity":"breaking","affected_versions":">=16.0.0"},{"fix":"Review fixed output manually; upgrade to v15.2.2+ for partial fixes.","message":"Autofix may produce invalid code in some cases (e.g., Spock data providers).","severity":"gotcha","affected_versions":"<17.0.0"},{"fix":"Pull from ghcr.io/nvuillam/npm-groovy-lint instead of Docker Hub.","message":"Docker images now available on ghcr.io; older Docker Hub tags may not be updated.","severity":"gotcha","affected_versions":">=16.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install npm-groovy-lint` and ensure using ESM import (e.g., `import { NpmGroovyLint } from 'npm-groovy-lint'`).","cause":"Package not installed or import path incorrect.","error":"Error: Cannot find module 'npm-groovy-lint'"},{"fix":"Change to `import { NpmGroovyLint } from 'npm-groovy-lint'` (ESM) or `const { NpmGroovyLint } = await import('npm-groovy-lint')`.","cause":"Using CommonJS require or incorrect import syntax.","error":"TypeError: (0 , _npmGroovyLint.NpmGroovyLint) is not a constructor"},{"fix":"Install Java 17-24 and set JAVA_HOME. Verify with `java -version`.","cause":"Missing or incompatible Java version.","error":"java.lang.NoClassDefFoundError: org/codehaus/groovy/control/MultipleCompilationErrorsException"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}