lib/config/config-initializer.js
function processAnswers(answers) {
    let config = {
        rules: {},
        env: {},
        parserOptions: {},
        extends: []
    };

    // set the latest ECMAScript version
    config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
    config.env.es6 = true;
    config.globals = {
        Atomics: "readonly",
        SharedArrayBuffer: "readonly"
    };

    // set the module type
    if (answers.moduleType === "esm") {
        config.parserOptions.sourceType = "module";
    } else if (answers.moduleType === "commonjs") {
        config.env.commonjs = true;
    }

    // add in browser and node environments if necessary
    answers.env.forEach(env => {
        config.env[env] = true;
    });

    // add in library information
    if (answers.framework === "react") {
        config.parserOptions.ecmaFeatures = {
            jsx: true
        };
        config.plugins = ["react"];
    } else if (answers.framework === "vue") {
        config.plugins = ["vue"];
        config.extends.push("plugin:vue/essential");
    }

    // setup rules based on problems/style enforcement preferences
    if (answers.purpose === "problems") {
        config.extends.unshift("eslint:recommended");
    } else if (answers.purpose === "style") {
        if (answers.source === "prompt") {
            config.extends.unshift("eslint:recommended");
            config.rules.indent = ["error", answers.indent];
            config.rules.quotes = ["error", answers.quotes];
            config.rules["linebreak-style"] = ["error", answers.linebreak];
            config.rules.semi = ["error", answers.semi ? "always" : "never"];
        } else if (answers.source === "auto") {
            config = configureRules(answers, config);
            config = autoconfig.extendFromRecommended(config);
        }
    }

    // normalize extends
    if (config.extends.length === 0) {
        delete config.extends;
    } else if (config.extends.length === 1) {
        config.extends = config.extends[0];
    }

    ConfigOps.normalizeToStrings(config);
    return config;
}
function processAnswers(answers) {
    let config = {
        rules: {},
        env: {},
        parserOptions: {},
        extends: []
    };

    // set the latest ECMAScript version
    config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
    config.env.es6 = true;
    config.globals = {
        Atomics: "readonly",
        SharedArrayBuffer: "readonly"
    };

    // set the module type
    if (answers.moduleType === "esm") {
        config.parserOptions.sourceType = "module";
    } else if (answers.moduleType === "commonjs") {
        config.env.commonjs = true;
    }

    // add in browser and node environments if necessary
    answers.env.forEach(env => {
        config.env[env] = true;
    });

    // add in library information
    if (answers.framework === "react") {
        config.parserOptions.ecmaFeatures = {
            jsx: true
        };
        config.plugins = ["react"];
    } else if (answers.framework === "vue") {
        config.plugins = ["vue"];
        config.extends.push("plugin:vue/essential");
    }

    // setup rules based on problems/style enforcement preferences
    if (answers.purpose === "problems") {
        config.extends.unshift("eslint:recommended");
    } else if (answers.purpose === "style") {
        if (answers.source === "prompt") {
            config.extends.unshift("eslint:recommended");
            config.rules.indent = ["error", answers.indent];
            config.rules.quotes = ["error", answers.quotes];
            config.rules["linebreak-style"] = ["error", answers.linebreak];
            config.rules.semi = ["error", answers.semi ? "always" : "never"];
        } else if (answers.source === "auto") {
            config = configureRules(answers, config);
            config = autoconfig.extendFromRecommended(config);
        }
    }

    // normalize extends
    if (config.extends.length === 0) {
        delete config.extends;
    } else if (config.extends.length === 1) {
        config.extends = config.extends[0];
    }

    ConfigOps.normalizeToStrings(config);
    return config;
}
function processAnswers ( answers ) { let config = { rules : { } , env : { } , parserOptions : { } , extends : [ ] } ; // set the latest ECMAScript version config . parserOptions . ecmaVersion = DEFAULT_ECMA_VERSION ; config . env . es6 = true ; config . globals = { Atomics : "readonly" , SharedArrayBuffer : "readonly" } ; // set the module type if ( answers . moduleType === "esm" ) { config . parserOptions . sourceType = "module" ; } else if ( answers . moduleType === "commonjs" ) { config . env . commonjs = true ; } // add in browser and node environments if necessary answers . env . forEach ( env => { config . env [ env ] = true ; } ) ; // add in library information if ( answers . framework === "react" ) { config . parserOptions . ecmaFeatures = { jsx : true } ; config . plugins = [ "react" ] ; } else if ( answers . framework === "vue" ) { config . plugins = [ "vue" ] ; config . extends . push ( "plugin:vue/essential" ) ; } // setup rules based on problems/style enforcement preferences if ( answers . purpose === "problems" ) { config . extends . unshift ( "eslint:recommended" ) ; } else if ( answers . purpose === "style" ) { if ( answers . source === "prompt" ) { config . extends . unshift ( "eslint:recommended" ) ; config . rules . indent = [ "error" , answers . indent ] ; config . rules . quotes = [ "error" , answers . quotes ] ; config . rules [ "linebreak-style" ] = [ "error" , answers . linebreak ] ; config . rules . semi = [ "error" , answers . semi ? "always" : "never" ] ; } else if ( answers . source === "auto" ) { config = configureRules ( answers , config ) ; config = autoconfig . extendFromRecommended ( config ) ; } } // normalize extends if ( config . extends . length === 0 ) { delete config . extends ; } else if ( config . extends . length === 1 ) { config . extends = config . extends [ 0 ] ; } ConfigOps . normalizeToStrings ( config ) ; return config ; }
process user's answers and create config object
@param {Object} answers answers received from inquirer
@returns {Object} config object
process user s answers and create config object