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 */
Related
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 */
I'm working on an application using WebStorm and occasionally I've seen warnings of the "unresolved variable" variety. These I have fixed, thanks to the StackOverflow community, by using JSDoc, either the #param or #namespace labels.
However I have just ONE more "unresolved function or method" to fix. In my app.js file I have the following line:
const app = express().use(bodyParser.json());
WebStorm flags up the .use function as an "unresolved function or method". I've tried resolving this by using JSDoc as follows:
/**
* #namespace express()
* #namespace express().use()
* */
I put this above the const app = express().use(bodyParser.json()); line, but it doesn't make a difference.
Is there another way to get rid of this warning?
the problem is that the express methods list is generated dynamically, and it's not possible to resolve these properties using static code analysis. Running npm i #types/express should solve the problem
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)...
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 */
I am making a node.js package found here
Development is going well, all except one thing. All of my code is in one file, index.ts.
I googled with no luck on how to separate the classes into different files and then be able to put them all together as a package in the end, while keeping the typescript types and all.
There are many ways to do it, but then they break IntelliSense (the items do not show up). Due to the whole reason I am using typescript is to have IntelliSense, and somewhat inline documentation, that is not a viable option.
Any help would be appreciated.
SOLUTION:
./Help/HelpModule.ts
export enum HelpMode {
/**
* Disable the automatic help command.
*/
Disabled,
/**
* Use the automatic help command and respond in the channel the command is used.
*/
Public,
/**
* Use the automatic help command and respond in a private message.
*/
Private
}
./index.ts
export * from './Help/HelpMode';
To split out your code into multiple files you must first move your functions into a new file, export them, then import them into your new file.
For example
//index.ts
function fooA() { .. }
function fooB() { .. }
If we want to split foo B into its own file. We do:
//index.ts
import { fooB } from "./fooB";
function fooA() { .. }
And the other file would be
//fooB.ts
export function fooB() { .. }