Skip to content

Commit f874a80

Browse files
committed
add grunt/jshint/jscs
1 parent 26fa134 commit f874a80

File tree

3 files changed

+70
-26
lines changed

3 files changed

+70
-26
lines changed

Gruntfile.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = function (grunt) {
2+
// Project configuration.
3+
grunt.initConfig({
4+
jshint: {
5+
options : {
6+
jshintrc: ".jshintrc",
7+
ignores : [ "node_modules/**/*.js" ]
8+
},
9+
src: ["Gruntfile.js", "app.js"],
10+
},
11+
jscs: {
12+
src: ["Gruntfile.js", "app.js"],
13+
options: {
14+
config: ".jscsrc",
15+
requireCurlyBraces: [ "if" ]
16+
}
17+
}
18+
});
19+
20+
grunt.loadNpmTasks("grunt-contrib-jshint");
21+
22+
grunt.registerTask("default", [ "lint", "jscs" ]);
23+
24+
grunt.loadNpmTasks("grunt-jscs");
25+
26+
grunt.registerTask("lint", "Check for common code problems.", [ "jshint" ]);
27+
};

app.js

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ app.use(express.static(__dirname + '/public'));
6363
var multipart = multer({ dest: process.env.TMPDIR, limits: { files: 1, fileSize: 100000000 }});
6464

6565
// posted body parser
66-
var bodyParser = require('body-parser')({extended:true})
66+
var bodyParser = require('body-parser')({extended:true});
6767

6868
// compress all requests
6969
app.use(compression());
@@ -100,7 +100,7 @@ app.post('/upload', multipart, isloggedin.auth, function(req, res){
100100
};
101101

102102
dbimport.clear();
103-
app.locals.import[obj.files.file.name] = obj
103+
app.locals.import[obj.files.file.name] = obj;
104104
inference.infer(obj.files.file.path, function(err, data) {
105105
data.upload_id = req.files.file.name;
106106
res.send(data);
@@ -112,7 +112,7 @@ app.post('/fetch', bodyParser, isloggedin.auth, function(req, res){
112112
var obj = req.body;
113113

114114
dbimport.clear();
115-
app.locals.import[obj.url] = obj
115+
app.locals.import[obj.url] = obj;
116116

117117
inference.infer(obj.url, function(err, data) {
118118
data.upload_id = obj.url;
@@ -126,7 +126,7 @@ app.post('/import', bodyParser, isloggedin.auth, function(req, res){
126126
console.log("****",req.body.schema);
127127
console.log("****");
128128

129-
var currentUpload = app.locals.import[req.body.upload_id]
129+
var currentUpload = app.locals.import[req.body.upload_id];
130130

131131
// run this in parallel to save time
132132
var theschema = JSON.parse(req.body.schema);
@@ -181,16 +181,16 @@ app.get('/config', isloggedin.auth, function(req, res) {
181181
autocomplete: app.locals.autocomplete,
182182
cache: app.locals.cache,
183183
metrics: app.locals.metrics
184-
})
185-
})
184+
});
185+
});
186186

187187
//settings api
188188
app.get('/settings', isloggedin.auth, function (req, res) {
189189
db.settings(function(err, data) {
190190
if (err) {
191191
return res.status(err.statusCode).send({error: err.error, reason: err.reason});
192192
}
193-
data["appenv"] = sssenv;
193+
data.appenv = sssenv;
194194
res.send(data);
195195
});
196196
});
@@ -277,7 +277,7 @@ app.get('/autocompletes', cors(), isloggedin.auth, function(req, res) {
277277

278278
Object.keys(data.counts).forEach(k => {
279279
facets[k] = `http://${req.headers.host}/autocompletes/${k}`;
280-
})
280+
});
281281

282282
res.send(facets);
283283

@@ -311,17 +311,19 @@ app.post('/service/enable/sas', isloggedin.auth, function(req, res) {
311311
registry.setEnv("search", "autocomplete_enable", true, function(err, data) {
312312

313313
if (err) {
314-
return res.send({ success: false })
314+
return res.send({ success: false });
315315
}
316316

317-
return res.send({ success: true })
317+
data = null;
318+
319+
return res.send({ success: true });
318320

319321
});
320322

321323
}
322324

323325
else {
324-
return res.send({ success: false })
326+
return res.send({ success: false });
325327
}
326328

327329
});
@@ -333,16 +335,18 @@ app.post('/service/disable/sas', isloggedin.auth, function(req, res) {
333335
registry.setEnv("search", "autocomplete_enable", false, function(err, data) {
334336

335337
if (err) {
336-
return res.send({ success: false })
338+
return res.send({ success: false });
337339
}
338340

339-
return res.send({ success: true })
341+
data = null;
342+
343+
return res.send({ success: true });
340344

341345
});
342346
}
343347

344348
else {
345-
return res.send({ success: false })
349+
return res.send({ success: false });
346350
}
347351

348352
});
@@ -355,17 +359,19 @@ app.post('/service/enable/scs', isloggedin.auth, function(req, res) {
355359
registry.setEnv("search", "cache_enable", true, function(err, data) {
356360

357361
if (err) {
358-
return res.send({ success: false })
362+
return res.send({ success: false });
359363
}
360364

361-
return res.send({ success: true })
365+
data = null;
366+
367+
return res.send({ success: true });
362368

363369
});
364370

365371
}
366372

367373
else {
368-
return res.send({ success: false })
374+
return res.send({ success: false });
369375
}
370376

371377
});
@@ -377,16 +383,18 @@ app.post('/service/disable/scs', isloggedin.auth, function(req, res) {
377383
registry.setEnv("search", "cache_enable", false, function(err, data) {
378384

379385
if (err) {
380-
return res.send({ success: false })
386+
return res.send({ success: false });
381387
}
382388

383-
return res.send({ success: true })
389+
data = null;
390+
391+
return res.send({ success: true });
384392

385393
});
386394
}
387395

388396
else {
389-
return res.send({ success: false })
397+
return res.send({ success: false });
390398
}
391399

392400
});
@@ -399,17 +407,19 @@ app.post('/service/enable/metrics', isloggedin.auth, function(req, res) {
399407
registry.setEnv("search", "metrics_enable", true, function(err, data) {
400408

401409
if (err) {
402-
return res.send({ success: false })
410+
return res.send({ success: false });
403411
}
404412

405-
return res.send({ success: true })
413+
data = null;
414+
415+
return res.send({ success: true });
406416

407417
});
408418

409419
}
410420

411421
else {
412-
return res.send({ success: false })
422+
return res.send({ success: false });
413423
}
414424

415425
});
@@ -421,16 +431,18 @@ app.post('/service/disable/metrics', isloggedin.auth, function(req, res) {
421431
registry.setEnv("search", "metrics_enable", false, function(err, data) {
422432

423433
if (err) {
424-
return res.send({ success: false })
434+
return res.send({ success: false });
425435
}
426436

427-
return res.send({ success: true })
437+
data = null;
438+
439+
return res.send({ success: true });
428440

429441
});
430442
}
431443

432444
else {
433-
return res.send({ success: false })
445+
return res.send({ success: false });
434446
}
435447

436448
});

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@
3030
},
3131
"devDependencies": {
3232
"autoprefixer": "^6.2.3",
33+
"grunt": "^1.0.1",
34+
"grunt-cli": "^1.2.0",
35+
"grunt-contrib-jshint": "^1.0.0",
36+
"grunt-jscs": "^3.0.1",
3337
"gulp": "^3.9.0",
3438
"gulp-postcss": "^6.0.1",
3539
"gulp-rename": "^1.2.2",
40+
"jshint": "^2.9.3",
3641
"postcss-cssnext": "^2.4.0",
3742
"postcss-custom-properties": "^5.0.0",
3843
"postcss-import": "^7.1.3"

0 commit comments

Comments
 (0)