Giter VIP home page Giter VIP logo

sails-hook-eslint's Introduction

sails-hook-eslint

npm version Dependency Status

Needs at least Sails version 0.11.0 to work

Sails JS hook to activate ESLint for your whole sails app.

Installation

npm install sails-hook-eslint

Usage

Make sure you have a .eslintrc in your root folder. Then just lift your app as normal, and enjoy the power of linting. For an example of an .eslintrc file see: https://github.com/artificialio/sane/blob/master/.eslintrc

Configuration

By default, configuration lives in sails.config.eslint. The configuration key (eslint) can be changed by setting sails.config.hooks['sails-hook-eslint'].configKey.

Parameter Type Details
check ((boolean)) Whether or not sails should lint your JS code. Defaults to true.
formatter ((string)) Which formatter to use. Defaults to 'stylish'.
patterns ((array)) Which folders or glob patterns to lint. Defaults to [path.resolve(sails.config.appPath, 'api'), path.resolve(sails.config.appPath, 'config')].

That’s it!

sails-hook-eslint's People

Contributors

globegitter avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

austinmao gvlekke

sails-hook-eslint's Issues

Failing to use extended rules

Hi there,

To keep it short, if I specify rules in the .eslintrc file then everything works fine.
But if I want to extend, for example airbnb rules, then they are not taken into account, a different config file is being used (I believe some eslint.json file in a config folder of your package dependencies).

For example,
airbnb rules specify the use of single quotes but I get errors because I'm not using double quotes...

Older dependencies are being installed

Older version of your dependency eslint i.e 0.18.0 is being installed even on updating sails-hook-eslint. Release a newer version of sails-hook-eslint with the updated dependencies in package.json . Dont just change the dependency version numbers in package.json.

Fails with babel as the parser

ReferenceError: couldn't resolve escope/referencer
    at monkeypatch (/home/cmdln/src/git/lobby/node_modules/babel-eslint/index.js:73:11)
    at Object.exports.parse (/home/cmdln/src/git/lobby/node_modules/babel-eslint/index.js:374:5)
    at parse (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/eslint.js:462:27)
    at EventEmitter.module.exports.api.verify (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/eslint.js:614:15)
    at processFile (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/cli-engine.js:193:27)
    at /home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/cli-engine.js:293:26
    at /home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:61:17
    at Array.forEach (native)
    at traverse (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:41:54)
    at /home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:63:17
    at Array.forEach (native)
    at traverse (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:41:54)
    at walk (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:83:9)
    at /home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:102:9
    at Array.forEach (native)
    at traverse (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/util/traverse.js:101:11)
    at CLIEngine.executeOnFiles (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/node_modules/eslint/lib/cli-engine.js:284:9)
    at runLint (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/index.js:9:20)
    at /home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/index.js:76:13
    at Array.forEach (native)
    at Hook.initialize (/home/cmdln/src/git/lobby/node_modules/sails-hook-eslint/index.js:70:18)
    at Hook.bound [as initialize] (/home/cmdln/src/git/lobby/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)

Here is my .eslintrc.

{
    "rules": {
        "indent": [
          2,
          "tab"
        ],
        "quotes": [
            2,
            "single"
        ],
        "linebreak-style": [
            2,
            "unix"
        ],
        "semi": [
            2,
            "always"
        ],
        "no-console": 0
    },
    "globals": {
        "sails": false,
        "Model1": false,
        "Model1Service": false,
        "SomeService": false,
        "AnotherService": false
    },
    "parser": "babel-eslint",
    "env": {
        "es6": true,
        "node": true,
        "browser": true,
        "mocha": true
    },
    "extends": "eslint:recommended",
    "ecmaFeatures": {
        "jsx": true,
        "experimentalObjectRestSpread": true,
        "modules": true
    },
    "plugins": [
        "react"
    ]
}

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.