Provide usage examples
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- node.js, typescript
- Lĩnh vực
- documentation
Hướng nghiên cứu
Bắt đầu với ví dụ TypeScript trong issue và xem xét các entry point công khai parse, modify và applyEdits của thư viện. Hoàn thành nghĩa là thêm một vài ví dụ rõ ràng bao quát việc tải, phân tích cú pháp và ghi các tệp JSONC, bao gồm cả quy trình định dạng và chỉnh sửa được trình bày.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Already asked in https://github.com/microsoft/node-jsonc-parser/issues/74, but it was closed by the author.
The request still stands, it would be great to have a few examples to use the library to load/parse/write JSONC files.
I shouldn't need to ask LLMs how to use something, but thankfully it helped. Here's my tsconfig.json reference sorter:
import { readFile, writeFile } from "node:fs/promises";
import * as jsonc from "jsonc-parser";
const editsOptions = {
formattingOptions: { tabSize: 2, insertSpaces: true },
};
async function sortReferences(filePath) {
const contents = await readFile(filePath, "utf8");
const json = jsonc.parse(contents);
if (!json.references) {
return;
}
json.references.sort((a, b) => a.path.localeCompare(b.path));
const edits = jsonc.modify(
contents,
["references"],
json.references,
editsOptions,
);
const newContents = jsonc.applyEdits(contents, edits);
if (contents !== newContents) {
await writeFile(filePath, newContents);
console.log(`Sorted: ${filePath}`);
}
}
for (const filePath of process.argv.slice(2)) {
void sortReferences(filePath).catch((error) => {
throw new Error(`Error sorting references in ${filePath}`, {
cause: error,
});
});
}
- Ngôn ngữ chính
- TypeScript
- Star
- 759
- Fork
- 66
- Merge trung bình
- 5 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/node-jsonc-parser
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
microsoft/node-jsonc-parser#125 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
microsoft/node-jsonc-parser#105 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
microsoft/node-jsonc-parser#103 · 2 bình luận · 8 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
microsoft/node-jsonc-parser#95 · 1 reaction ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
Tất cả issue của microsoft/node-jsonc-parser
Issue tương tự
-
Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenNSW/nsw-srilanka#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
digidem/comapeo-cloud-app#403 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100