Skip to content

Commit

Permalink
Frontend: Allow console debug statement in development (Cloud-CV#983)
Browse files Browse the repository at this point in the history
* Frontend: Allow console debug statement in development
	* Change eslint no-console error to warnings
	* Dev server will stop only for lint errors not for warnings

* Solved authCtrl console bug
  • Loading branch information
spyshiv authored and deshraj committed Jun 1, 2017
1 parent 18c47d0 commit df78b62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
8 changes: 2 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ eslint config file.
"extends": "eslint:recommended",

"rules": {
"no-console": [
"error", {
allow: ["warn", "error"]
}
],
"semi": [2,
"no-console": "warn",
"semi": ["error",
"always", {
"omitLastInOneLineBlock": true
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/js/controllers/authCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@

}

} catch (error) { /*eslint no-console: ["error", {allow: ["warn", "error"]}]*/
console.error(error);
} catch (error) {
console.log(error);
}
}
vm.stopLoader();
Expand Down Expand Up @@ -158,8 +158,8 @@
if (non_field_errors) {
vm.FormError = response.data.non_field_errors[0];
}
} catch (error) { /*eslint no-console: ["error", {allow: ["warn", "error"]}]*/
console.error(error);
} catch (error) {
console.log(error);
}
}
vm.stopLoader();
Expand Down
24 changes: 16 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,19 @@ gulp.task('lint', [], function() {
.pipe(eslint({}))
.pipe(eslint.format())
.pipe(eslint.results(function(results) {
connect.serverClose(); // Close the server initially.
var countError = results.errorCount; // Get the count of lint errors.
var countWarning = results.warningCount; // Get the count of lint warnings.
if (countError === 0) { // If there are no errors.
if (countWarning === 0) { // If there are no warnings.
gulp.start('connect'); // Connect the server again.

// Get the count of lint errors
var countError = results.errorCount;
//Get the count of lint warnings
var countWarning = results.warningCount;
if (countError === 0) {
gulp.start('connect');
if(countWarning > 0) {
console.warn("Please remove lint warnings in production env.");
}
} else {
connect.serverClose();
console.error("Please remove lint errors to connect the server");
}
}))
});
Expand Down Expand Up @@ -352,7 +358,9 @@ gulp.task('watch', function() {


// Start a server for serving frontend
gulp.task('connect', [], function() {
gulp.task('connect', ['lint'], function() {
// initially close the existance server if exists
connect.serverClose();
connect.server({
root: 'frontend/',
port: 8888,
Expand Down Expand Up @@ -390,5 +398,5 @@ gulp.task('prod', function(callback) {

// Runserver for development
gulp.task('dev:runserver', function(callback) {
runSequence('dev', 'watch', 'lint', callback);
runSequence('dev', 'connect', 'watch', callback);
});

0 comments on commit df78b62

Please sign in to comment.