gpt4 book ai didi

javascript - ESLint 导入/模块被视为未定义

转载 作者:行者123 更新时间:2023-11-29 23:53:04 25 4
gpt4 key购买 nike

我将 Webpack 与 Polymer 一起使用,导入一个组件,如下所示:

import '@polymer/polymer/polymer-element.html';

class AppShell extends Polymer.Element {
static get is() { return 'app-shell'; }
}

我在这里省略了其余的组件。导入在我的应用程序中按预期工作,但是当我运行 ESLint 时,我收到以下错误消息:

50:27  error  'Polymer' is not defined  no-undef

这是我的 package.json,我在其中定义我的 ESLint 设置。任何人都知道为什么 ESLint 没有正确获取导入?

{
"name": "client-meeting-tracker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"start": "node utils/webserver.js",
"lint": "eslint --ext .html,.js */**",
"build": "node utils/build.js"
},
"dependencies": {
"@startup-boilerplate/inkling": "*",
"auth0-lock": "^10.7.3",
"lodash": "^4.6.1",
"moment": "^2.17.1"
},
"devDependencies": {
"cross-env": "^1.0.6",
"css-loader": "^0.23.1",
"eslint": "^3.16.0",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-import": "^2.2.0",
"file-loader": "^0.8.4",
"fs-extra": "^0.30.0",
"polymer-cli": "^0.17.0",
"wc-loader": "*",
"webpack": "2.2.0",
"webpack-dev-server": "2.2.0"
},
"eslintConfig": {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": [
"eslint:recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
},
"plugins": [
"html"
]
}
}

最佳答案

Polymer 被定义为全局的,所以我会 configure Polymer as a global在你的 package.json 中:

"eslintConfig": {
"globals": {
"Polymer": true
}
}

关于javascript - ESLint 导入/模块被视为未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42366154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com