All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.tasks.no_es6_dist.js Maven / Gradle / Ivy

The newest version!
var eslint = require('eslint');
var constants = require('./util/constants');
var EXIT_CODE = 0;

var partialBundlePaths = constants.partialBundleNames.map(constants.makePartialBundleOpts);

assertES5();

// Ensure no ES6 has snuck through into the build:
function assertES5() {
    var ESLint = eslint.ESLint;

    var cli = new ESLint({
        allowInlineConfig: false,
        useEslintrc: false,
        ignore: false,
        overrideConfig: {
            parserOptions: {
                ecmaVersion: 5
            }
        }
    });

    var files = partialBundlePaths.map(function(f) { return f.dist; });
    files.unshift(constants.pathToPlotlyDist);

    var report = cli.lintFiles(files);
    var formatter = cli.loadFormatter();

    var errors = [];
    if(report.errorCount > 0) {
        console.log(formatter(report.results));

        // It doesn't work well to pass formatted logs into this,
        // so instead pass the empty string in a way that causes
        // the test to fail
        errors.push('');
    }

    log('es5-only syntax', errors);
}


function log(name, logs) {
    if(logs.length) {
        console.error('test-syntax error [' + name + ']');
        console.error(logs.join('\n'));
        EXIT_CODE = 1;
    } else {
        console.log('ok ' + name);
    }
}

process.on('exit', function() {
    if(EXIT_CODE) {
        throw new Error('test syntax failed.');
    }
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy