eslint-linter-browserify
v10.11.0
Published
Use eslint in the browser
Maintainers
Readme
eslint-linter-browserify
Use ESLint in the browser.
Installation
npm install eslint-linter-browserifyUsage
Bundlers (ESM / CommonJS)
import * as eslint from "eslint-linter-browserify";
// or const eslint = require("eslint-linter-browserify");
const linter = new eslint.Linter();
const messages = linter.verify("var foo;", {
rules: {
semi: ["error", "never"]
}
}, { filename: "foo.js" });
console.log(messages);Browser (Script Tag / CDN)
Loading the UMD bundle directly via a <script> tag exposes window.eslint.Linter:
<script src="https://cdn.jsdelivr.net/npm/eslint-linter-browserify/linter.min.js"></script>
<script>
const linter = new eslint.Linter();
const messages = linter.verify("var foo;", {
rules: {
semi: ["error", "never"]
}
}, { filename: "foo.js" });
console.log(messages);
</script>Bundle Variants
| File / Package Specifier | Format | Description |
| --- | --- | --- |
| eslint-linter-browserify | ESM (linter.mjs) / CJS (linter.cjs) | Default entry points for bundlers (Vite, Rollup, Webpack, etc.) and Node.js |
| linter.min.js | UMD (minified) | Standalone minified bundle for browser <script> tags (window.eslint.Linter) |
| linter.js | UMD (unminified) | Standalone unminified bundle for development and debugging |
Documentation
For full details on the Linter API and supported options, see the ESLint Node.js API Documentation.
See the CodeMirror example for a way to use this in CodeMirror.
