MJBZA
MJBZA

Reputation: 5018

Why WebIde shows error for alert and console.log?

I am using WebIde of SAPUI5 development.

If I write a console.log or alert it shows error of unexpected Alert and so on inside of the editor.

While the code works and I prefer to not see these errors inside of the editor.

How can I customize WebIde to not show these kind of errors.

Upvotes: 2

Views: 8285

Answers (1)

Qualiture
Qualiture

Reputation: 4920

While it is discouraged to use console.log and alert statements in your code because

[...] such messages are considered to be for debugging purposes and therefore not suitable to ship to the client [...]

http://eslint.org/docs/rules/no-console

and

[...] JavaScripts’ alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation [...]

http://eslint.org/docs/rules/no-alert

you can have your Linter configured to bypass these checks (although I would not recommend to do so)

But keep in mind these checks are not specific to SAPUI5 or Web IDE, rather for every Javascript project!

Anyway, since Web IDE uses ESLint, to disable the check, add the following on top of the affected Javascript file:

/*eslint-disable no-console, no-alert */

Upvotes: 9

Related Questions