Giter Site home page Giter Site logo

kingjay66 / eslint-plugin-no-use-extend-native Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dustinspecker/eslint-plugin-no-use-extend-native

0.0 1.0 0.0 85 KB

ESLint plugin to prevent use of extended native objects

License: MIT License

JavaScript 100.00%

eslint-plugin-no-use-extend-native's Introduction

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-plugin-no-use-extend-native's People

Contributors

dustinspecker avatar brettz9 avatar greenkeeperio-bot avatar brandon93s avatar sindresorhus avatar niedzielski avatar greenkeeper[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.