Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
eslint-plugin-no-function-declare-after-return
Advanced tools
An ESLint plugin to prevent function declaration after return statement
An ESLint plugin to prevent function declaration after return statement
# Using npm
npm i -S no-function-declare-after-return
# Using yarn
yarn add no-function-declare-after-return
In .eslintrc
{
"plugins": [
"no-function-declare-after-return"
],
"rules": {
"no-function-declare-after-return/no-function-declare-after-return": 2
}
}
Let's consider a code example:
function publicMethods(obj){
if(obj instanceof customClass)
return {
set: methodSetter(obj),
get: methodGetter(obj),
}
function methodSetter(obj){
.
.
.
}
function methodGetter(obj){
.
.
.
}
}
The function compiles succesfully even though the functions are used before declaration. This is due to the fact that -
Function declarations in JavaScript are hoisted to the top of the enclosing function or global scope. (More Info)
But considering from a readability standpoint, it is quite difficult to figure out where the function is defined and also difficult for new comers to keep in mind the concept of hoisting.
This plugin will enforce that there are no function declarations are the return statement.
Note : This plugin is separate, and in no way replaces no-unreachable-code
of ESLint.
if (repo.isAwesome || repo.isHelpful) {
StarRepo();
}
FAQs
An ESLint plugin to prevent function declaration after return statement
We found that eslint-plugin-no-function-declare-after-return demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.