Skip to content

Commit

Permalink
Add support for JSON with Comments.
Browse files Browse the repository at this point in the history
Support is similar to JSON5, except block comments are also supported.
  • Loading branch information
ralimi committed Feb 25, 2023
1 parent 9430173 commit 53f6d2f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
16 changes: 16 additions & 0 deletions syntax.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@
}
]
},
{
"language": "JSON with Comments",
"markers": [
{
"type": "line",
"pattern": "//"
},
{
"type": "block",
"pattern": {
"start": "/\\*",
"end": "\\*/"
}
}
]
},
{
"language": "JSON5",
"markers": [
Expand Down
6 changes: 6 additions & 0 deletions tests/test_closed.diff
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ index 525e25d..ba4e68d 100644
-TODO: Create an issue for TODO
--}
-sum a b = a + b
diff --git a/tests/config.jsonc b/tests/config.jsonc
index 0000000..525e25d 100644
--- a/tests/config.jsonc
+++ b/tests/config.jsonc
@@ -0,0 +0,1 @@
- // TODO: Delete this line from the codebase
diff --git a/tests/config.json5 b/tests/config.json5
index 0000000..525e25d 100644
--- a/tests/config.json5
Expand Down
17 changes: 17 additions & 0 deletions tests/test_new.diff
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ index 0000000..525e25d
+ # This function should probably do something more interesting
+ # labels: help wanted
+}
diff --git a/tests/config.jsonc b/tests/config.jsonc
new file mode 100644
index 0000000..525e25d
--- /dev/null
+++ b/tests/config.jsonc
@@ -0,0 +0,11 @@
+{
+ "myConfig": [
+ /*
+ GitRepository where 'Git release/tag'
+ matches 'Helm' version
+ */
+ "itIsWonderful",
+ // TODO: Delete this line from the codebase
+ "butItHasSomePendingActivities"
+ ]
+}
diff --git a/tests/config.json5 b/tests/config.json5
new file mode 100644
index 0000000..525e25d
Expand Down
10 changes: 8 additions & 2 deletions tests/test_todo_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ def test_php_issues(self):
def test_java_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'java'), 2)

def test_json_with_comments_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)

def test_json5_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 1)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)

def test_ruby_issues(self):
# Includes 2 tests for Crystal.
Expand Down Expand Up @@ -123,8 +126,11 @@ def test_tex_issues(self):
def test_julia_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'julia'), 2)

def test_json_with_comments_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)

def test_json5_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 1)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)

def test_autohotkey_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'autohotkey'), 1)
Expand Down

0 comments on commit 53f6d2f

Please sign in to comment.