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
20 changes: 20 additions & 0 deletions .github/workflows/check-tools-order.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check Tools Order

on:
pull_request:

jobs:
check-tools-order:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 20

- name: Validate tools and libraries order
run: node check-tools-order.js
56 changes: 56 additions & 0 deletions check-tools-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node

const fs = require("fs");
const path = require("path");

const filePath = path.join(__dirname, "index.markdown");
const content = fs.readFileSync(filePath, "utf8");

// Extract the "Tools and Libraries" section
const sectionMatch = content.match(/## Tools and Libraries([\s\S]*?)(?=\n## |\n#+ |$)/);
if (!sectionMatch) {
console.error("Could not find the 'Tools and Libraries' section.");
process.exit(1);
}

const section = sectionMatch[1];

// Extract language headers (lines like **Language**)
const languageRegex = /^\*\*(.+?)\*\*/gm;
const languages = [];
let match;
while ((match = languageRegex.exec(section)) !== null) {
languages.push(match[1]);
}

if (languages.length === 0) {
console.error("No language headers found in the 'Tools and Libraries' section.");
process.exit(1);
}

console.log("Languages found:");
languages.forEach((lang, i) => console.log(` ${i + 1}. ${lang}`));
console.log();

// Check alphabetical order (case-insensitive)
let inOrder = true;
for (let i = 1; i < languages.length; i++) {
const prev = languages[i - 1].toLowerCase();
const curr = languages[i].toLowerCase();
if (curr < prev) {
console.error(
`Ordering error: "${languages[i]}" should appear before "${languages[i - 1]}".`,
);
inOrder = false;
}
}

if (inOrder) {
console.log("All languages are listed in alphabetical order.");
} else {
console.error();
console.error(
"The 'Tools and Libraries' section must stay in alphabetical order.",
);
process.exit(1);
}
23 changes: 11 additions & 12 deletions index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ Several tools and libraries support JSONC, enabling developers to parse and gene

Here is a non-exhaustive list:

**JavaScript/TypeScript**:
- [microsoft/node-jsonc-parser](https://github.com/microsoft/node-jsonc-parser)

**C++**
- [stephenberry/glaze](https://github.com/stephenberry/glaze)

Expand All @@ -118,25 +115,27 @@ Here is a non-exhaustive list:
**Go**
- [tidwall/jsonc](https://github.com/tidwall/jsonc)

**Python**
- [n-takumasa/json-with-comments](https://github.com/n-takumasa/json-with-comments)
**Java**
- [Jackson](https://github.com/FasterXML/jackson-core) `JsonFactory.enable(JsonReadFeature.ALLOW_JAVA_COMMENTS)`

**JavaScript/TypeScript**:
- [microsoft/node-jsonc-parser](https://github.com/microsoft/node-jsonc-parser)

**Kotlin**
- [kotlinx.serialization.json](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/allow-comments.html)

**PHP**
- [otar/jsonc](https://github.com/otar/jsonc)

**Python**
- [n-takumasa/json-with-comments](https://github.com/n-takumasa/json-with-comments)

**Rust**
- [dprint/jsonc-parser](https://github.com/dprint/jsonc-parser)

**Swift**
- [steelbrain/JSONCKit](https://github.com/steelbrain/JSONCKit)

**Java**
- [Jackson](https://github.com/FasterXML/jackson-core) `JsonFactory.enable(JsonReadFeature.ALLOW_JAVA_COMMENTS)`

**Kotlin**
- [kotlinx.serialization.json](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-builder/allow-comments.html)


## APPENDIX A: Trailing Commas and JSONC

### Why Trailing Commas Are Not a Requirement?
Expand Down
Loading