-
Notifications
You must be signed in to change notification settings - Fork 887
Add exceptions support for comment-format rule (fixes #562) #1757
Conversation
@IllusionMH I extended timeout for executable to 4s in #1766 |
type: "string", | ||
enum: ["check-space", "check-lowercase", "check-uppercase"], | ||
}, { | ||
type: "array", |
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.
would it be better to just make this a single regex string since the code makes it into a reg expression anyways? Also, people might see weird behavior if they don't know it's a regex.
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.
on second thought, it's probably better the way it is...
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.
I've checked list of ESLint rules and they use RE to provide patterns, however they use object with "ignorePattern" key to provide it.
As alternative approach I can implement exception argument as object with two possible keys ignoreWords
- array of strings to ignore and ignorePattern
- string with RE to ignore, instead of array of words. Users can select either of two, which suit best for their needs.
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.
yes, would suggest an object with key for future extensibility
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.
Ok. I'll rework this PR to use object instead of array.
And one more question: Is current state of options
in rule metadata correct for case with array?
I not sure if I correctly get this format especially when there should be 2 types of items in array - strings and array (unfortunately I can't find docs with description or sources that process it)
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.
I'm not that familiar with JSON schema, but don't you want anyOf
instead of oneOf
?
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.
Thanks for the tip, I'll check Schema docs then. (haven't used JSON Schema before and didn't realize that TSLint uses it)
@nchen63 thank you! I've noticed that I forgot to update |
@IllusionMH could you please enable Circle CI on your fork? |
@adidahiya added. But for some reason it doesn't run build on all 3 Node.js versions. |
Your CI build looks fine, it is running different node versions in 3 containers (maybe you went and enabled multiple containers in the hour since you posted your last comment :)) |
@adidahiya yes, now it runs in 3 containers, however failed/stopped few times when I tried to setup them. Moreover build on Do I need to do any other actions with CI? |
aba85ee
to
6fe20ce
Compare
I've rebased this branch and resolved conflicts. @nchen63, @adidahiya is there anything that should be addressed in this PR? |
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.
Sorry the review took so long
type: "style", | ||
typescriptOnly: false, | ||
}; | ||
/* tslint:enable:object-literal-sort-keys */ | ||
|
||
public static LOWERCASE_FAILURE = "comment must start with lowercase letter"; | ||
public static UPPERCASE_FAILURE = "comment must start with uppercase letter"; | ||
public static LOWERCASE_FAILURE = "comment must start with lowercase letter, word from exceptions list or exceptions pattern"; |
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.
Could you print the list of exceptions or regex exception in the error? I think most people wouldn't know what an "exceptions list" is when seeing this error.
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.
Thanks! Good point.
Is it ok if there will be 3 different messages instead of one generic?
comment must start with lowercase letter
comment must start with lowercase letter or word from exceptions list: TODO, HACK
comment must start with lowercase letter or match exceptions pattern: STD(IN|OUT|ERR)\b
And same for uppercase option.
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.
3 different messages are ok.
I'd avoid using the word "exceptions" since it could confuse people with the kind of exception you throw. Something like Comment must start with a lowercase letter, or the words "TODO", or "HACK"
and Comment must start with a lowercase letter or match the regex pattern "STD(IN|OUT|ERR)\b
@nchen63 I've updated messages. |
@IllusionMH thanks! |
I realized as I was compiling the release notes that the option |
@nchen63 you are right. |
Docs are generated and published with the release. I've recently added the generated docs to .gitignore, so it's not possible to update in any case. |
@nchen63 thanks, PR is on the way |
PR checklist
New feature, bugfix, orenhancementWhat changes did you make?
This PR adds support for exceptions list to comment-format rule.
Implementation uses array of exceptions as last argument.
Is there anything you'd like reviewers to focus on?
1. Is there a need to escape special characters in exception list to avoid broken RegEx'es?
2. Does exceptions array in last position good choice until #1738 implemented?
P.S. Is it possible to set tests timeout for executable to 3000ms? This will help me a lot, since some tests take ~2500ms under when I run tests in Docker container.