eslint-plugin-no-use-extend-native
ESLint plugin to prevent use of extended native objects
Last updated 3 months ago by dustinspecker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install eslint-plugin-no-use-extend-native 
SYNC missed versions from official npm registry.

eslint-plugin-no-use-extend-native

NPM version Coverage Status

ESLint plugin to prevent use of extended native objects

Install

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

Usage

In your eslint.config.js file add the plugin as such:

import eslintPluginNoUseExtendNative from 'eslint-plugin-no-use-extend-native'

export default [
  {
    plugins: {
      'no-use-extend-native': eslintPluginNoUseExtendNative,
    },
    rules: {
      'no-use-extend-native/no-use-extend-native': 2,
    },
  },
]

If you want the default of the single rule being enabled as an error, you can also just use the following instead of all of the above:

import eslintPluginNoUseExtendNative from 'eslint-plugin-no-use-extend-native'

export default [
  eslintPluginNoUseExtendNative.configs.recommended,
]

With this plugin enabled, ESLint will find issues with using extended native objects:

import colors from '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.

Usage with no-extend-native

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.

LICENSE

MIT © Dustin Specker

Current Tags

  • 0.7.2                                ...           latest (3 months ago)

31 Versions

  • 0.7.2                                ...           3 months ago
  • 0.7.1                                ...           4 months ago
  • 0.7.0                                ...           5 months ago
  • 0.6.1                                ...           6 months ago
  • 0.6.0                                ...           6 months ago
  • 0.5.0                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.12                                ...           8 years ago
  • 0.3.11                                ...           8 years ago
  • 0.3.10                                ...           8 years ago
  • 0.3.9                                ...           8 years ago
  • 0.3.8                                ...           8 years ago
  • 0.3.7                                ...           9 years ago
  • 0.3.6                                ...           9 years ago
  • 0.3.5                                ...           9 years ago
  • 0.3.4                                ...           9 years ago
  • 0.3.3                                ...           9 years ago
  • 0.3.2                                ...           9 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.8                                ...           9 years ago
  • 0.1.7                                ...           9 years ago
  • 0.1.6                                ...           9 years ago
  • 0.1.5                                ...           9 years ago
  • 0.1.4                                ...           9 years ago
  • 0.1.3                                ...           9 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE