Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Rewrite and simplify comment-format #2616

Merged
merged 7 commits into from May 31, 2017
Merged

Rewrite and simplify comment-format #2616

merged 7 commits into from May 31, 2017

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Apr 20, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

Initially I just wanted to convert the walker to a function. But then I needed to change so much it became a complete rewrite.

Is there anything you'd like reviewers to focus on?

CHANGELOG.md entry:

[enhancement] comment-format no longer excludes comments with triple slash from linting except /// <reference path="..."/>

@@ -10,7 +10,8 @@ class Clazz { // This comment is correct
console.log("test"); //This comment has no space
~~~~~~~~~~~~~~~~~~~~~~~~~ [space]
}
/// <reference or something>
/// <not a reference>
~~~~~~~~~~~~~~~~~~~ [space]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message could be better -- there is a space, the problem is the extra /.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should handle comments starting with more than 2 slashes better. The comment text should only be checked starting from the first non-slash character.

And maybe there could be a new option to disallow more than 2 slashes

super(sourceFile, options);
function parseOptions(options: Array<string | IExceptionsObject>): Options {
return {
case: options.indexOf(OPTION_LOWERCASE) !== -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested ternary is discouraged

}
const commentText = fullText.slice(start, end);
// whitelist //#region and //#endregion and JetBrains IDEs' "//noinspection ..."
if (/^(?:#(!?end)?region|noinspection\s)/.test(commentText)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the !?end part for? This matches !end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, that should be ?:end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants