npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-benderthecrime

v2.3.0

Published

shareable eslint plugin

Downloads

17

Readme

eslint-plugin-benderthecrime 🚀

Shareable ESLint plugin

Installation

You'll first need to install ESLint:

npm i -D eslint

You will also need the the babel-eslint package, which this package uses as its parser, as well as the eslint-plugin-react module:

npm i --save-dev babel-eslint eslint-plugin-react

Next, install eslint-plugin-benderthecrime:

npm install eslint-plugin-benderthecrime --save-dev

NOTE: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-benderthecrime globally.

Usage

Add eslint-plugin-benderthecrime to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "benderthecrime"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "benderthecrime/no-for-of": 2
    }
}

Additionally, this plugin comes with a recommended configuration, which can be inherited from in your .eslintrc:

{
    "extends": [
        "plugin:benderthecrime/recommended"
    ],
    "plugins": [
        "benderthecrime"
    ]
}

Finally, this plugin comes with an "all" configuration, which will enable all custom rules found in this plugin:

{
    "extends": [
        "plugin:benderthecrime/all"
    ],
    "plugins": [
        "benderthecrime"
    ]
}

Supported Rules

None of the rules that are available with this plugin have additional options where they are not specified.

  • cache-for-loop-length:

    Requires that the second clause of the for loop condition reference a variable as opposed to directly referencing the length of a collection:

    // BAD
    for (let i = 0; i < arr.length; ++i) {}
    
    // GOOD
    const len = arr.length;
    
    for (let i = 0; i < len; ++i) {}
  • exports-always-on-top:

    Requires that only imports and definitions come before export statements. This also implies that imports must be defined at the top of the module.

  • import-occurrence-order:

    Requires that imports are listed in the order in which they are used. This rule takes an optional second argument which has a property "ignoreImportGroups" which will ignore ordering of import groups separated by a newline:

    {
        "rules": {
            "benderthecrime/import-occurrence-order": [
                2,
                {
                    "ignoreImportGroups": false
                }
            ]
        }
    }
  • limit-object-expression-prop-count:

    Limits the number of properties allowed in an object literal definition.

    The v8 engine explicitly puts any object with more than 26 properties into slow mode. This is an attempt to hedge the risk of objects being treated as dictionaries in v8. For more information, see the v8 engine unit tests.

    {
        "rules": {
            "benderthecrime/limit-object-expression-prop-count": [ 2, 15 ]
        }
    }
  • max-function-body-length:

    Allows the user to define a max length in characters no function can exceed. This rule takes a second argument which indicates the max length which no function can exceed. The default is 300:

    {
        "rules": {
            "benderthecrime/max-function-body-length": [ 2, 300 ]
        }
    }
  • no-arrow-callback:

    DEPRECATED: Use a combination of the "max-nested-callbacks" and "no-unnecessary-arrow-function" rules

    Disallows arrow functions as callbacks:

    // BAD
    [1, 2, 3].map(n => n ** 2);
    
    // GOOD
    [1, 2, 3].map(square);
    
    function square(n) {
        return n ** 2;
    }
  • no-break:

    DEPRECATED: Use "no-restricted-syntax"

    Disallows break statements.

  • no-comment:

    Disallows comments. This rule takes an optional second parameter as an object allowing a comment pattern to ignore:

    {
        "rules": {
            "benderthecrime/no-comment": [
                2,
                {
                    "ignorePattern": "eslint-disable|@flow"
                }
            ]
        }
    }
  • no-for-each:

    DEPRECATED: Use "no-restricted-properties"

    Disallows forEach:

    // BAD
    [1, 2, 3].forEach(console.log);
    
    // GOOD
    for (let i = 0; i < [1, 2, 3].length; ++i) {
        console.log(i);
    }

    NOTE: Currently, this rule prevents the use of ANY forEach method

  • no-for-in:

    DEPRECATED: Use "no-restricted-syntax"

    Disallows "for...in".

  • no-for-of:

    DEPRECATED: Use "no-restricted-syntax"

    Disallows "for...of".

  • no-generator-functions:

    Disallows generator functions.

    Generator functions are not currently optimizable by the v8 engine because they potentially have indeterminate end conditions. It may not be a wise decision to use generator functions until they become optimizable.

  • no-require:

    Disallows the use of require to import modules. Instead this rule predicates the use of ES6 style imports.

  • no-switch-statement:

    DEPRECATED: Use "no-restricted-syntax"

    Disallows switch statements.

  • no-unnecessary-arrow-function:

    Disallows the use of arrow functions without the use of "this" in the function body.

  • no-while-loop:

    DEPRECATED: Use "no-restricted-syntax"

    Disallows all flavors of while loops.

  • require-jsdoc-on-export:

    Requires JSDoc docstrings only on exports. This rule allows an additional configuration option specifying on which code constructs JSDocs should be required:

    {
        "rules": {
            "benderthecrime/require-jsdoc-on-export": [
                2,
                {
                  "ClassDeclaration": false,
                  "FunctionDeclaration": true,
                  "MethodDefinition": false
                }
            ]
        }
    }

Changes

For an up to date list of changes, please see the CHANGELOG.md