'Missing semicolon' warning in Eclipse for JavaScript code

好久不见. 提交于 2019-12-21 04:21:20

问题


Eclipse gives me the warning 'Missing semicolon' for line 4 of the following code:

const C = 'b';
function foo() {
    alert('x');
}

It does not for the following code:

//const C = 'b';
function foo() {
    alert('x');
}

For the following it gives me two warnings:

const C = 'b';
function foo() {
    alert('x');
};

Multiple markers at this line

  • Unnecessary semicolon
  • Missing semicolon

Is there a way to make Eclipse ignore my lines with 'const'? Or is there another way to solve my problem?

I am using:

Eclipse IDE for JavaScript Web Developers.
Version: Indigo Service Release 1
Build id: 20110916-0149


回答1:


There is only a proposed const in JavaScript. Use

var C = 'b';

Actually, there is a const apparently, but it is not supported by all browsers and would not be good to use for that reason.

The reason Eclipse is giving you the warning is that it does not recognize const which is a known bug in Eclipse.

You can read how to ignore the errors in Use of JavaScript const gives "missing semicolon" in associative....




回答2:


You may disable some warnings in the preference menu:



来源:https://stackoverflow.com/questions/9513035/missing-semicolon-warning-in-eclipse-for-javascript-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!