-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I've created two branches (feature/improve-error-output & chris/poc/context-and-reporter) but really want to get your opinion before I continue down this path. Didn't know if you already had a plan in your head how to accomplish improving error output and easier unit testing.
What I was wanting to do was mimic eslint's output for errors and warnings.
Drawing from how eslint rules are written they are a JS object similar to this:
module.exports = {
meta: {
docs: {
description: "some description",
category: "some category",
url: "documentation url"
},
// json object array that describes configuration options
schema: [
],
// message key value pairs for output
messages: {
someKey: "some message for output",
}
},
create(context) {
// report rule violations
}
};I like the idea of meta.docs.url with a link back to this repo with a readme explaining the particular rule but not necessary at the moment.
To start I am basically interested in the create function that provides a common interface for each rule to be called from the eslint runner. In my 2nd branch, chris/poc/context-and-reporter, I started to explore having a context object that provides a way to access the mule project's folderInfo, pomInfo, and a way to read a file within that folderInfo.
Then I created a reporter that is also passed into each "rule"'s validate function. This is used to track problems found as rules are being evaluated and then it has a function to print out errors in the format of severity category description. Initially I was thinking to include a category for the error and ideally I'd like to look at adding which file the error was found.
I think these two things will allow for the rules/validation functions to be passed their mock data to more easily unit test them without having to mock the fs package or always have a file to be read.
