How to use the jshint/src/cli.getConfig function in jshint

To help you get started, we’ve selected a few jshint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / atom-fixmyjs / index.js View on Github external
function init(editor) {
	const file = editor.getURI();
	const config = file ? jshintCli.getConfig(file) : {};
	const selectedText = editor.getSelectedText();
	const text = selectedText || editor.getText();
	let retText = '';

	try {
		if (atom.config.get('fixmyjs.legacy')) {
			const jshint = require('jshint').JSHINT;
			jshint(text, config);
			retText = fixmyjs(jshint.data(), text).run();
		} else {
			retText = fixmyjs.fix(text, config);
		}
	} catch (err) {
		console.error(err);
		atom.notifications.addError('FixMyJS', {detail: err.message});
		return;