-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add eslintrc * eslint and prettier all files * fix: replace by npm script * fix: prettify more files * fixes based on review
- Loading branch information
1 parent
9914725
commit f0ad770
Showing
97 changed files
with
4,042 additions
and
3,246 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,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 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
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 |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
/coverage | ||
|
||
# production | ||
/lib | ||
/dist | ||
|
||
# npm | ||
package-lock.json | ||
npm-debug.log* | ||
.nyc_output | ||
test/html |
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,9 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"trailingComma": "es5", | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"printWidth": 80 | ||
} |
This file was deleted.
Oops, something went wrong.
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,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 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 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.