0.7.2 • Published 10 months ago

eslint-plugin-no-use-extend-native v0.7.2

Weekly downloads
47,580
License
MIT
Repository
github
Last release
10 months ago

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

eslint-config-quartz@leonzalion/eslint-configeslint-config-quark@ajw998/eslint-config@infinitebrahmanuniverse/nolb-eslint-plugin-n@everything-registry/sub-chunk-1613web-ui-deps@comocapital/eslint-config@darkristy/eslint-config@anvilabs/eslint-config@anireact/eslint-config@anolilab/eslint-config@atomspace/eslint@al/eslint-config-alertlogic@binur95/eslint-config@carv/eslint-config@cfware/lint@chalkygames123/eslint-config@7sne/eslintxoxo-browser-focused-fork@fernando457829/eslint-config-javascript@hukakhepak/eslint-config@lolpants/eslint-config@logto/eslint-config@lesnoypudge/eslint-config@leonzalion/configs@luludev/eslint-config@movilitascloud/eslint-config@nirtamir2/eslint-config@nodertc/eslint-config@epaypool/eslint-config-base@max-norin/ts-project-init@mblabs/eslint-config@megabytelabs/eslint-config@dwmt/eslint-config@react-hookz/eslint-config@pvtnbr/eslint-config@pvtnbr/eslint-config-base@qiuqfang/get-port@rweich/eslint-config@scagood/eslint-config@phi.school/eslint-config@papb/linter@shinnn/eslint-config@sotream/eslint-config-nestjs@sotream/eslint-config-nextjs@sotream/eslint-config-react-js@sotream/eslint-config-react-ts@sonnymiel/eslint-config@silverhand/eslint-configreact-miha-prettier-eslintreadable-codes15e-javascriptlintrolllionconfig@washi/eslint-config@washingtondc/eslint@ver0/eslint-config@tunnckocore/eslint-config@theurgi/eslint-config@vutung/eslint-config@voltiso/config.eslint@voltiso/eslint-config@voltiso/eslint-config-fastbroomyeslint-config-lifioneslint-config-lifion-webeslint-config-pixiebrixeslint-config-reform-collectiveeslint-config-readableeslint-config-vaveeslint-config-nirtamir2eslint-config-noamkadosheslint-config-xaxaeslint-config-x2eslint-config-yaruseslint-config-tunnckocoreeslint-config-unioneslint-config-strict-modeeslint-config-steeleslint-config-silverwindeslint-config-tailseslint-config-ash-nazgeslint-config-astureslint-config-eschadeslint-config-7sne-eslinteslint-config-backendeslint-config-besteslint-config-anvilabseslint-config-current-thingeslint-config-evil-vueeslint-config-dustinspeckereslint-config-mailonlineeslint-config-hardcoreeslint-config-haloeslint-config-lovata
0.7.2

10 months ago

0.7.1

11 months ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

5 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.12

9 years ago

0.3.11

9 years ago

0.3.10

9 years ago

0.3.9

9 years ago

0.3.8

9 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

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago