[英]ESLint flagging functions as 'not defined' where they are loaded in the html
I'm working on a project where the environment (Moodle) doesn't support ES6 Harmony Modules correctly in all the recent browsers (looking at you Safari.).我正在开发一个项目,其中环境(Moodle)在所有最近的浏览器中都不能正确支持 ES6 Harmony 模块(看看你 Safari。)。 I have defined a lot of helper functions in a
common.js
file and the rest of the code in the router.js
file, both of which are loaded using <script>
elements in the html.我在
common.js
文件中定义了很多辅助函数,在router.js
文件中定义了代码的 rest,这两者都是使用 html 中的<script>
元素加载的。 As a result if I define a function called say loadData()
in the common.js
file and use it in the router.js
file I get the linter error 'loadData' is defined but never used
in the first file and 'loadData' is not defined.
结果,如果我在
common.js
文件中定义一个名为 say loadData()
的 function 并在router.js
文件中使用它,我会得到 linter 错误'loadData' is defined but never used
在第一个文件中使用, 'loadData' is not defined.
in the latter!在后者!
Whilst I could disable some of the ESLint rules they can be valuable in spotting issues.虽然我可以禁用一些 ESLint 规则,但它们对于发现问题很有价值。 Is there a way to modifying my
.eslintrc.json
file so that ESLint is aware of these functions?有没有办法修改我的
.eslintrc.json
文件,以便 ESLint 知道这些功能?
Maybe just define them as global in eslintrc.也许只是在 eslintrc 中将它们定义为全局。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.