![Meet Socket at BlackHat and DEF CON in Las Vegas](https://cdn.sanity.io/images/cgdhsj6q/production/4a3876139ffd3878bb3e7800a14cf4044245dca7-1080x834.jpg?w=400&fit=max&auto=format)
Security News
Meet Socket at BlackHat and DEF CON in Las Vegas
Come meet the Socket team at BlackHat and DEF CON! We're sponsoring some fun networking events and we would love to see you there.
ember-template-lint
Advanced tools
Package description
ember-template-lint is a linting tool for Ember.js templates. It helps developers maintain consistent coding styles, catch potential errors, and enforce best practices in Handlebars templates.
Linting Templates
This feature allows you to lint your Handlebars templates to ensure they follow specific rules. For example, the 'no-bare-strings' rule prevents the use of bare strings in templates, encouraging the use of translation helpers instead.
module.exports = { 'no-bare-strings': true };
Custom Rules
You can define custom linting rules to enforce specific coding standards within your project. In this example, the 'no-inline-styles' rule is set to 'error' severity, which will flag any inline styles in templates as errors.
module.exports = { rules: { 'no-inline-styles': { severity: 'error' } } };
Configuration File
You can extend from predefined configurations to quickly set up linting rules. The 'recommended' configuration includes a set of rules that are generally considered best practices for Ember.js templates.
module.exports = { extends: 'recommended' };
ESLint is a widely-used linting tool for JavaScript. It helps developers find and fix problems in their JavaScript code. While ESLint focuses on JavaScript, ember-template-lint is specifically designed for Handlebars templates in Ember.js.
Stylelint is a linter for CSS and other stylesheets. It helps enforce consistent conventions and avoid errors in stylesheets. Like ember-template-lint, it is highly configurable, but it focuses on styles rather than Handlebars templates.
ember-cli-template-lint is an older package that integrates template linting into the Ember CLI build process. It has been largely superseded by ember-template-lint, which offers more features and better integration.
Changelog
Readme
ember-template-lint
is a library that will lint your handlebars template and return error results.
For example, if the rule no-bare-strings
is enabled, this template would be
in violation:
{{! app/components/my-thing/template.hbs }}
<div>A bare string</div>
When the ember-template-lint
executable is run, we would have a single result indicating that
the no-bare-strings
rule found an error.
^12.22.0 || ^14.17.0 || >=16.0.0
npm install --save-dev ember-template-lint
yarn add --dev ember-template-lint
Note: this library is installed by default with new Ember apps.
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 .
See documentation on workflow examples.
See documentation on the todo functionality.
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. |
π | 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). |
β¨οΈ | a11y | Enables A11Y rules. Its goal is to include all A11Y related rules, therefore it does not follow the same SemVer policy as the other presets. Please see versioning for more details. |
Each rule has emojis denoting:
--fix
command line option--fix
optionYou 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.
FAQs
Linter for Ember or Handlebars templates.
The npm package ember-template-lint receives a total of 124,493 weekly downloads. As such, ember-template-lint popularity was classified as popular.
We found that ember-template-lint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Come meet the Socket team at BlackHat and DEF CON! We're sponsoring some fun networking events and we would love to see you there.
Security News
Learn how Socket's 'Non-Existent Author' alert helps safeguard your dependencies by identifying npm packages published by deleted accounts. This is one of the fastest ways to determine if a package may be abandoned.
Security News
In July, the Python Software Foundation mounted a quick response to address a leaked GitHub token, elected new board members, and added more members to the team supporting PSF and PyPI infrastructure.