{"size": 1313, "ext": "js", "max_stars_repo_path": "web/libariries/bootstrap/node_modules/jscs/lib/rules/require-multi-line-ternary.js", "max_stars_repo_name": "Moccine/Symfony-Projet-1", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "web/libariries/bootstrap/node_modules/jscs/lib/rules/require-multi-line-ternary.js", "max_issues_repo_name": "Moccine/Symfony-Projet-1", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/libariries/bootstrap/node_modules/jscs/lib/rules/require-multi-line-ternary.js", "max_forks_repo_name": "Moccine/Symfony-Projet-1", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.1774193548, "max_line_length": 104, "alphanum_fraction": 0.4965727342}
/**
 * Requires the test, consequent and alternate to be on separate lines when using the ternary operator.
 *
 * Types: `Boolean`
 *
 * #### Example
 *
 * ```js
 * "requireMultiLineTernary": true
 * ```
 *
 * ##### Valid
 *
 * ```js
 * var foo = (a === b)
 *   ? 1
 *   : 2;
 * ```
 *
 * ##### Invalid
 *
 * ```js
 * var foo = (a === b) ? 1 : 2;
 * ```
 */

var assert = require('assert');

module.exports = function() {};

module.exports.prototype = {
    configure: function(options) {
        assert(
            options === true,
            this.getOptionName() + ' option requires a true value or should be removed'
        );
    },

    getOptionName: function() {
        return 'requireMultiLineTernary';
    },

    check: function(file, errors) {
        file.iterateNodesByType('ConditionalExpression', function(node) {

            errors.assert.differentLine({
                token: node.test,
                nextToken: node.consequent,
                message: 'Missing new line after test'
            });

            errors.assert.differentLine({
                token: node.consequent,
                nextToken: node.alternate,
                message: 'Missing new line after consequent'
            });

        });
    }

};
