Socket
Socket
Sign inDemoInstall

jscs

Package Overview
Dependencies
195
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jscs

JavaScript Style Checker


Version published
Weekly downloads
65K
decreased by-1.42%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

Version 0.0.2:

  • Link to parent nodes.

Readme

Source

node-jscs

JSCS — JavaScript Code Style.

jscs is a code style checker. jscs can check cases, which are not implemeted in jshint, but it does not duplicate jshint functionality, so you should use jscs and jshint together.

Installation

jscs can be installed using npm:

npm install jscs

To run jscs, you can use the following command from the project root:

./node_modules/.bin/jscs path[ path[...]]

Configuration

jscs is configured using .jscs.json file, located in the project root.

Example configuration:

{
    /*
        Option: require_curly_braces
        Requires curly braces after statements.

        Valid example:

        if (x) {
            x++;
        }

        Invalid example:

        if (x) x++;
    */
    "require_curly_braces": ["if", "else", "for", "while", "do"],

    /*
        Option: require_space_after_keywords
        Requires space after keyword.

        Valid example:

        return true;

        Invalid example:

        if(x) {
            x++;
        }
    */
    "require_space_after_keywords": ["if", "else", "for", "while", "do", "switch", "return"],

    /*
        Option: disallow_space_after_keywords
        Disallows space after keyword.

        Valid example:

        if(x > y) {
            y++;
        }
    */
    "disallow_space_after_keywords": ["if", "else", "for", "while", "do", "switch"],

    /*
        Option: disallow_multiple_var_decl
        Disallows multiple var declaration.

        Valid example:

        var x = 1;
        var y = 2;

        Invalid example:

        var x = 1,
            y = 2;
    */
    "disallow_multiple_var_decl": true,

    /*
        Option: disallow_left_sticked_operators
        Disallows sticking operators to the left.

        Valid example:

        x = y ? 1 : 2;

        Invalid example:

        x = y? 1 : 2;
    */
    "disallow_left_sticked_operators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],

    /*
        Option: require_right_sticked_operators
        Requires sticking operators to the left.

        Valid example:

        x = !y;

        Invalid example:

        x = ! y;
    */
    "require_right_sticked_operators": ["!"],

    /*
        Option: disallow_right_sticked_operators
        Disallows sticking operators to the right.

        Valid example:

        x = y + 1;

        Invalid example:

        x = y +1;
    */
    "disallow_right_sticked_operators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],

    /*
        Option: disallow_right_sticked_operators
        Requires sticking operators to the right.

        Valid example:

        x = [1, 2];

        Invalid example:

        x = [1,2];
    */
    "require_left_sticked_operators": [","],

    /*
        Option: disallow_implicit_type_conversion
        Disallows implicit type conversion.

        Valid example:

        x = Boolean(y);
        x = Number(y);
        x = String(y);
        x = ~s.indexOf('.');

        Invalid example:

        x = !!y;
        x = +y;
        x = '' + y;
        x = s.indexOf('.') !== -1;
    */
    "disallow_implicit_type_conversion": ["numeric", "boolean", "binary", "string"],

    /*
        Option: disallow_keywords
        Disallows usage of specified keywords.

        Invalid example:

        with (x) {
            prop++;
        }
    */
    "disallow_keywords": ["with"],

    /*
        Option: disallow_muliple_line_breaks
        Disallows multiple blank lines in a row.

        Invalid example:

        var x = 1;


        x++;
    */
    "disallow_muliple_line_breaks": true,

    /*
        Option: disallow_keywords_on_new_line
        Disallows placing keywords on a new line.

        Valid example:

        if (x < 0) {
            x++;
        } else {
            x--;
        }

        Invalid example:

        if (x < 0) {
            x++;
        }
        else {
            x--;
        }
    */
    "disallow_keywords_on_new_line": ["else"],

    /*
        Option: require_keywords_on_new_line
        Requires placing keywords on a new line.

        Valid example:

        if (x < 0) {
            x++;
        }
        else {
            x--;
        }

        Invalid example:

        if (x < 0) {
            x++;
        } else {
            x--;
        }
    */
    "require_keywords_on_new_line": ["else"],

    /*
        Option: require_line_feed_at_file_end
        Requires placing line feed at file end.
    */
    "require_line_feed_at_file_end": true,

    /*
        Option: validate_jsdoc
        Enables jsdoc validation.

        Option: validate_jsdoc.check_param_names
        Ensures param names in jsdoc and in function declaration are equal.

        Option: validate_jsdoc.require_param_types
        Ensures params in jsdoc contains type.

        Option: validate_jsdoc.check_redundant_params
        Reports redundant params in jsdoc.
    */
    "validate_jsdoc": {
        "check_param_names": true,
        "check_redundant_params": true,
        "require_param_types": true
    }
}

FAQs

Last updated on 17 Jun 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc