0.5.0 • Published 4 years ago

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

Weekly downloads
47,580
License
MIT
Repository
github
Last release
4 years ago

eslint-plugin-no-use-extend-native

NPM version Build Status Coverage Status

Code Climate Dependencies DevDependencies

ESLint plugin to prevent use of extended native objects

Uses Sindre Sorhus's proto-props

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 .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.

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-1613eslint-config-7sne-eslinteslint-config-anvilabseslint-config-astureslint-config-backendeslint-config-bestreact-miha-prettier-eslints15e-javascriptreadable-code@darkristy/eslint-config@binur95/eslint-config@carv/eslint-config@cfware/lint@chalkygames123/eslint-config@sotream/eslint-config-nestjs@sotream/eslint-config-nextjs@sotream/eslint-config-react-js@sotream/eslint-config-react-ts@comocapital/eslint-config@anvilabs/eslint-config@anolilab/eslint-config@atomspace/eslintbroomy@al/eslint-config-alertlogic@alexlit/config-eslint@7sne/eslint@anireact/eslint-configeslint-config-silverwindeslint-config-simplesenseeslint-config-dustinspeckereslint-config-steeleslint-config-strict-modeeslint-config-tailseslint-config-vaveeslint-config-lifioneslint-config-lifion-webeslint-config-lovataeslint-config-readableeslint-config-reform-collectiveeslint-config-tunnckocoreeslint-config-xaxaeslint-config-x2eslint-config-yaruseslint-config-haloeslint-config-hardcoreeslint-config-evil-vueeslint-config-mailonlineeslint-config-pixiebrixeslint-config-nirtamir2eslint-config-noamkadosh@fernando457829/eslint-config-javascript@dwmt/eslint-config@ecohead/configs@epaypool/eslint-config-base@luludev/eslint-config@pvtnbr/eslint-config@pvtnbr/eslint-config-base@rweich/eslint-config@relaycorp/eslint-config@movilitascloud/eslint-config@shinnn/eslint-config@silverhand/eslint-config@papb/linter@phi.school/eslint-config@react-hookz/eslint-config@qiuqfang/get-port@nodertc/eslint-config@leonzalion/configs@mblabs/eslint-config@max-norin/ts-project-init@megabytelabs/eslint-config@lolpants/eslint-config@logto/eslint-config@scagood/eslint-config@theurgi/eslint-config@voltiso/config.eslint@voltiso/eslint-config@voltiso/eslint-config-fast@vutung/eslint-config@washi/eslint-config@washingtondc/eslint@tunnckocore/eslint-configxoxo-browser-focused-fork@hukakhepak/eslint-configlionconfig
0.5.0

4 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.12

7 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

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 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