-
Notifications
You must be signed in to change notification settings - Fork 37
Fix handling whitespace before first comment #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nokel81
wants to merge
2
commits into
Stuk:main
Choose a base branch
from
Nokel81:issue-47
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -53,15 +53,15 @@ ruleTester.run("header", rule, { | |
}, | ||
{ | ||
code: "// Copyright 2017", | ||
options: ["line", {pattern: "^ Copyright \\d+$"}, 0] | ||
options: ["line", { pattern: "^ Copyright \\d+$" }, 0] | ||
}, | ||
{ | ||
code: "// Copyright 2017\n// Author: [email protected]", | ||
options: ["line", [{pattern: "^ Copyright \\d+$"}, {pattern: "^ Author: \\w+@\\w+\\.\\w+$"}], 0] | ||
options: ["line", [{ pattern: "^ Copyright \\d+$" }, { pattern: "^ Author: \\w+@\\w+\\.\\w+$" }], 0] | ||
}, | ||
{ | ||
code: "/* Copyright 2017\n Author: [email protected] */", | ||
options: ["block", {pattern: "^ Copyright \\d{4}\\n Author: \\w+@\\w+\\.\\w+ $"}, 0] | ||
options: ["block", { pattern: "^ Copyright \\d{4}\\n Author: \\w+@\\w+\\.\\w+ $" }, 0] | ||
}, | ||
{ | ||
code: "#!/usr/bin/env node\n/**\n * Copyright\n */", | ||
|
@@ -81,11 +81,11 @@ ruleTester.run("header", rule, { | |
}, | ||
{ | ||
code: "/*Copyright 2018\r\nMy Company*/\r\nconsole.log(1)", | ||
options: ["block", ["Copyright 2018", "My Company"], {"lineEndings": "windows"}] | ||
options: ["block", ["Copyright 2018", "My Company"], { "lineEndings": "windows" }] | ||
}, | ||
{ | ||
code: "/*Copyright 2018\nMy Company*/\nconsole.log(1)", | ||
options: ["block", ["Copyright 2018", "My Company"], {"lineEndings": "unix"}] | ||
options: ["block", ["Copyright 2018", "My Company"], { "lineEndings": "unix" }] | ||
}, | ||
{ | ||
code: "/*************************\n * Copyright 2015\n * My Company\n *************************/\nconsole.log(1)", | ||
|
@@ -130,31 +130,103 @@ ruleTester.run("header", rule, { | |
code: "console.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{message: "missing header"} | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\n\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\n\n\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\n\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company", 2], | ||
errors: [ | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company", 3], | ||
errors: [ | ||
{ message: "missing header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\n\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "\n/**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
options: ["block", "*\n * Copyright 2020\n * My Company\n *", 2], | ||
errors: [ | ||
{ message: "unexpected preceding whitespace" } | ||
], | ||
output: "/**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
}, | ||
{ | ||
code: " /**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
options: ["block", "*\n * Copyright 2020\n * My Company\n *", 2], | ||
errors: [ | ||
{ message: "unexpected preceding whitespace" } | ||
], | ||
output: "/**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
}, | ||
{ | ||
code: "\n /**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
options: ["block", "*\n * Copyright 2020\n * My Company\n *", 2], | ||
errors: [ | ||
{ message: "unexpected preceding whitespace" } | ||
], | ||
output: "/**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);", | ||
}, | ||
{ | ||
code: "\n//Copyright 2018\r\n//My Company\r\n/* DOCS */", | ||
options: ["line", ["Copyright 2018", "My Company"]], | ||
errors: [ | ||
{ message: "unexpected preceding whitespace" } | ||
], | ||
output: "//Copyright 2018\r\n//My Company\r\n/* DOCS */", | ||
}, | ||
{ | ||
code: "//Copyright 2014, My Company\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{message: "header should be a block comment"} | ||
{ message: "header should be a block comment" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "/*Copyright 2014, My Company*/\nconsole.log(1);", | ||
options: ["line", "Copyright 2015, My Company"], | ||
errors: [ | ||
{message: "header should be a line comment"} | ||
{ message: "header should be a line comment" } | ||
], | ||
output: "//Copyright 2015, My Company\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "/*Copyright 2014, My Company*/\nconsole.log(1);", | ||
options: ["block", "Copyright 2015, My Company"], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "/*Copyright 2015, My Company*/\nconsole.log(1);" | ||
}, | ||
|
@@ -163,69 +235,69 @@ ruleTester.run("header", rule, { | |
code: "/*Copyright 2015\nMy Company\nExtra*/\nconsole.log(1);", | ||
options: ["block", ["Copyright 2015", "My Company"]], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "/*Copyright 2015\nMy Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "/*Copyright 2015\n*/\nconsole.log(1);", | ||
options: ["block", ["Copyright 2015", "My Company"]], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "/*Copyright 2015\nMy Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "//Copyright 2014\n//My Company\nconsole.log(1)", | ||
options: ["line", "Copyright 2015\nMy Company"], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "//Copyright 2015\n//My Company\nconsole.log(1)" | ||
}, | ||
{ | ||
code: "//Copyright 2015", | ||
options: ["line", "Copyright 2015\nMy Company"], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "//Copyright 2015\n//My Company\n" | ||
}, | ||
{ | ||
code: "// Copyright 2017 trailing", | ||
options: ["line", {pattern: "^ Copyright \\d+$"}], | ||
options: ["line", { pattern: "^ Copyright \\d+$" }], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
] | ||
}, | ||
{ | ||
code: "// Copyright 2017 trailing", | ||
options: ["line", {pattern: "^ Copyright \\d+$", template: " Copyright 2018"}], | ||
options: ["line", { pattern: "^ Copyright \\d+$", template: " Copyright 2018" }], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "// Copyright 2018\n" | ||
}, | ||
{ | ||
code: "// Copyright 2017 trailing\n// Someone", | ||
options: ["line", [{pattern: "^ Copyright \\d+$", template: " Copyright 2018"}, " My Company"]], | ||
options: ["line", [{ pattern: "^ Copyright \\d+$", template: " Copyright 2018" }, " My Company"]], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "// Copyright 2018\n// My Company\n" | ||
}, | ||
{ | ||
code: "// Copyright 2017\n// Author: [email protected]", | ||
options: ["line", [{pattern: "Copyright \\d+"}, {pattern: "^ Author: \\w+@\\w+\\.\\w+$"}]], | ||
options: ["line", [{ pattern: "Copyright \\d+" }, { pattern: "^ Author: \\w+@\\w+\\.\\w+$" }]], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
] | ||
}, | ||
{ | ||
code: "/* Copyright 2017-01-02\n Author: [email protected] */", | ||
options: ["block", {pattern: "^ Copyright \\d+\\n Author: \\w+@\\w+\\.\\w+ $"}], | ||
options: ["block", { pattern: "^ Copyright \\d+\\n Author: \\w+@\\w+\\.\\w+ $" }], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
] | ||
}, | ||
{ | ||
|
@@ -237,47 +309,47 @@ ruleTester.run("header", rule, { | |
" ************************" | ||
]], | ||
errors: [ | ||
{message: "incorrect header"} | ||
{ message: "incorrect header" } | ||
], | ||
output: "/*************************\n * Copyright 2019\n * My Company\n *************************/\nconsole.log(1)" | ||
}, | ||
{ | ||
code: "/*Copyright 2020, My Company*/console.log(1);", | ||
options: ["block", "Copyright 2020, My Company", 2], | ||
errors: [ | ||
{message: "no newline after header"} | ||
{ message: "no newline after header" } | ||
], | ||
output: "/*Copyright 2020, My Company*/\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "/*Copyright 2020, My Company*/console.log(1);", | ||
options: ["block", "Copyright 2020, My Company", 1], | ||
errors: [ | ||
{message: "no newline after header"} | ||
{ message: "no newline after header" } | ||
], | ||
output: "/*Copyright 2020, My Company*/\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "//Copyright 2020\n//My Company\nconsole.log(1);", | ||
options: ["line", ["Copyright 2020", "My Company"], 2], | ||
errors: [ | ||
{message: "no newline after header"} | ||
{ message: "no newline after header" } | ||
], | ||
output: "//Copyright 2020\n//My Company\n\nconsole.log(1);" | ||
}, | ||
{ | ||
code: "/*Copyright 2020, My Company*/\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment", | ||
options: ["block", "Copyright 2020, My Company", 2], | ||
errors: [ | ||
{message: "no newline after header"} | ||
{ message: "no newline after header" } | ||
], | ||
output: "/*Copyright 2020, My Company*/\n\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment" | ||
}, | ||
{ | ||
code: "//Copyright 2020\n//My Company\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment", | ||
options: ["line", ["Copyright 2020", "My Company"], 2], | ||
errors: [ | ||
{message: "no newline after header"} | ||
{ message: "no newline after header" } | ||
], | ||
output: "//Copyright 2020\n//My Company\n\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment" | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.