ember-template-lint will lint your handlebars template and return error results.
For example, given the rule no-bare-strings is enabled, this template would be
in violation:
When the ember-template-lint executable is run, we would have a single result indicating that
the no-bare-strings rule found an error.
This addon is installed by default with new Ember apps, so check your package.json before installing to see if you need to install it.
To install ember-template-lint
With npm:
npm install --save-dev ember-template-lintWith yarn:
yarn add ember-template-lint --devNode.js 10 || >=12 is required.
While ember-template-lint does have a Node API, the main way to use it is through its executable, which is intended to be installed locally within a project.
Basic usage is as straightforward as
ember-template-lint .Basic usage with a single file
ember-template-lint "app/templates/application.hbs"Output errors with source description
ember-template-lint "app/templates/application.hbs" --verboseMultiple file/directory/wildcard paths are accepted
ember-template-lint "app/templates/components/**/*" "app/templates/application.hbs"Output errors as pretty-printed JSON string
ember-template-lint "app/templates/application.hbs" --jsonIgnore warnings / only report errors
ember-template-lint "app/templates/application.hbs" --quietDefine custom config path
ember-template-lint "app/templates/application.hbs" --config-path .my-template-lintrc.jsRead from stdin
ember-template-lint --filename app/templates/application.hbs < app/templates/application.hbsPrint list of formatted rules for use with pending in config file
ember-template-lint "app/templates/application.hbs" --print-pendingSpecify custom ignore pattern ['**/dist/**', '**/tmp/**', '**/node_modules/**'] by default
ember-template-lint "/tmp/template.hbs" --ignore-pattern "**/foo/**" --ignore-pattern "**/bar/**"Disable ignore pattern entirely
ember-template-lint "/tmp/template.hbs" --no-ignore-patternRunning a single rule without options
ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:error'Running a single rule with options
ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:["error", { "allow": ["some-helper"] }]'Running a single rule, disabling inline configuration
ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:error' --no-inline-configSpecify a config object to use instead of what exists locally
ember-template-lint --config '{ "rules": { "no-implicit-this": { "severity": 2, "config": true } } }' test/fixtures/no-implicit-this-allow-with-regexp/app/templatesπ‘ Ensure you wrap all glob patterns in quotes so that it won't be interpreted by the CLI. ember-template-lint app/templates/** (this will expand all paths in app/templates) and ember-template-lint "app/templates/**" (this will pass the glob to ember-template-lint and not interpret the glob).
You can turn on specific rules by toggling them in a
.template-lintrc.js file at the base of your project, or at a custom relative
path which may be identified using the CLI:
module.exports = {
extends: 'recommended',
rules: {
'no-bare-strings': true,
},
};For more detailed information see configuration.
| Name | Description | |
|---|---|---|
| β | recommended | enables the recommended rules |
| π | octane | extends the recommended preset by enabling Ember Octane rules |
| π | stylistic | enables stylistic rules for those who aren't ready to adopt ember-template-lint-plugin-prettier (including stylistic rules that were previously in the recommended preset in ember-template-lint v1) |
Each rule has emojis denoting:
- what configuration it belongs to
- π§ if some problems reported by the rule are automatically fixable by the
--fixcommand line option
You can add a fixer to a rule. See fixer documentation for more details.
It is possible to share a config (extends) or plugin (custom rules) across projects. See ember-template-lint-plugin-peopleconnect for an example.
You can define and use your own custom rules using the plugin system. See plugin documentation for more details.
The semver policy for this addon can be read here: semver policy.
See the Contributing Guidelines for information on how to help out.
This project is licensed under the MIT License.