Polymer 1.0:如何为 Polymer 行为配置 jshint?
Polymer 1.0 : How to configure jshint for Polymer behaviours?
我有一个全球化-behaviour.html 文件:
<script>
GlobalizeBehavior = {
// https://www.polymer-project.org/1.0/docs/devguide/behaviors.html#definining-behaviors
i18n: function(key) {
return key;
}
};
</script>
我将此文件包含在其他自定义元素中,如下所示:
<link rel="import" href="../globalize-behavior/globalize-behavior.html">
并像这样使用它(在全局-element.html):
<script>
(function() {
Polymer({
is: 'global-element',
behaviors: [GlobalizeBehavior],
openAddTransDialog: function() {},
});
})();
</script>
而且,这是 .jshintrc 文件:
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"globals": {
"wrap": true,
"unwrap": true,
"Polymer": true,
"Platform": true,
"page": true,
"app": true
}
}
我在 运行 jshint:
时遇到以下错误
globalize-behavior.html line 2 col 1 'GlobalizeBehavior' is not defined.
global-element.html line 104 col 17 'GlobalizeBehavior' is not defined.
我该如何解决这个问题?
您可以添加
"globals": {
"GlobalizeBehavior": true
}
或:
"predef": [
"GlobalizeBehavior"
]
到您的 .jshintrc
文件?
我有一个全球化-behaviour.html 文件:
<script>
GlobalizeBehavior = {
// https://www.polymer-project.org/1.0/docs/devguide/behaviors.html#definining-behaviors
i18n: function(key) {
return key;
}
};
</script>
我将此文件包含在其他自定义元素中,如下所示:
<link rel="import" href="../globalize-behavior/globalize-behavior.html">
并像这样使用它(在全局-element.html):
<script>
(function() {
Polymer({
is: 'global-element',
behaviors: [GlobalizeBehavior],
openAddTransDialog: function() {},
});
})();
</script>
而且,这是 .jshintrc 文件:
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"globals": {
"wrap": true,
"unwrap": true,
"Polymer": true,
"Platform": true,
"page": true,
"app": true
}
}
我在 运行 jshint:
时遇到以下错误globalize-behavior.html line 2 col 1 'GlobalizeBehavior' is not defined.
global-element.html line 104 col 17 'GlobalizeBehavior' is not defined.
我该如何解决这个问题?
您可以添加
"globals": {
"GlobalizeBehavior": true
}
或:
"predef": [
"GlobalizeBehavior"
]
到您的 .jshintrc
文件?