8000 Report short TypeScript comments by zerone0x · Pull Request #198 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@ function isAbsent(error) {
return error.code === "MODULE_NOT_FOUND";
}

const MAX_SINGLE_LINE_CHARS = 10;
const MAX_BLOCK_CHARS = 15;

function isExempt(text) {
return text.includes("eslint-disable");
}

function isReportableSingle(text) {
return (
text.startsWith("//") && !isExempt(text) && text.length >= MAX_SINGLE_LINE_CHARS
);
return text.startsWith("//") && !isExempt(text);
}

function isReportableBlock(text) {
return (
text.startsWith("/*") && !isExempt(text) && text.length >= MAX_BLOCK_CHARS
);
return text.startsWith("/*") && !isExempt(text);
}

function truncate(text) {
Expand Down
17 changes: 17 additions & 0 deletions plugins/typescript/tests/test_the_comment_helper_finds_ts_morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def test_an_install_outside_the_project_still_finds_ts_morph(tmp_path: Path) ->
assert reported_files(result) == [as_ts_morph_spells(consumer / SOURCE_FILE)]


def test_short_comments_are_still_reported(tmp_path: Path) -> None:
consumer = project(tmp_path)
(consumer / SOURCE_FILE).write_text(
"// note\n"
"/* why */\n"
"export const other = 2;\n",
encoding="utf-8",
)

result = run(consumer, installed_outside_the_project(tmp_path))

assert reported_files(result) == [
as_ts_morph_spells(consumer / SOURCE_FILE),
as_ts_morph_spells(consumer / SOURCE_FILE),
]


def test_a_project_without_ts_morph_is_told_to_install_it(tmp_path: Path) -> None:
consumer = project_without_ts_morph(tmp_path)

Expand Down
Loading
0