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

v2.1.1

Published

Eslint rules for Backbone.

Downloads

5,928

Readme

NPM version build status

eslint-plugin-backbone

Backbone specific linting rules for ESLint

How to use

Install ESLint either locally or globally


npm install eslint@">=1.0.0"

or

npm install eslint@">=1.0.0" --save-dev

eslint-plugin-backbone requires ESLint with version greater then 1.0.0 if you would like to use your own base models.

Install Backbone plugins.

If you installed ESLint globally, you have to install Backbone plugin globally too. Otherwise, install it locally.


npm install eslint-plugin-backbone

or

npm install eslint-plugin-backbone --save-dev

Default configuration

Deprecated in v2

note: ESLint v2 removed support for default configurations. Please see config below for details.

If you are using ESLint >0.9.0 then this plugin will provide default configuration. If you are fine with defaults, you do not need to update your .eslintrc file.

Defaults are currently set to the following:

    "collection-model": 2,
    "defaults-on-top": 1,
    "event-scope": 1,
    "events-on-top": [1, ["tagName", "className"]],
    "initialize-on-top": [1, { View: ["tagName", "className", "events"], Model: ["defaults", "url", "urlRoot"], Collection: ["model", "url"] }],
    "model-defaults": 2,
    "no-changed-set": 2,
    "no-collection-models": 2,
    "no-constructor": 1,
    "no-el-assign": 2,
    "no-model-attributes": 2,
    "no-native-jquery": [1, "selector"],
    "no-silent": 1,
    "no-view-collection-models": 2,
    "no-view-model-attributes": 2,
    "no-view-onoff-binding": 2,
    "no-view-qualified-jquery": 0,
    "render-return": 2

Configuration

In version 2.0.0 removed support for default configurations for plugins and replaced it with ability for plugins to bundle configs. This plugin include recommended configuration that you can extend from to enable recommended setup of the rules (see "Default configuration" for the list of enabled rules).

To enable bundled config modify your .eslintrc file to include the following line:

{
    "extends": "plugin:backbone/recommended"
}

This will enable all of the rules listed above, as well as add two global variables - Backbone and _.

Modify .eslintrc for your project

Add plugins section and specify eslint-plugin-backbone as a plugin


{
    "plugins": [
        "backbone"
    ]
}

Enable all of the rules that you would like to use


{
    "rules": {
        "backbone/collection-model": 1,
        "backbone/defaults-on-top": 1,
        "backbone/model-defaults": 1,
        "backbone/no-constructor": 1,
        "backbone/no-native-jquery": 1,
        ...
    }
}

If you are using custom models/view/collection bases you also have to specify each on in the settings section


{
    "settings": {
        "backbone": {
            "Collection": ["Backbone.NestedCollection", "MyCollection"],
            "Model": ["MyBaseModel"],
            "View": ["MyBaseView"]
        }
    }
}

List of supported rules