Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jscs

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscs

JavaScript Style Checker

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-jscs Build Status

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: require_multiple_var_decl
        Requires multiple var declaration.

        Valid example:

        var x = 1,
            y = 2;

        Invalid example:

        var x = 1;
        var y = 2;
    */
    "require_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('.') !== -1;

        Invalid example:

        x = !!y;
        x = +y;
        x = '' + y;
        x = ~s.indexOf('.');
    */
    "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
    },

    /*
        Option: exclude_files
        Disables style checking for specified paths.
    */
    "exclude_files": ["node_modules/**"]
}

FAQs

Package last updated on 18 Jun 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc