return new Promise((resolve, reject) => { standard.lintText(ignoredBlock, standardOptions, (err, results) => { if (err) return reject(err) results.originalLine = block.line results.originalText = block return resolve(results) }) })
return new Promise(function(resolve, reject){ linter.lintText(content, {}, function(err, result){ if(err){ console.error("failed to analyse"); console.log({ error: err }); reject(err); } const formattedResults = result.results.map(format); resolve(formattedResults[0]); //we passed single file contents, so all errors are per-file }); });
function fix (req, res, next) { if (!req.body || !req.body.text) { return next(new restifyErrors.BadRequestError('text field is required.')) } standard.lintText(req.body.text, {fix: true}, (err, result) => { if (err) return next(err) res.send(result) next() }) }
function processFile (file, enc, cb) { if (file.isNull()) { return cb(null, file) } if (file.isStream()) { return cb(new gutil.PluginError(PLUGIN_NAME, 'Streams are not supported!')) } standard.lintText(String(file.contents), opts, function (err, data) { if (err) { return cb(err) } file.standard = data cb(null, file) }) }
fs.readFile(filePath, {encoding: 'utf8'}, function (err, data) { t.error(err, 'read ' + basename + ' file without error ') var formatted try { formatted = fmt(data) } catch (e) { t.error(e, 'format ' + basename + ' without error') } standard.lintText(formatted, function (err, result) { t.error(err, 'linting ' + basename + ' should be error free') t.equal(result.errorCount, 0, basename + ' error free after formatting') t.equal(result.warningCount, 0, basename + ' warning free after formatting') if (result.errorCount || result.warningCount !== 0) { // If there is an issue, print the details console.log(inspect(result, {depth: depth || null})) } t.end() }) })
handler: function (request, reply) { standard.lintText(request.payload.value, function (err, data) { if (err) { return reply(Boom.badRequest('An error occurred standardizing the code', err)) } var annotations = [] if (data.errorCount) { var messages = data.results[0].messages messages.forEach(function (message) { annotations.push( { row: message.line - 1, // must be 0 based column: message.column - 1, // must be 0 based text: message.message, // text to show in tooltip type: 'error' } ) }) } return reply(annotations) }) }
async.map(blocks, function (block, callback) { return standard.lintText(block, callback) }, function (err, results) {