Skip to content

Commit

Permalink
Merge pull request #360 from roggervalf/set-husky
Browse files Browse the repository at this point in the history
Adding husky, pretty-quick and lint-staged
  • Loading branch information
bradvogel authored Apr 8, 2021
2 parents 79a38b1 + cf9771b commit 3c5d0cb
Show file tree
Hide file tree
Showing 26 changed files with 3,102 additions and 4,188 deletions.
46 changes: 46 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
env: {
node: true,
es6: true,
browser: true,
commonjs: true,
jquery: true,
},
parserOptions: {
ecmaVersion: 2018,
},
plugins: ['prettier'],
extends: ['prettier'],
overrides: [
{
files: ['lib/**'],
rules: {
'max-len': 'error',
},
},
{
files: ['benchmark/**', 'examples/**'],
parserOptions: {
ecmaVersion: 8,
},
rules: {
'no-console': 'off',
},
},
{
files: ['test/**'],
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module',
},
rules: {
'handle-callback-err': 'warn',
'no-shadow': 'off',
'no-warning-comments': 'off',
},
},
],
rules: {
strict: 'off',
},
};
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pretty:quick
npm run lint:staged
3 changes: 3 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,md}": "node_modules/.bin/eslint . --ignore-path ./.prettierignore --fix"
}
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
"@mixmaxhq/prettier-config"
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": false,
"arrowParens": "always",
"endOfLine": "lf"
}
2 changes: 1 addition & 1 deletion example/bee.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function main() {
});

// Fake process function to move newly created jobs in the UI through a few of the job states.
queue.process(async function (job) {
queue.process(async function () {
// Wait 5sec
await new Promise((res) => setTimeout(res, 5000));

Expand Down
4 changes: 2 additions & 2 deletions example/bull.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
});

// Fake process function to move newly created jobs in the UI through a few of the job states.
queue.process(async function (job) {
queue.process(async function () {
// Wait 5sec
await new Promise((res) => setTimeout(res, 5000));

Expand All @@ -32,7 +32,7 @@ async function main() {
});

// adding delayed jobs
const delayedJob = await queue.add({}, { delay: 60 * 1000 });
const delayedJob = await queue.add({}, {delay: 60 * 1000});
delayedJob.log('Log message');

const app = Arena(
Expand Down
12 changes: 6 additions & 6 deletions example/bullmq.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Arena = require('../');
const { Queue, QueueScheduler, Worker } = require('bullmq');
const {Queue, QueueScheduler, Worker} = require('bullmq');
const RedisServer = require('redis-server');

// Select ports that are unlikely to be used by other services a developer might be running locally.
Expand All @@ -14,17 +14,17 @@ async function main() {
const queueName = 'name_of_my_queue';

const queueScheduler = new QueueScheduler(queueName, {
connection: { port: REDIS_SERVER_PORT },
connection: {port: REDIS_SERVER_PORT},
});
await queueScheduler.waitUntilReady();

const queue = new Queue(queueName, {
connection: { port: REDIS_SERVER_PORT },
connection: {port: REDIS_SERVER_PORT},
});

new Worker(
queueName,
async function (job) {
async function () {
// Wait 5sec
await new Promise((res) => setTimeout(res, 5000));

Expand All @@ -34,12 +34,12 @@ async function main() {
}
},
{
connection: { port: REDIS_SERVER_PORT },
connection: {port: REDIS_SERVER_PORT},
}
);

// adding delayed jobs
const delayedJob = await queue.add('delayed', {}, { delay: 60 * 1000 });
const delayedJob = await queue.add('delayed', {}, {delay: 60 * 1000});
delayedJob.log('Log message');

Arena(
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ const Arena = require('./src/server/app');
const routes = require('./src/server/views/routes');

function run(config, listenOpts = {}) {
const { app, Queues } = Arena(config);
const {app, Queues} = Arena(config);

Queues.useCdn = typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;
Queues.useCdn =
typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;

app.locals.appBasePath = listenOpts.basePath || app.locals.appBasePath;

app.use(app.locals.appBasePath, express.static(path.join(__dirname, 'public')));
app.use(
app.locals.appBasePath,
express.static(path.join(__dirname, 'public'))
);
app.use(app.locals.appBasePath, routes);

const port = listenOpts.port || 4567;
const host = listenOpts.host || '0.0.0.0'; // Default: listen to all network interfaces.
if (!listenOpts.disableListen) {
app.listen(port, host, () => console.log(`Arena is running on port ${port} at host ${host}`));
app.listen(port, host, () => {
console.log(`Arena is running on port ${port} at host ${host}`);
});
}

return app;
Expand Down
Loading

0 comments on commit 3c5d0cb

Please sign in to comment.