java-lint
raw JSON → 0.3.0 verified Fri May 01 auth: no javascript deprecated
A Java lint utility library focused on removing unused imports. Current version 0.3.0 ships TypeScript types and requires Node.js ^18.13.0 || >=20.2.0. It uses java-parser for AST parsing. The package has been superseded by eslint-plugin-java-lang starting at v0.4.0, which converts the project into an ESLint plugin format. Key differentiators: lightweight, focused only on unused import removal, but with caveats about false negatives due to lazy global identifier collection.
Common errors
error TypeError: removeUnusedImports is not a function ↓
cause Using CommonJS require which returns an object with default export?
fix
Use ESM import: import { removeUnusedImports } from 'java-lint'
Warnings
deprecated This package is superseded by eslint-plugin-java-lang as of v0.4.0. ↓
fix Migrate to eslint-plugin-java-lang.
gotcha False negatives possible: global identifiers collection is lazy. ↓
fix Review results manually or consider using eslint-plugin-java-lang.
gotcha Requires Node.js ^18.13.0 || >=20.2.0 ↓
fix Ensure Node.js version compatibility.
Install
npm install java-lint yarn add java-lint pnpm add java-lint Imports
- removeUnusedImports wrong
const removeUnusedImports = require('java-lint').removeUnusedImports;correctimport { removeUnusedImports } from 'java-lint'
Quickstart
import { removeUnusedImports } from 'java-lint';
const source = `package my.project;
import my.project.pack.Unused;
class Foo {}`;
const cleaned = removeUnusedImports(source);
console.log(cleaned);
// Output: "package my.project;\n\nclass Foo {}"