-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from ripper234/add-linter
Add eslint
- Loading branch information
Showing
23 changed files
with
705 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
public/gentelella/**/*.js | ||
*.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
"extends": "standard", | ||
"plugins": [ | ||
"standard", | ||
"promise" | ||
], | ||
"rules": { | ||
// Used in tests | ||
"no-undef": ["off"], | ||
|
||
// Style | ||
"semi": ["off"], | ||
"indent": ["off"], | ||
"eol-last": ["off"], | ||
"quotes": ["off"], | ||
"operator-linebreak": ["off"], | ||
"space-before-function-paren": ["off"], | ||
"spaced-comment": ["off"], | ||
"brace-style": ["off"], | ||
"padded-blocks": ["off"], | ||
"camelcase": ["off"], | ||
"space-infix-ops": ["off"], | ||
"comma-spacing": ["off"], | ||
"no-trailing-spaces": ["off"], | ||
"key-spacing": ["off"], | ||
"block-spacing": ["off"], | ||
"space-unary-ops": ["off"], | ||
"comma-dangle": ["off"], | ||
"one-var": ["off"], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ Before contributing, please review this guide. | |
|
||
## <a name="question"></a> Got a Question or Problem? | ||
|
||
* Join our Slack and ask us at #sparksystem channel | ||
* [Join our Slack](https://www.hamsterpad.com/chat/midburnos) and ask us at #sparksystem channel | ||
* Email: **[email protected]** | ||
|
||
## <a name="issue"></a> Found an Issue? | ||
|
@@ -65,7 +65,8 @@ Before you submit your pull request consider the following guidelines: | |
- Have you searched for existing, related issues and pull requests? | ||
- Is this a new feature that can stand alone as an external component? | ||
- Is the change being proposed clearly explained and motivated? | ||
|
||
- Does `npm lint` pass? (We use eslint with [Standard.js](http://standardjs.com/) style) | ||
- Does `npm test` pass? | ||
See: [Branching, patching and merging documentation](/docs/development/branching.md) for more details. | ||
|
||
That's it! Thank you for your contribution! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,69 @@ | ||
const path = require('path'); | ||
const winston = require('winston'); | ||
const config = require('config'); | ||
const assert = require('assert'); | ||
const sprintf = require("sprintf-js").sprintf; | ||
const dateFormat = require('dateformat'); | ||
|
||
|
||
module.exports = function(module) { | ||
module.exports = function (module) { | ||
assert(module); | ||
assert(module.id); | ||
|
||
var appDir = path.dirname(require.main.filename); | ||
var id = path.relative(appDir, module.id); | ||
var logger = new (winston.Logger)({ | ||
transports: [ | ||
new (winston.transports.Console)({ | ||
timestamp: function() { | ||
return dateFormat(Date.now(), "dd/mm/yy hh:MM:ss.l"); | ||
}, | ||
formatter: function(options) { | ||
// Return string will be passed to logger. | ||
return sprintf("%-33s", options.timestamp() +' '+ options.level.toUpperCase() +' '+ id + ' : ') + (options.message ? options.message : '') + | ||
(options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' ); | ||
} | ||
}) | ||
] | ||
|
||
var logger = new(winston.Logger)({ | ||
transports: [ | ||
new(winston.transports.Console)({ | ||
timestamp: function () { | ||
return dateFormat(Date.now(), "dd/mm/yy hh:MM:ss.l"); | ||
}, | ||
formatter: function (options) { | ||
// Return string will be passed to logger. | ||
return sprintf("%-33s", options.timestamp() + ' ' + options.level.toUpperCase() + ' ' + id + ' : ') + (options.message ? options.message : '') + | ||
(options.meta && Object.keys(options.meta).length ? '\n\t' + JSON.stringify(options.meta) : ''); | ||
} | ||
}) | ||
] | ||
}); | ||
|
||
function log (level, msg, vars) { | ||
logger.log(level, msg, vars); | ||
function log(level, msg, vars) { | ||
logger.log(level, msg, vars); | ||
} | ||
|
||
// Make Morgan log work with Winston | ||
// http://stackoverflow.com/a/28824464/11236 | ||
logger.stream = function(params) { | ||
logger.stream = function (params) { | ||
return { | ||
write: function(message, encoding){ | ||
write: function (message, encoding) { | ||
if (params.filter && !params.filter(message)) { | ||
return; | ||
} | ||
|
||
if (message.endsWith('\n')) { | ||
message = message.slice(0, -1); | ||
} | ||
logger.log(params.level, message); | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
log : log, | ||
logger : logger, | ||
log: log, | ||
|
||
logger: logger, | ||
|
||
// Aliases | ||
debug : function (msg, vars) { | ||
debug: function (msg, vars) { | ||
log('debug', msg, vars); | ||
}, | ||
info : function (msg, vars) { | ||
info: function (msg, vars) { | ||
log('info', msg, vars); | ||
}, | ||
warn : function (msg, vars) { | ||
warn: function (msg, vars) { | ||
log('warn', msg, vars); | ||
}, | ||
error : function (msg, vars) { | ||
error: function (msg, vars) { | ||
log('error', msg, vars); | ||
}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.