koajs / eslint-config-koa

Koa's ESLint config, based on Standard
MIT License
12 stars 2 forks source link

eslint error: unexpected space before function parentheses #5

Closed dzeroone closed 6 years ago

dzeroone commented 6 years ago

Example

// x-response-time
app.use(async (ctx, next) => {
  const start = Date.now();
  await next();
  const ms = Date.now() - start;
  ctx.set('X-Response-Time', `${ms}ms`);
});
nickserv commented 6 years ago

I noticed this is from a Koa example, but the style is slightly different than Koa's usual style of no spaces before function parentheses, which is why we get the linter error here.

You should change async (ctx, next) to async(ctx, next) and the error will go away. Let me know if you're okay with this fix or if you'd like to discuss changing this rule (which would affect other Koa projects).

dzeroone commented 6 years ago

I like async (ctx, next) this style. So, I have modified .eslintrc rules for my local projects on my own :)

nickserv commented 6 years ago

That's fine, this is just a base config for the convenience of Koa but you can use whatever you'd like. I'm closing this since Koa is continuing to use the style. Also note that ESLint 4 has some more strict rules, so updating from ESLint 3 could also cause this to appear.