Registry / testing / eslint-plugin-html

eslint-plugin-html

JSON →
library8.1.4jsnpmunverified

ESLint plugin to lint and fix inline scripts inside HTML files. Current stable version is 8.1.4, with a release cadence of several months. It integrates with ESLint's flat config (ESLint 9+) and legacy config, supports multiple script tags per file with shared or module scope, and provides settings for HTML/XML extensions, indentation, and ignoring script tags without type. Unlike other HTML linting plugins, it focuses exclusively on JavaScript within HTML without providing HTML-specific rules.

npm install eslint-plugin-html
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-HTML
E
eslint-plugin-html
testingjavascriptv8.1.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin object)
✓ import html from 'eslint-plugin-html'
✗ const html = require('eslint-plugin-html')
CommonJS require works but is not recommended; ESM is standard since ESLint 9.
processors
✓ const { processors } = require('eslint-plugin-html')
✗ import { processors } from 'eslint-plugin-html'
The package exports a default object with processors; named exports are available but not the main entry point for flat config.
Rules (none directly exported)
✓ import html from 'eslint-plugin-html' // then use html.rules if needed
✗ import { rules } from 'eslint-plugin-html'
This plugin does not define custom rules; it only provides a processor. Use default import to access the processor via html.processors['.html'].

Configures ESLint to lint inline scripts in HTML files using flat config (ESLint 9+).

// Install: npm install --save-dev eslint eslint-plugin-html // eslint.config.js import html from 'eslint-plugin-html'; export default [ { files: ['**/*.html'], plugins: { html }, rules: { 'semi': 'error' } } ]; // Then lint: npx eslint index.html
Debug
Known issues
breakingIn v8, ESLint 9 flat config is the primary configuration method; legacy config (.eslintrc) may still work but is discouraged.
fix
Adopt flat config as shown in the quickstart or use the 'legacy' plugin wrapper if you must use .eslintrc.
affects: >=8.0.0
breakingVersion 5+ drops support for Node < 6 and ESLint < 4.
fix
Upgrade Node to >=6 and ESLint to >=4.
affects: >=5.0.0
deprecatedThe 'html/html-extensions' setting is deprecated; use ESLint's built-in file extension matching.
fix
Remove 'html/html-extensions' and rely on the 'files' pattern in flat config.
affects: >=7.0.0
gotchaBy default, multiple script tags share global scope (non-module). This can cause false positives if variables are reused across tags.
fix
Set 'sourceType: module' in ESLint parser options if using ES modules.
affects: *
gotchaXML files with script tags are also linted if .xml is registered via settings.
fix
If you don't need XML linting, ensure 'html/xml-extensions' is not set.
affects: *
Errors
Common errors & fixes
ESLint couldn't find the plugin 'eslint-plugin-html'.
Plugin not installed or not listed in eslint.config.js correctly.
fix
Run 'npm install --save-dev eslint-plugin-html' and ensure the import path is correct.
Configuration for rule 'html/indent' is invalid.
The rule 'html/indent' does not exist; it's a setting, not a rule.
fix
Use the 'settings' property: settings: { html: { indent: 4 } } instead of rules.
The 'plugins' section in .eslintrc is for legacy config only.
Using .eslintrc instead of flat config with v8.
fix
Switch to eslint.config.js flat config, or use the 'legacy' plugin object (import { legacy } from 'eslint-plugin-html').
Upgrade
Version history
8.1.4latest on npm
Audit
Dependencies
eslintoptionalPeer dependency; the plugin extends ESLint functionality.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-html — npm install eslint-plugin-html · libregistry