<commit_before>"use strict";

const CLIEngine = require("eslint").CLIEngine;
const Promise = require("bluebird");
const fs = require("fs");
const path = require("path");
const filePathMatcher = require("../../lib/file-path-matcher");


/**
 *
 * @param {string} file
 * @param {string} srcDir
 * @param {JsTaskConfig} config
 */
module.exports = function (file, srcDir, config)
{
    if (filePathMatcher(file, config.ignoreLintFor))
    {
        return;
    }

    let esLintConfig = {
        configFile: __dirname + "/../../../.eslintrc.yml",
        ignore: false,
        ecmaFeatures: {}
    };

    // set specific options for different file extensions
    switch (path.extname(file))
    {
        case ".jsx":
            esLintConfig.ecmaFeatures.jsx = true;
            break;

        case ".js":
            // continue with linting
            break;

        default:
            // abort linting, as any other file extension is given
            return;
    }

    let engine = new CLIEngine(esLintConfig);
    let formatter = engine.getFormatter();
    let report = engine.executeOnFiles([file]);

    if (report.results)
    {
        // make all paths relative
        report.results = report.results.map(
            (entry) =>
            {
                entry.filePath = path.relative(srcDir, entry.filePath);
                return entry;
            }
        );

        console.log(formatter(report.results));
    }
};<commit_msg>Fix empty lines in JS output<commit_after>"use strict";

const CLIEngine = require("eslint").CLIEngine;
const Promise = require("bluebird");
const fs = require("fs");
const path = require("path");
const filePathMatcher = require("../../lib/file-path-matcher");


/**
 *
 * @param {string} file
 * @param {string} srcDir
 * @param {JsTaskConfig} config
 */
module.exports = function (file, srcDir, config)
{
    if (filePathMatcher(file, config.ignoreLintFor))
    {
        return;
    }

    let esLintConfig = {
        configFile: __dirname + "/../../../.eslintrc.yml",
        ignore: false,
        ecmaFeatures: {}
    };

    // set specific options for different file extensions
    switch (path.extname(file))
    {
        case ".jsx":
            esLintConfig.ecmaFeatures.jsx = true;
            break;

        case ".js":
            // continue with linting
            break;

        default:
            // abort linting, as any other file extension is given
            return;
    }

    let engine = new CLIEngine(esLintConfig);
    let formatter = engine.getFormatter();
    let report = engine.executeOnFiles([file]);

    if (report.errorCount || report.warningCount)
    {
        // make all paths relative
        report.results = report.results.map(
            (entry) =>
            {
                entry.filePath = path.relative(srcDir, entry.filePath);
                return entry;
            }
        );

        console.log(formatter(report.results));
    }
};
{'fraction_non_alphanumeric': 0.12952316537030775, 'fraction_numerical': 0.0, 'mean_word_length': 1.9908998988877655, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6677569', 'n_tokens_mistral': 858, 'n_tokens_neox': 827, 'n_words': 204}