Registry / testing / eslint-plugin-handlebars

eslint-plugin-handlebars

JSON →
library1.0.4jsnpmunverified

An ESLint plugin for linting Handlebars templates, version 1.0.4. It enforces consistent formatting and validates template syntax, including block spacing, quotes, indentation, and closing tags. Provides recommended and strict configurations. All rules are auto-fixable except no-missing-closing-tag. Requires ESLint >=8.57.0 and Node.js >=18.18.0. Unlike general formatters, it targets Handlebars-specific syntax errors and style issues.

npm install eslint-plugin-handlebars
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-HAND
E
eslint-plugin-handlebars
testingjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import handlebars from 'eslint-plugin-handlebars'
const handlebars = require('eslint-plugin-handlebars')
ESM-only; CommonJS require is not supported. ESLint flat config requires ESM imports.
defineConfig
import { defineConfig } from 'eslint/config'
const { defineConfig } = require('eslint/config')
defineConfig is part of ESLint's flat config API; not available in legacy config.
plugins
plugins: { handlebars }
plugins: ['handlebars']
In flat config, plugins are objects, not strings. The key is the namespace for rules.

Flat config example that enables all rules with error level, demonstrating recommended strict setup.

// eslint.config.js import { defineConfig } from "eslint/config"; import handlebars from "eslint-plugin-handlebars"; export default defineConfig([ { plugins: { handlebars, }, rules: { "handlebars/block-spacing": "error", "handlebars/consistent-quotes": ["error", "double"], "handlebars/expression-spacing": "error", "handlebars/indentation": ["error", 2], "handlebars/no-missing-closing-tag": "error", "handlebars/no-multiple-empty-lines": ["error", { max: 1 }], "handlebars/no-trailing-spaces": "error", }, }, ]);
Debug
Known issues
breakingESM-only: require() not supported. Must use import syntax.
fix
Switch to ESM: set "type": "module" in package.json and use import statements.
affects: >=1.0.0
breakingRequires ESLint >=8.57.0. Older ESLint versions incompatible.
fix
Upgrade ESLint to >=8.57.0.
affects: >=1.0.0
breakingFlat config only; legacy .eslintrc configs not supported.
fix
Migrate to flat config using eslint.config.js.
affects: >=1.0.0
gotchaAll rules are auto-fixable except no-missing-closing-tag.
fix
Run eslint with --fix for auto-fixable rules; manually fix missing closing tags.
affects: >=1.0.0
gotchaPlugin name in flat config must match the import variable. Use 'handlebars' as plugin key.
fix
Set plugins: { handlebars } not plugins: ['handlebars'].
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'handlebars' declared in 'plugins': Cannot find module 'eslint-plugin-handlebars'
Missing npm install or incorrect import path in flat config.
fix
Run npm install eslint-plugin-handlebars --save-dev and restart ESLint.
TypeError: plugins must be an object, a string, or a function
Using array syntax ['handlebars'] in flat config instead of object.
fix
Change to plugins: { handlebars } (object with key matching the import).
ReferenceError: require is not defined in ES module scope
Using require() in an ESM project.
fix
Replace const handlebars = require('eslint-plugin-handlebars') with import handlebars from 'eslint-plugin-handlebars'.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; plugin requires ESLint >=8.57.0 to function
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-handlebars — npm install eslint-plugin-handlebars · libregistry