Skip to content

Instantly share code, notes, and snippets.

@mkamakura
Last active June 7, 2016 02:52
Show Gist options
  • Save mkamakura/b3c57d62c70d0e0eec67525ef43bcc15 to your computer and use it in GitHub Desktop.
Save mkamakura/b3c57d62c70d0e0eec67525ef43bcc15 to your computer and use it in GitHub Desktop.
alfred-eslint-workflow(script only)
#!/usr/bin/env node
# script filter(shell)
# {enter your node path} alfred-eslint-workflow.js "{query}"
#
# nodejs >= 5.0.0
#
# require npm packages install command
# npm i superagent
# npm i alfred-item
const request = require('superagent');
const AlfredItem = require('alfred-item');
const item = new AlfredItem();
request
.post('http://xwxg7mebsb-dsn.algolia.net/1/indexes/*/queries?x-algolia-api-key=653e00f423bee91f9863571eed16f2f5&x-algolia-application-id=XWXG7MEBSB&x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%203.8.1')
.send({"requests":[{"indexName":"eslint","params":`query=${process.argv[2]}&hitsPerPage=5`}]})
.end((err, res) => {
res.body.results[0].hits.filter(hit => hit.category === 'Rules').forEach((hit, i) => item.addItem(i, hit.title, hit.category, null, {arg: `http://eslint.org${hit.url}`}));
console.log(item.output());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment