<commit_before>import * as json from 'comment-json';
import {
    RegExpPatternDefinition,
    Glob,
    Source,
    LanguageSetting,
    Pattern,
    CSpellSettingsWithSourceTrace,
    ImportFileRef,
    GlobDef,
} from '@cspell/cspell-types';
import * as path from 'path';
import { normalizePathForDictDefs } from './DictionarySettings';
import * as util from '../util/util';
import { resolveFile } from '../util/resolveFile';
import { getRawGlobalSettings } from './GlobalSettings';
import { cosmiconfig, cosmiconfigSync, OptionsSync as CosmicOptionsSync, Options as CosmicOptions } from 'cosmiconfig';
import { GlobMatcher } from 'cspell-glob';
import { ImportError } from './ImportError';

const configSettingsFileVersion0_1 = '0.1';
const configSettingsFileVersion0_2 = '0.2';
const currentSettingsFileVersion = configSettingsFileVersion0_2;

export const sectionCSpell = 'cSpell';

export const defaultFileName = 'cspell.json';

export const ENV_CSPELL_GLOB_ROOT = 'CSPELL_GLOB_ROOT';

/**
 * Logic of the locations:
 * - Support backward compatibility with the VS Code Spell Checker
 *   the spell checker extension can only write to `.json` files because
 *   it would be too difficult to automatically modify a `.js` or `.cjs` file.
 * - To support `cspell.config.js` in a VS Code environment, have a `cspell.json` import
 *   the `cspell.config.js`.
 */
const searchPlaces = [
    // Original locations
    '.cspell.json',
    'cspell.json',
    '.cSpell.json',
    'cSpell.json',
    // Original locations jsonc
    '.cspell.jsonc',
    'cspell.jsonc',
    // Alternate locations
    '.vscode/cspell.json',
    '.vscode/cSpell.json',
    '.vscode/.cspell.json',
    // Standard Locations
    'cspell.config.json',
    'cspell.config.jsonc',
    'cspell.config.yaml',
    'cspell.config.yml',
    'cspell.yaml',
    'cspell.yml',
    // Dynamic config is looked for last
    'cspell.config.js',<commit_msg>feat: Support `package.json` as a configuration location. (#1178)<commit_after>import * as json from 'comment-json';
import {
    RegExpPatternDefinition,
    Glob,
    Source,
    LanguageSetting,
    Pattern,
    CSpellSettingsWithSourceTrace,
    ImportFileRef,
    GlobDef,
} from '@cspell/cspell-types';
import * as path from 'path';
import { normalizePathForDictDefs } from './DictionarySettings';
import * as util from '../util/util';
import { resolveFile } from '../util/resolveFile';
import { getRawGlobalSettings } from './GlobalSettings';
import { cosmiconfig, cosmiconfigSync, OptionsSync as CosmicOptionsSync, Options as CosmicOptions } from 'cosmiconfig';
import { GlobMatcher } from 'cspell-glob';
import { ImportError } from './ImportError';

const configSettingsFileVersion0_1 = '0.1';
const configSettingsFileVersion0_2 = '0.2';
const currentSettingsFileVersion = configSettingsFileVersion0_2;

export const sectionCSpell = 'cSpell';

export const defaultFileName = 'cspell.json';

export const ENV_CSPELL_GLOB_ROOT = 'CSPELL_GLOB_ROOT';

/**
 * Logic of the locations:
 * - Support backward compatibility with the VS Code Spell Checker
 *   the spell checker extension can only write to `.json` files because
 *   it would be too difficult to automatically modify a `.js` or `.cjs` file.
 * - To support `cspell.config.js` in a VS Code environment, have a `cspell.json` import
 *   the `cspell.config.js`.
 */
const searchPlaces = [
    'package.json',
    // Original locations
    '.cspell.json',
    'cspell.json',
    '.cSpell.json',
    'cSpell.json',
    // Original locations jsonc
    '.cspell.jsonc',
    'cspell.jsonc',
    // Alternate locations
    '.vscode/cspell.json',
    '.vscode/cSpell.json',
    '.vscode/.cspell.json',
    // Standard Locations
    'cspell.config.json',
    'cspell.config.jsonc',
    'cspell.config.yaml',
    'cspell.config.yml',
    'cspell.yaml',
    'cspell.yml',
    // Dynamic config is looked for last
    'cspell.config.js',
{'fraction_non_alphanumeric': 0.12237583205325141, 'fraction_numerical': 0.006144393241167435, 'mean_word_length': 3.662291169451074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5322077', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1262, 'n_words': 331}