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.
Linter
✓ import Linter from 'ember-template-lint'
✗ const Linter = require('ember-template-lint')
Default export; ESM import preferred. CommonJS require is still supported for backward compatibility.
Linter
✓ const { Linter } = require('ember-template-lint')
✗ const Linter = require('ember-template-lint').Linter
CommonJS destructured import works; direct property access also works but less idiomatic.
getConfig
✓ import { getConfig } from 'ember-template-lint'
Utility to load and merge config files.
FIXABLE_RULES
✓ import { FIXABLE_RULES } from 'ember-template-lint'
List of rule names that support auto-fix.
Setup config file, run CLI, use programmatic API to lint and fix a template.
// Create .template-lintrc.js
'use strict';
module.exports = {
extends: 'recommended',
rules: {
'no-bare-strings': true,
},
};
// Run lint via CLI
// npx ember-template-lint .
// Or use programmatic API
import Linter from 'ember-template-lint';
const linter = new Linter();
const results = await linter.verify({
source: '<div>A bare string</div>',
filePath: 'app/templates/application.hbs',
config: {
rules: {
'no-bare-strings': true,
},
},
});
console.log(results);
// [
// {
// rule: 'no-bare-strings',
// severity: 2,
// filePath: 'app/templates/application.hbs',
// message: 'Non-translated string used',
// line: 1,
// column: 5
// }
// ]
// Auto-fix
import { verifyAndFix } from 'ember-template-lint';
const fixed = await verifyAndFix({
source: '<div>A bare string</div>',
filePath: 'app/templates/application.hbs',
config: {
rules: {
'no-bare-strings': 'fix',
},
},
});
ember-template-lint --version
Errors
Common errors & fixes
Cannot find module 'ember-template-lint'
Package not installed or path resolution issue.
fixRun `npm install --save-dev ember-template-lint` or check your node_modules.
Rule 'no-bare-strings' is not configured.
Rule not enabled in .template-lintrc.js or used outside a project.
fixAdd `'no-bare-strings': true` to rules in config file.
Error: EMFILE: too many open files
Max file descriptors reached when linting many files.
fixIncrease file descriptor limit (e.g., `ulimit -n 4096`) or lint fewer files at once.
The `config` option must be an object, not a string
Passing deprecated string path to Linter constructor.
fixLoad config with `require` or use `getConfig` and pass the object.
Audit
Dependencies
@ember-template-lint/todo-utilsrequiredManages todo comments for lint results
chalkrequiredUsed for colored terminal output
ember-template-recastrequiredParses and transforms handlebars templates