<commit_before>'use strict';

const _ = require('lodash');
const path = require('path');

const packageJson = require('../package');

function extendConfig(config) {
	config = _.cloneDeep(config);

	if (config.extends) {
		if (!Array.isArray(config.extends)) {
			config.extends = [config.extends];
		}

		const extendedConfigs = config.extends.map((fileName) => {
			// check if not absolute path
			if (path.resolve(fileName) !== path.normalize(fileName)) {
				const eslintPrefix = 'eslint-config-';
				if (!fileName.startsWith(eslintPrefix)) {
					fileName = eslintPrefix + fileName;
				}

				if (fileName.startsWith(packageJson.name)) {
					fileName = fileName.replace(packageJson.name, '..');
				}
			}

			const configToExtend = require(fileName);
			return extendConfig(configToExtend);
		});

		delete config.extends;

		for (const extendedConfig of extendedConfigs.reverse()) {
			for (const sectionName of Object.keys(extendedConfig)) {
				if (_.isPlainObject(extendedConfig[sectionName])) {
					if (config[sectionName] === undefined) {
						config[sectionName] = {};
					}

					for (const ruleName of Object.keys(extendedConfig[sectionName])) {
						if (config[sectionName][ruleName] === undefined) {
							config[sectionName][ruleName] = extendedConfig[sectionName][ruleName];
						}
					}
				} else if (Array.isArray(config[sectionName])) {
					config[sectionName] = config[sectionName].concat(extendedConfig[sectionName]);
				} else if (config[sectionName] === undefined) {
					config[sectionName] = extendedConfig[sectionName];
				}
			}
		}
	}

	return config;
}

module.exports = extendConfig;<commit_msg>Use snake case for variable name<commit_after>'use strict';

const _ = require('lodash');
const path = require('path');

const package_json = require('../package');

function extendConfig(config) {
	config = _.cloneDeep(config);

	if (config.extends) {
		if (!Array.isArray(config.extends)) {
			config.extends = [config.extends];
		}

		const extended_configs = config.extends.map((file_name) => {
			// check if not absolute path
			if (path.resolve(file_name) !== path.normalize(file_name)) {
				const eslint_prefix = 'eslint-config-';
				if (!file_name.startsWith(eslint_prefix)) {
					file_name = eslint_prefix + file_name;
				}

				if (file_name.startsWith(package_json.name)) {
					file_name = file_name.replace(package_json.name, '..');
				}
			}

			const config_to_extend = require(file_name);
			return extendConfig(config_to_extend);
		});

		delete config.extends;

		for (const extended_config of extended_configs.reverse()) {
			for (const section_name of Object.keys(extended_config)) {
				if (_.isPlainObject(extended_config[section_name])) {
					if (config[section_name] === undefined) {
						config[section_name] = {};
					}

					for (const rule_name of Object.keys(extended_config[section_name])) {
						if (config[section_name][rule_name] === undefined) {
							config[section_name][rule_name] = extended_config[section_name][rule_name];
						}
					}
				} else if (Array.isArray(config[section_name])) {
					config[section_name] = config[section_name].concat(extended_config[section_name]);
				} else if (config[section_name] === undefined) {
					config[section_name] = extended_config[section_name];
				}
			}
		}
	}

	return config;
}

module.exports = extendConfig;
{'fraction_non_alphanumeric': 0.14017297942141366, 'fraction_numerical': 0.0, 'mean_word_length': 4.005970149253732, 'pattern_counts': {'":': 0, '<': 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': '7618654', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1046, 'n_words': 186}