Security News
Python Overtakes JavaScript as Top Programming Language on GitHub
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
eslint-plugin-no-use-extend-native
Advanced tools
ESLint plugin to prevent use of extended native objects
ESLint plugin to prevent use of extended native objects
Uses Sindre Sorhus's proto-props
First, install ESLint via
npm install --save-dev eslint
Then install eslint-plugin-no-use-extend-native
npm install --save-dev eslint-plugin-no-use-extend-native
In your .eslintrc
file add the plugin as such:
{
plugins: [
'no-use-extend-native'
]
}
To modify the single rule, no-use-extend-native
, add the rule to your .eslintrc.*
as such:
{
plugins: [
'no-use-extend-native'
],
rules: {
'no-use-extend-native/no-use-extend-native': 1
}
}
The default value is 2
.
If you want the default, you can also just use the following instead of all of the above:
{
extends: ['plugin:no-use-extend-native/recommended']
}
With this plugin enabled, ESLint will find issues with using extended native objects:
const colors = require('colors');
console.log('unicorn'.green);
// => ESLint will give an error stating 'Avoid using extended native objects'
[].customFunction();
// => ESLint will give an error stating 'Avoid using extended native objects'
More examples can be seen in the tests.
ESLint's no-extend-native
rule verifies code is not modifying a native prototype. e.g., with the no-extend-native
rule enabled, the following lines are each considered incorrect:
String.prototype.shortHash = function() { return this.substring(0, 7); };
Object.defineProperty(Array.prototype, "times", { value: 999 });
no-use-extend-native
verifies code is not using a non-native prototype. e.g., with the no-use-extend-native
plugin enabled, the following line is considered incorrect:
"50bda47b09923e045759db8e8dd01a0bacd97370".shortHash() === "50bda47";
The no-use-extend-native
plugin is designed to work with ESLint's no-extend-native
rule. no-extend-native
ensures that native prototypes aren't extended, and should a third party library extend them, no-use-extend-native
ensures those changes aren't depended upon.
MIT © Dustin Specker
FAQs
ESLint plugin to prevent use of extended native objects
We found that eslint-plugin-no-use-extend-native demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
Security News
Dutch National Police and FBI dismantle Redline and Meta infostealer malware-as-a-service operations in Operation Magnus, seizing servers and source code.
Research
Security News
Socket is tracking a new trend where malicious actors are now exploiting the popularity of LLM research to spread malware through seemingly useful open source packages.