-
-
Notifications
You must be signed in to change notification settings - Fork 401
fix: add prettier and eslint #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,13 @@ | ||
module.exports = { | ||
extends: ['eslint:recommended', 'plugin:prettier/recommended'], | ||
env: { | ||
browser: true, | ||
amd: true, | ||
node: true, | ||
mocha: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
}, | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
/coverage | ||
|
||
# production | ||
/lib | ||
/dist | ||
|
||
# npm | ||
package-lock.json | ||
npm-debug.log* | ||
.nyc_output | ||
test/html |
This file contains hidden or 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,9 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"trailingComma": "es5", | ||
Shinigami92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"useTabs": false, | ||
"tabWidth": 2, | ||
"printWidth": 80 | ||
thedaviddias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,57 +1,59 @@ | ||
var path = require('path'); | ||
var events = require('events'); | ||
var glob = require('glob'); | ||
path.parse = path.parse || require('path-parse'); | ||
var path = require('path') | ||
var events = require('events') | ||
var glob = require('glob') | ||
path.parse = path.parse || require('path-parse') | ||
|
||
var mapFormatters; | ||
var arrSupportedFormatters; | ||
var HTMLHint; | ||
var options; | ||
var mapFormatters | ||
var arrSupportedFormatters | ||
var HTMLHint | ||
var options | ||
|
||
// load formatters | ||
mapFormatters = loadFormatters(); | ||
arrSupportedFormatters = []; | ||
for(var formatterName in mapFormatters){ | ||
if(formatterName !== 'default'){ | ||
arrSupportedFormatters.push(formatterName); | ||
} | ||
mapFormatters = loadFormatters() | ||
arrSupportedFormatters = [] | ||
for (var formatterName in mapFormatters) { | ||
if (formatterName !== 'default') { | ||
arrSupportedFormatters.push(formatterName) | ||
} | ||
} | ||
|
||
// load all formatters | ||
function loadFormatters(){ | ||
var arrFiles = glob.sync('./formatters/*.js', { | ||
'cwd': __dirname, | ||
'dot': false, | ||
'nodir': true, | ||
'strict': false, | ||
'silent': true | ||
}); | ||
var mapFormatters = {}; | ||
arrFiles.forEach(function(file){ | ||
var fileInfo = path.parse(file); | ||
var formatterPath = path.resolve(__dirname, file); | ||
mapFormatters[fileInfo.name] = require(formatterPath); | ||
}); | ||
return mapFormatters; | ||
function loadFormatters() { | ||
var arrFiles = glob.sync('./formatters/*.js', { | ||
cwd: __dirname, | ||
dot: false, | ||
nodir: true, | ||
strict: false, | ||
silent: true, | ||
}) | ||
var mapFormatters = {} | ||
arrFiles.forEach(function (file) { | ||
var fileInfo = path.parse(file) | ||
var formatterPath = path.resolve(__dirname, file) | ||
mapFormatters[fileInfo.name] = require(formatterPath) | ||
}) | ||
return mapFormatters | ||
} | ||
|
||
var formatter =new events.EventEmitter(); | ||
formatter.getSupported = function(){ | ||
return arrSupportedFormatters; | ||
}; | ||
formatter.init = function(tmpHTMLHint, tmpOptions){ | ||
HTMLHint = tmpHTMLHint; | ||
options = tmpOptions; | ||
}; | ||
formatter.setFormat = function(format){ | ||
var formatHandel = mapFormatters[format]; | ||
if(formatHandel === undefined){ | ||
console.log('No supported formatter, supported formatters: %s'.red, arrSupportedFormatters.join(', ')); | ||
process.exit(1); | ||
} | ||
else{ | ||
formatHandel(formatter, HTMLHint, options); | ||
} | ||
}; | ||
var formatter = new events.EventEmitter() | ||
formatter.getSupported = function () { | ||
return arrSupportedFormatters | ||
} | ||
formatter.init = function (tmpHTMLHint, tmpOptions) { | ||
HTMLHint = tmpHTMLHint | ||
options = tmpOptions | ||
} | ||
formatter.setFormat = function (format) { | ||
var formatHandel = mapFormatters[format] | ||
if (formatHandel === undefined) { | ||
console.log( | ||
'No supported formatter, supported formatters: %s'.red, | ||
arrSupportedFormatters.join(', ') | ||
) | ||
process.exit(1) | ||
} else { | ||
formatHandel(formatter, HTMLHint, options) | ||
} | ||
} | ||
|
||
module.exports = formatter; | ||
module.exports = formatter |
This file contains hidden or 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,48 +1,50 @@ | ||
var xml = require('xml'); | ||
var xml = require('xml') | ||
|
||
var checkstyleFormatter = function(formatter){ | ||
formatter.on('end', function(event){ | ||
var arrFiles = []; | ||
var arrAllMessages = event.arrAllMessages; | ||
arrAllMessages.forEach(function(fileInfo){ | ||
var arrMessages = fileInfo.messages; | ||
var arrErrors = []; | ||
arrMessages.forEach(function(message){ | ||
arrErrors.push({ | ||
error: { | ||
_attr: { | ||
line: message.line, | ||
column: message.col, | ||
severity: message.type, | ||
message: message.message, | ||
source: 'htmlhint.'+message.rule.id | ||
} | ||
} | ||
}); | ||
}); | ||
arrFiles.push({ | ||
file: [ | ||
{ | ||
_attr: { | ||
name: fileInfo.file | ||
} | ||
} | ||
].concat(arrErrors) | ||
}); | ||
}); | ||
var objXml = { | ||
checkstyle: [ | ||
{ | ||
_attr: { | ||
version: '4.3' | ||
} | ||
} | ||
].concat(arrFiles) | ||
}; | ||
console.log(xml(objXml, { | ||
declaration: true, | ||
indent: ' ' | ||
})); | ||
}); | ||
}; | ||
module.exports = checkstyleFormatter; | ||
var checkstyleFormatter = function (formatter) { | ||
formatter.on('end', function (event) { | ||
var arrFiles = [] | ||
var arrAllMessages = event.arrAllMessages | ||
arrAllMessages.forEach(function (fileInfo) { | ||
var arrMessages = fileInfo.messages | ||
var arrErrors = [] | ||
arrMessages.forEach(function (message) { | ||
arrErrors.push({ | ||
error: { | ||
_attr: { | ||
line: message.line, | ||
column: message.col, | ||
severity: message.type, | ||
message: message.message, | ||
source: 'htmlhint.' + message.rule.id, | ||
}, | ||
}, | ||
}) | ||
}) | ||
arrFiles.push({ | ||
file: [ | ||
{ | ||
_attr: { | ||
name: fileInfo.file, | ||
}, | ||
}, | ||
].concat(arrErrors), | ||
}) | ||
}) | ||
var objXml = { | ||
checkstyle: [ | ||
{ | ||
_attr: { | ||
version: '4.3', | ||
}, | ||
}, | ||
].concat(arrFiles), | ||
} | ||
console.log( | ||
xml(objXml, { | ||
declaration: true, | ||
indent: ' ', | ||
}) | ||
) | ||
}) | ||
} | ||
module.exports = checkstyleFormatter |
This file contains hidden or 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,24 +1,25 @@ | ||
var compactFormatter = function(formatter, HTMLHint, options){ | ||
var nocolor = options.nocolor; | ||
formatter.on('file', function(event){ | ||
event.messages.forEach(function (message) { | ||
console.log('%s: line %d, col %d, %s - %s (%s)', | ||
event.file, | ||
message.line, | ||
message.col, | ||
message.type, | ||
message.message, | ||
message.rule.id | ||
); | ||
}); | ||
}); | ||
formatter.on('end', function(event){ | ||
var allHintCount = event.allHintCount; | ||
if(allHintCount > 0){ | ||
console.log(''); | ||
var message = '%d problems'; | ||
console.log(nocolor ? message : message.red, event.allHintCount); | ||
} | ||
}); | ||
}; | ||
module.exports = compactFormatter; | ||
var compactFormatter = function (formatter, HTMLHint, options) { | ||
var nocolor = options.nocolor | ||
formatter.on('file', function (event) { | ||
event.messages.forEach(function (message) { | ||
console.log( | ||
'%s: line %d, col %d, %s - %s (%s)', | ||
event.file, | ||
message.line, | ||
message.col, | ||
message.type, | ||
message.message, | ||
message.rule.id | ||
) | ||
}) | ||
}) | ||
formatter.on('end', function (event) { | ||
var allHintCount = event.allHintCount | ||
if (allHintCount > 0) { | ||
console.log('') | ||
var message = '%d problems' | ||
console.log(nocolor ? message : message.red, event.allHintCount) | ||
} | ||
}) | ||
} | ||
module.exports = compactFormatter |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'm a fan of semicolons because it increases readability
Do you have an argument why you want to disable semis?