Open mrmlnc opened 8 years ago
With #92, this can be achieved with ESLint's JSON formatter:
$ node bin/pug-lint -r node_modules/eslint/lib/formatters/json.js --config t.json a.pug b.pug
[
{
"messages": [
{
"ruleId": "disallowIdLiterals",
"severity": 2,
"message": "ID literals must not be used",
"line": 1,
"column": 1,
"nodeType": null,
"source": "#id",
"fatal": false,
"messageWithSource": "a.pug:1:1\n > 1| #id\n-------^\n 2| \n\nID literals must not be used",
"fullSource": "#id\n",
"pugError": {
"code": "PUG:LINT_DISALLOWIDLITERALS",
"msg": "ID literals must not be used",
"line": 1,
"column": 1,
"filename": "a.pug"
}
}
],
"filePath": "a.pug",
"errorCount": 1,
"warningCount": 0
},
{
"messages": [
{
"ruleId": "",
"severity": 2,
"message": "Syntax Error: Unexpected character '#'",
"line": 1,
"column": 9,
"nodeType": null,
"source": "= (afds # sadf)",
"fatal": false,
"messageWithSource": "b.pug:1:9\n > 1| = (afds # sadf)\n---------------^\n 2| \n\nSyntax Error: Unexpected character '#'",
"fullSource": "= (afds # sadf)\n",
"pugError": {
"code": "PUG:SYNTAX_ERROR",
"msg": "Syntax Error: Unexpected character '#'",
"line": 1,
"column": 9,
"filename": "b.pug"
}
}
],
"filePath": "b.pug",
"errorCount": 1,
"warningCount": 0
}
]
(JSON formatted and private properties removed)
The schema of the output is defined by ESLint. The pug-error object is in message.pugError
.
Maybe add a JSON reporter as in ESLint for easy interaction with the command line utility in plugins?
For example:
Output: