From d1dbd30d6ca9b364635e5d0fb4fc20ade60398a0 Mon Sep 17 00:00:00 2001 From: Joe Biellik Date: Thu, 8 Sep 2016 16:01:14 +0100 Subject: [PATCH] Improve linting and cleanup --- .eslintrc | 10 ++++++++-- app.js | 2 +- controllers/pastes.js | 4 ++-- db.js | 8 ++++---- public/main.js | 5 ++++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.eslintrc b/.eslintrc index 411497d..bd1be6a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,9 +3,15 @@ "node": true, "es6": true }, + "extends": ["eslint:recommended"], "parser": "babel-eslint", "rules": { - "indent": [2, "tab"], - "quotes": [2, "single", "avoid-escape"] + "indent": ["error", "tab"], + "quotes": ["error", "single", "avoid-escape"], + "linebreak-style": ["error", "unix"], + "semi": ["error", "always"], + "no-trailing-spaces": ["warn"], + "comma-dangle": ["error"], + "no-console": ["warn", { allow: ["warn", "error"] }] } } diff --git a/app.js b/app.js index e09a8ff..59ea3bf 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ require('babel-core/register')({ var config = require('config'); var app = require('koa')(); var router = require('./router'); -var db = require('./db')(); +require('./db')(); app.keys = config.keys; app.proxy = true; diff --git a/controllers/pastes.js b/controllers/pastes.js index 9a02903..f83ca8d 100644 --- a/controllers/pastes.js +++ b/controllers/pastes.js @@ -2,7 +2,7 @@ var config = require('config'); var Paste = require('../models/paste'); module.exports = { - *view(next) { + *view() { try { let paste = yield Paste.findById(this.params.id).exec(); let lang = Object.keys(this.query)[0]; @@ -23,7 +23,7 @@ module.exports = { } }, - *create(next) { + *create() { if (this.request.body.fields) { if (this.request.body.fields.paste) { this.request.body.paste = this.request.body.fields.paste; diff --git a/db.js b/db.js index 3390366..83ad75c 100644 --- a/db.js +++ b/db.js @@ -2,15 +2,15 @@ var config = require('config'); var util = require('util'); var mongoose = require('mongoose'); -module.exports = function () { +module.exports = function() { mongoose.Promise = global.Promise; - mongoose.connect(config.db); + mongoose.connect(config.db); - mongoose.connection.once('open', function () { + mongoose.connection.once('open', function() { util.log('MongoDB connection open'); }); mongoose.connection.on('error', console.error.bind(console, 'MongoDB connection error:')); return mongoose.connection; -} +}; diff --git a/public/main.js b/public/main.js index fd66621..42e9e39 100644 --- a/public/main.js +++ b/public/main.js @@ -1,3 +1,6 @@ +/* eslint-env browser */ +/* global $ autosize */ + $(document).ready(function() { autosize($('textarea')); @@ -17,7 +20,7 @@ $(document).ready(function() { window.getSelection().addRange(range); }); - $('select#highlight').change(function(e) { + $('select#highlight').change(function() { location.hash = $(this).val(); });