{"id":25513,"library":"eslint-plugin-handlebars","title":"ESLint Plugin Handlebars","description":"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.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eslint","eslintplugin","eslint-plugin","handlebars","hbs","template","linting","formatting"],"install":[{"cmd":"npm install eslint-plugin-handlebars","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-handlebars","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-handlebars","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires ESLint >=8.57.0 to function","package":"eslint","optional":false}],"imports":[{"note":"ESM-only; CommonJS require is not supported. ESLint flat config requires ESM imports.","wrong":"const handlebars = require('eslint-plugin-handlebars')","symbol":"default","correct":"import handlebars from 'eslint-plugin-handlebars'"},{"note":"defineConfig is part of ESLint's flat config API; not available in legacy config.","wrong":"const { defineConfig } = require('eslint/config')","symbol":"defineConfig","correct":"import { defineConfig } from 'eslint/config'"},{"note":"In flat config, plugins are objects, not strings. The key is the namespace for rules.","wrong":"plugins: ['handlebars']","symbol":"plugins","correct":"plugins: { handlebars }"}],"quickstart":{"code":"// eslint.config.js\nimport { defineConfig } from \"eslint/config\";\nimport handlebars from \"eslint-plugin-handlebars\";\n\nexport default defineConfig([\n  {\n    plugins: {\n      handlebars,\n    },\n    rules: {\n      \"handlebars/block-spacing\": \"error\",\n      \"handlebars/consistent-quotes\": [\"error\", \"double\"],\n      \"handlebars/expression-spacing\": \"error\",\n      \"handlebars/indentation\": [\"error\", 2],\n      \"handlebars/no-missing-closing-tag\": \"error\",\n      \"handlebars/no-multiple-empty-lines\": [\"error\", { max: 1 }],\n      \"handlebars/no-trailing-spaces\": \"error\",\n    },\n  },\n]);\n","lang":"typescript","description":"Flat config example that enables all rules with error level, demonstrating recommended strict setup."},"warnings":[{"fix":"Switch to ESM: set \"type\": \"module\" in package.json and use import statements.","message":"ESM-only: require() not supported. Must use import syntax.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade ESLint to >=8.57.0.","message":"Requires ESLint >=8.57.0. Older ESLint versions incompatible.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Migrate to flat config using eslint.config.js.","message":"Flat config only; legacy .eslintrc configs not supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Run eslint with --fix for auto-fixable rules; manually fix missing closing tags.","message":"All rules are auto-fixable except no-missing-closing-tag.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set plugins: { handlebars } not plugins: ['handlebars'].","message":"Plugin name in flat config must match the import variable. Use 'handlebars' as plugin key.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install eslint-plugin-handlebars --save-dev and restart ESLint.","cause":"Missing npm install or incorrect import path in flat config.","error":"Error: Failed to load plugin 'handlebars' declared in 'plugins': Cannot find module 'eslint-plugin-handlebars'"},{"fix":"Change to plugins: { handlebars } (object with key matching the import).","cause":"Using array syntax ['handlebars'] in flat config instead of object.","error":"TypeError: plugins must be an object, a string, or a function"},{"fix":"Replace const handlebars = require('eslint-plugin-handlebars') with import handlebars from 'eslint-plugin-handlebars'.","cause":"Using require() in an ESM project.","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}