Giter Club home page Giter Club logo

eslint-plugin-backbone's Introduction

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

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,
    "render-return": 2

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

eslint-plugin-backbone's People

Contributors

ilyavolodin avatar pdehaan avatar platinumazure avatar

Watchers

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