<commit_before>/** @babel */
import esformatter from 'esformatter';

const SUPPORTED_SCOPES = [
	'source.js',
	'source.jsx',
	'source.js.jsx'
];

function init(editor, onSave) {
	if (!editor) {
		return;
	}

	const selectedText = onSave ? null : editor.getSelectedText();
	const text = selectedText || editor.getText();
	let retText = '';

	try {
		retText = esformatter.format(text, esformatter.rc(editor.getURI()));
	} catch (err) {
		console.error(err);
		atom.beep();
		return;
	}

	const editorEl = atom.views.getView(editor);
	const cursorPosition = editor.getCursorBufferPosition();
	const line = editorEl.getFirstVisibleScreenRow() + editor.displayBuffer.getVerticalScrollMargin();
<commit_msg>add in-app error message - fixes #31<commit_after>/** @babel */
import esformatter from 'esformatter';

const SUPPORTED_SCOPES = [
	'source.js',
	'source.jsx',
	'source.js.jsx'
];

function init(editor, onSave) {
	if (!editor) {
		return;
	}

	const selectedText = onSave ? null : editor.getSelectedText();
	const text = selectedText || editor.getText();
	let retText = '';

	try {
		retText = esformatter.format(text, esformatter.rc(editor.getURI()));
	} catch (err) {
		console.error(err);
		atom.notifications.addError('esformatter', {detail: err.message});
		return;
	}

	const editorEl = atom.views.getView(editor);
	const cursorPosition = editor.getCursorBufferPosition();
	const line = editorEl.getFirstVisibleScreenRow() + editor.displayBuffer.getVerticalScrollMargin();

{'fraction_non_alphanumeric': 0.14787305874409182, 'fraction_numerical': 0.0013504388926401081, 'mean_word_length': 4.951807228915663, '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': '4948245', 'n_tokens_mistral': 518, 'n_tokens_neox': 486, 'n_words': 101}