简体   繁体   English

导出未使用的功能以便整理

[英]Export unused function for linting

I have the following code in a Javascript file: 我在Javascript文件中有以下代码:

/* exported something */

function something() {}

The something function is not used in the file because it is called from a Html form submission. 在文件中未使用something函数,因为它是从HTML表单提交中调用的。

When the linter runs, es-lint in my case, I receive a no-unused-vars message. 当短绒es-lint运行时,在我的情况下为es-lint ,我收到一条no-unused-vars消息。

I expected that exported comment would fix this, but this is not the case. 我希望exported评论可以解决此问题,但事实并非如此。

Am I doing something wrong? 难道我做错了什么? Am I missing something? 我想念什么吗?

Try eliminating the space between the pragma and code: 尝试消除编译指示和代码之间的空格:

/* exported something */
function something() {}

If this doesn't work, then you can always edit your eslint config so that the vars property only looks at functions in local scope: 如果这不起作用,那么您始终可以编辑eslint配置,以便vars属性仅查看本地范围内的函数:

{
    "rules": {
        "no-unused-vars": [2, {"vars": "local", "args": "after-used"}]
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM