eslint-linter-browserify
raw JSON → 10.2.1 verified Sat Apr 25 auth: no javascript
A browser-compatible build of ESLint that runs the Linter API client-side without Node.js. Version 10.2.1 mirrors ESLint's core linting engine, made available for browser environments via bundlers like webpack or direct script tags. It ships TypeScript definitions and supports ESM, CJS, and UMD. Unlike server-side ESLint, only the Linter class is available (no CLI, no built-in formatters). Key differentiator: enables real-time linting in browser-based code editors such as CodeMirror or Monaco.
Common errors
error Cannot find module 'eslint-linter-browserify' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install eslint-linter-browserify' and ensure import path is correct.
error linter.verify is not a function ↓
cause Using default import instead of named import: 'import Linter from ...' returns the module object, not the Linter class.
fix
Use 'import { Linter } from 'eslint-linter-browserify''.
error ReferenceError: require is not defined ↓
cause Using CJS require in an ESM context (e.g., modern browser or Node with 'type':'module').
fix
Use import instead, or switch to a bundler that supports require.
error Failed to load rule 'no-undef': Cannot find module 'eslint/lib/rules/no-undef' ↓
cause Trying to load a rule that expects Node.js module resolution; browser build may not include all rules.
fix
Only use rules that are bundled with the linter. Check the package's bundled rules list.
Warnings
binding Only the Linter class is available; other ESLint APIs (CLIEngine, RuleTester, etc.) are not bundled. ↓
fix Use only Linter. For other APIs, consider server-side ESLint.
gotcha Rules that require file system access (e.g., 'import', 'node') may not work or behave differently in the browser. ↓
fix Only use syntax and built-in rules that don't rely on Node.js APIs. Test thoroughly.
deprecated The namespace import via <script> tag returns the linter object as window.eslint. Ensure script order if using multiple bundles. ↓
fix Use <script src='linter.js'> before any code that depends on window.eslint.
Install
npm install eslint-linter-browserify yarn add eslint-linter-browserify pnpm add eslint-linter-browserify Imports
- Linter wrong
import Linter from 'eslint-linter-browserify'correctimport { Linter } from 'eslint-linter-browserify' - eslint (namespace) wrong
const eslint = require('eslint-linter-browserify')correctimport * as eslint from 'eslint-linter-browserify' - type Linter wrong
import { Linter } from 'eslint-linter-browserify' // no runtime import neededcorrectimport type { Linter } from 'eslint-linter-browserify'
Quickstart
import { Linter } from 'eslint-linter-browserify';
const linter = new Linter();
const code = "var foo = 1;";
const config = {
rules: {
semi: ["error", "always"],
"no-var": ["error"]
}
};
const messages = linter.verify(code, config, { filename: "test.js" });
console.log(messages);
// Example output: [{ line: 1, column: 1, message: "Unexpected var, use let or const instead.", ruleId: "no-var", severity: 2 }]