{"id":25719,"library":"handlebars-lint","title":"handlebars-lint","description":"Lint Handlebars templates for missing variables, helpers, block helpers, or partials. Current stable version is 1.0.0. The package takes a template string and a context object with known helpers and variables, then returns an object categorizing any missing references. It differentiates between variables, helpers, block helpers, and partials. There is no active maintenance; the last release was in 2016 and the GitHub repository has been archived. It requires Node >=4 and depends on the `handlebars` package for parsing.","status":"deprecated","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/handlebars-lint","tags":["javascript","find","handlebars","helpers","lint","missing","template","templates","variables"],"install":[{"cmd":"npm install handlebars-lint","lang":"bash","label":"npm"},{"cmd":"yarn add handlebars-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add handlebars-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally to parse and compile templates for linting. Must be installed separately as a peer dependency.","package":"handlebars","optional":true}],"imports":[{"note":"Package is CommonJS, but ESM import works as default export.","wrong":"const lint = require('handlebars-lint');","symbol":"default","correct":"import lint from 'handlebars-lint';"},{"note":"The module exports a single function; named import is incorrect.","wrong":"import { lint } from 'handlebars-lint';","symbol":"lint","correct":"const lint = require('handlebars-lint');"},{"note":"Type imports are available if using TypeScript with the package's bundled types.","wrong":"import { LintResult } from 'handlebars-lint';","symbol":"types","correct":"import type { LintResult } from 'handlebars-lint';"}],"quickstart":{"code":"import Handlebars from 'handlebars';\nimport lint from 'handlebars-lint';\n\nconst template = '{{greeting}} {{name}}';\nconst context = {\n  helpers: {},\n  variables: { greeting: 'Hello' }\n};\nconst missing = lint(template, { context });\nconsole.log(missing);\n// { variables: [ 'name' ], helpers: [], partials: [], blockHelpers: [] }","lang":"typescript","description":"This shows how to lint a simple Handlebars template for missing variables using the default import."},"warnings":[{"fix":"Migrate to eslint-plugin-handlebars or implement custom validation.","message":"Package is deprecated and no longer maintained. Last release 2016. Use ESLint plugin for Handlebars or manual validation.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Explicitly define all helpers and variables in the context object to avoid misclassification.","message":"The linter treats expressions without params/hash as variables if not found in helpers or variables. This may misclassify single-word helpers (e.g. {{foo}} where foo is actually a helper without arguments).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure Handlebars is installed and optionally pass `hbs: Handlebars` in options.","message":"Requires passing an optional `Handlebars` instance via `options.hbs`; if not provided, it uses the global `Handlebars` which may not be installed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `{ context: { helpers: {}, variables: {} } }` as shown in examples.","message":"The `options.context` property must be an object with `helpers` and `variables` (and optionally `partials` and `blockHelpers`). Providing a flat object will throw or produce incorrect results.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install handlebars (`npm install handlebars`) and pass `options.hbs: require('handlebars')`.","cause":"Handlebars is not installed or not passed correctly in options.","error":"TypeError: Handlebars.compile is not a function"},{"fix":"Provide a context object like `{ context: { helpers: {}, variables: {} } }`.","cause":"The `context` option is missing or not an object with `helpers` property.","error":"Cannot read property 'helpers' of undefined"},{"fix":"Add `foo` to `context.helpers` if it is a helper, or to `context.variables` if it is a variable.","cause":"A single word like `{{foo}}` is not found in helpers or variables; defaults to variable.","error":"The expression '{{foo}}' is ambiguous; assumed variable. If 'foo' is a helper, add it to the context.helpers."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}