ESLINT error messages - eslint

I am trying to use extern libraries on my SAPUI5 project and follow tutorials https://blogs.sap.com/2017/04/30/how-to-include-third-party-libraries-modules-in-sapui5/.
For example, I include lodash as you can see on the image:
On the image, you can see, that the sap web ide complains about third library.
How to avoid the complaint?

Just add /* eslint-disable */ at the top of your target file:
/* eslint-disable */
/**
* ...
*/
;(function(){function n(n)...

Related

EsLint: Hide undefined functions Warnings

How can i hide all un-used Functions warnings in Javascript (using EsLint)? If i use following command, it will only hide warnings of the defined functions.
/* global lg, storeKeys, mergeDeep, count, preg_match */
Is there a way to hide all functions warnings without hiding the un-defined Variables? Like:
/* eslint-disable no-undef-functions */

Where can I store JSDoc typedef information to share across projects?

I'm adding #typedef JSDoc comments to the top of Javascript files to help define types (really, so that I can take advantage of some of the typescript benefits without learning it all today).
Where can I store JSDoc typedef information to share across projects in VSCode?
For example, can I store this in some external file and then use it in multiple .js files?
/**
* #typedef {Object} SomeType
* #property {String} id
*/
2021 Update
Edit tsconfig.json so that includes is relative to the root of your project and includes your type files as well. For example:
{
"compilerOptions": {
// ...
},
"include": ["./my-types.js", "src/**/*.js"],
}
If you're not nesting any of your projects under a folder like src/, then this would work on its own:
{
"compilerOptions": {
// ...
},
"include": ["**/*.js"],
}
Original Answer
You can put that code snippet in a .js file and then either add it to the files or include in each tsconfig.json file or use a reference directive:
///<reference path="path/to/shared-file.js" />
(These are the same two options you have for TypeScript declaration files.) It gets a little more complicated if your shared file is an ES6 module (with top-level ES6 imports or exports); then you'll need to either import it or use import types.

Allow debugger; statements in certain files, using ESLint

Say I want to use this rule:
https://eslint.org/docs/rules/no-debugger
however, I have about 15 files where I want to keep debugger; statements.
Is there something I can add at the top of the .ts/.js files, that can tell ESLint to ignore the no-debugger rule for this particular file?
You can also disable ESLint in the same line:
debugger; // eslint-disable-line no-debugger
You can do that like this:
/* eslint-disable no-debugger */
... code that violates rule ...
/* eslint-enable no-debugger */
Update your eslint configuration file (.eslintrc etc) with such rule:
"rules": {
"no-debugger":"off"
}
Probably your IDE can help. If you are using VS Code, you can mouse over debugger, click Quick Fix..., and select Disable no-debugger for the entire file, as shown as below:
Then the IDE will add the following comment at the top of the file to disable the rule for you:
/* eslint-disable no-debugger */
See more on the eslint no-debugger rule.
OR, add:
"no-debugger": false
to the bottom of tslint.json, to disable this warning for all files.
I think debugger need to removed, and briefly used in a development environment.
So you're better off ignoring it where you use.
For example:
disable no-debugger for this line
// eslint-disable-next-line no-debugger
debugger
or disable no-debugger for the entire file
/* eslint-disable no-debugger */

ESLint / VSCode, the whole object is underlined

Since the last VSCode or Eslint extension update, the whole object is underlined when an error or a warning is detected. An idea why ?
I’m guessing you’re exporting this function from Webpack configuration module. I can think of two options that come to play.
First, define named function:
module.exports = function withBaseConfiguration() {
return { /* configuration goes here */ }
}
Second, disable the ESLint rule for this file by placing following at the top:
/* eslint-disable func-names */

jsdoc not generating table of contents properly

I'm running grunt jsdoc module and the output html is missing the filenames in the table of contents.
See image:
Notice the js repeated in right hand column under modules
Top of file (AMD):
/** #module identity.js
*
* abstracts the logic for obtaining a user's identity
* #module identity.js
* #type {Core}
*/

Resources