Polymer 聚合物1.0:如何为聚合物行为配置jshint?

Polymer 聚合物1.0:如何为聚合物行为配置jshint?,polymer,jshint,Polymer,Jshint,我有一个globalize-behavior.html文件: <script> GlobalizeBehavior = { // https://www.polymer-project.org/1.0/docs/devguide/behaviors.html#definining-behaviors i18n: function(key) { return key; } }; </script> 运行jshint时,我遇到以下错误: globa

我有一个globalize-behavior.html文件:

<script>
GlobalizeBehavior = {

  // https://www.polymer-project.org/1.0/docs/devguide/behaviors.html#definining-behaviors

  i18n: function(key) {
    return key;
  }

};
</script>
运行jshint时,我遇到以下错误:

globalize-behavior.html第2行第1列“GlobalizeBehavior”未定义

global-element.html第104行第17列“GlobalizeBehavior”未定义

如何修复此问题?

您可以添加

"globals": {
    "GlobalizeBehavior": true
}
或:


到您的
.jshintrc
文件?

修复了此答案中的输入错误
prefed
应该是
predef
<script>
  (function() {
    Polymer({
      is: 'global-element',
      behaviors: [GlobalizeBehavior],

      openAddTransDialog: function() {},

    });
  })();
</script>
{
  "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
  }
}
"globals": {
    "GlobalizeBehavior": true
}
"predef": [
    "GlobalizeBehavior"
]