当前位置: 首页 > 软件库 > 程序开发 > >

ember-template-lint

Linter for Ember or Handlebars templates
授权协议 MIT License
开发语言 JavaScript
所属分类 程序开发
软件类型 开源软件
地区 不详
投 递 者 昝成弘
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

ember-template-lint

Build Status

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 bein 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 thatthe no-bare-strings rule found an error.

Requirements

  • Node.js >= 10.24 < 11 || 12.* || >= 14.*

Installation

npm install --save-dev ember-template-lint
yarn add --dev ember-template-lint

Note: this library is installed by default with new Ember apps.

Usage

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 .

Workflow Examples

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" --verbose

Multiple 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" --json

Ignore warnings / only report errors

ember-template-lint "app/templates/application.hbs" --quiet

Convert errors to TODOs in order to resolve at a later date

ember-template-lint . --update-todo

Number of warnings to trigger nonzero exit code

ember-template-lint "app/templates/application.hbs" --max-warnings=2

Include TODOs with other output results

ember-template-lint . --include-todo

Define custom config path

ember-template-lint "app/templates/application.hbs" --config-path .my-template-lintrc.js

Read from stdin

ember-template-lint --filename app/templates/application.hbs < app/templates/application.hbs

Specify 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-pattern

Running 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-config

Specify 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

Specify a configuration to override the normally loaded config file:

ember-template-lint . --config='{"extends": "a11y"}'

Provide a custom formatter from a relative path

ember-template-lint --format ./my-shwanky-formatter.js

Provide a custom formatter from a formatter package

ember-template-lint --format ember-template-lint-formatter-snazzy

�� 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).

For more information about the todo functionality, see the documentation.

Configuration

Project Wide

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 relativepath which may be identified using the CLI:

module.exports = {
  extends: 'recommended',

  rules: {
    'no-bare-strings': true,
  },
};

For more detailed information see configuration.

Presets

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.

Rules

Each rule has emojis denoting:

  • what configuration it belongs to
  • �� if some problems reported by the rule are automatically fixable by the --fix command line option
Name �� ⌨️ ��
attribute-indentation
block-indentation ��
builtin-component-arguments
deprecated-each-syntax
deprecated-inline-view-helper
deprecated-render-helper
eol-last �� ��
inline-link-to ��
linebreak-style ��
link-href-attributes ⌨️
link-rel-noopener ��
modifier-name-case ��
no-abstract-roles ⌨️
no-accesskey-attribute ⌨️ ��
no-action
no-action-modifiers
no-args-paths
no-arguments-for-html-elements
no-aria-hidden-body ⌨️ ��
no-attrs-in-components
no-bare-strings
no-block-params-for-html-elements
no-capital-arguments
no-class-bindings
no-curly-component-invocation ��
no-debugger
no-down-event-binding ⌨️
no-duplicate-attributes ⌨️
no-duplicate-id ⌨️
no-duplicate-landmark-elements ⌨️
no-dynamic-subexpression-invocations
no-element-event-actions
no-empty-headings ⌨️
no-extra-mut-helper-argument
no-forbidden-elements
no-heading-inside-button ⌨️
no-html-comments
no-implicit-this
no-index-component-invocation
no-inline-styles
no-input-block
no-input-tagname
no-invalid-block-param-definition
no-invalid-interactive ⌨️
no-invalid-link-text ⌨️
no-invalid-link-title ⌨️
no-invalid-meta ⌨️
no-invalid-role ⌨️
no-link-to-positional-params
no-link-to-tagname
no-log
no-model-argument-in-route-templates ��
no-multiple-empty-lines ��
no-mut-helper
no-negated-condition ��
no-nested-interactive ⌨️
no-nested-landmark ⌨️
no-nested-splattributes
no-obsolete-elements ⌨️
no-outlet-outside-routes
no-partial
no-passed-in-event-handlers
no-positional-data-test-selectors ��
no-positive-tabindex ⌨️
no-potential-path-strings
no-quoteless-attributes
no-redundant-fn ��
no-redundant-landmark-role ⌨️ ��
no-restricted-invocations
no-route-action
no-shadowed-elements
no-this-in-template-only-components ��
no-trailing-spaces ��
no-triple-curlies
no-unbalanced-curlies
no-unbound
no-unknown-arguments-for-builtin-components ��
no-unnecessary-component-helper
no-unnecessary-concat ��
no-unused-block-params
no-valueless-arguments
no-whitespace-for-layout �� ⌨️
no-whitespace-within-word �� ⌨️
no-with
no-yield-only
no-yield-to-default
quotes ��
require-button-type ��
require-context-role ⌨️
require-each-key
require-form-method
require-has-block-helper ��
require-iframe-title ⌨️
require-input-label ⌨️
require-lang-attribute ⌨️
require-presentational-children ⌨️
require-splattributes
require-valid-alt-text ⌨️
require-valid-named-block-naming-format
self-closing-void-elements ��
simple-unless
splat-attributes-only
style-concatenation
table-groups ⌨️
template-length

Supporting the --fix option

You can add a fixer to a rule. See fixer documentation for more details.

Sharing configs

It is possible to share a config (extends) or plugin (custom rules) across projects. See ember-template-lint-plugin-peopleconnect for an example.

Defining your own rules

You can define and use your own custom rules using the plugin system. See plugin documentation for more details.

Semantic Versioning Policy

The semver policy for this addon can be read here: semver policy.

Contributing

See the Contributing Guidelines for information on how to help out.

License

This project is licensed under the MIT License.

 相关资料
  • Template初探 到目前为止我们只是简单的将后端数据显示到页面上, 没有涉及到HTML代码, 而优雅的网站总算通过CSS+HTML, 甚至还有强大的JS的支持. 在这个教程中要打造一个Blog, 所以我们设置一个Blog界面, 原本打算使用Bootstrap作为前段的工具, 不过经过@游逸的建议, 使用了更加轻量级的[Pure][1], 同样是响应式页面设置, 这也将是未来的主流吧.. 在my

  • 描述 (Description) 在呈现视图时,模板会创建可重复使用的标记副本,并提供对实例数据的访问。 语法 (Syntax) view.template(data) 参数 (Parameters) data - 渲染视图时要访问的数据。 例子 (Example) <!DOCTYPE html> <html> <head> <title>View Example</title

  • 模板模式使用抽象操作在基类中定义基本算法,其中子类覆盖具体行为。 模板模式将算法的轮廓保持在单独的方法中。 此方法称为模板方法。 以下是模板模式的不同功能 - 它定义了操作中算法的骨架 它包括子类,它重新定义了算法的某些步骤。 class MakeMeal: def prepare(self): pass def cook(self): pass def eat(self): p

  • import "text/template" template包实现了数据驱动的用于生成文本输出的模板。 如果要生成HTML格式的输出,参见html/template包,该包提供了和本包相同的接口,但会自动将输出转化为安全的HTML格式输出,可以抵抗一些网络攻击。 通过将模板应用于一个数据结构(即该数据结构作为模板的参数)来执行,来获得输出。模板中的注释引用数据接口的元素(一般如结构体的字段或者字

  • import "html/template" template包(html/template)实现了数据驱动的模板,用于生成可对抗代码注入的安全HTML输出。本包提供了和text/template包相同的接口,无论何时当输出是HTML的时候都应使用本包。 此处的文档关注本包的安全特性。至于如何使用模板,请参照text/template包。 Introduction &para 本包是对text/t

  • Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查