remove redundancy in node.config schema keys
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
What is the problem this feature will solve?
Notice below how in the current schema, the namespaces "test" and "watch" are redundantly specified. This is the result of mapping the CLI args as-is.
{
"$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
"test": {
"test-concurrency": 3
"test-isolation": "process"
"test-timeout": 5000
"test-rerun-failures": true
"test-only": true
"test-force-exit": false
"test-name-pattern": "^iso"
"test-skip-pattern": "tree$"
"test-global-setup": "setup-module.mjs"
"experimental-test-coverage": true
"test-coverage-exclude": "test/**"
"test-coverage-include": "src/**"
"test-coverage-branches": 100
"test-coverage-functions": 100
"test-coverage-lines": 100
"test-reporter": ["dot", "spec", "lcov"]
"test-reporter-destination": ["stdout", "test.report", "lcov.info"]
"experimental-test-module-mocks": true
"test-update-snapshots": true
},
"watch": {
"watch-preserve-output": true
"watch-path": "./src"
}
}
What is the feature you are proposing to solve the problem?
Instead, the namespace part of the CLI arg could automatically be mapped to a namespace within the config schema:
{
"$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
"test": {
"concurrency": 3
"isolation": "process"
"timeout": 5000
"rerun-failures": true
"only": true
"force-exit": false
"name-pattern": "^iso"
"skip-pattern": "tree$"
"global-setup": "setup-module.mjs"
"experimental-coverage": true
"coverage-exclude": "test/**"
"coverage-include": "src/**"
"coverage-branches": 100
"coverage-functions": 100
"coverage-lines": 100
"reporter": ["dot", "spec", "lcov"]
"reporter-destination": ["stdout", "test.report", "lcov.info"]
"experimental-module-mocks": true
"test-update-snapshots": true
},
"watch": {
"preserve-output": true
"path": "./src"
}
}
Note that for "experimental-" CLI args, the mapped namespace occurs after that prefix.
We can take it a step further, apply the idea recursively, as below. This has the added of benefit fixing how destinations are specified when there are multiple test reporters.
{
"$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
"test": {
"concurrency": 3
"isolation": "process"
"timeout": 5000
"rerun-failures": true
"only": true
"force-exit": false
"name-pattern": "^iso"
"skip-pattern": "tree$"
"global-setup": "setup-module.mjs"
"experimental-coverage": {
"exclude": "test/**"
"include": "src/**"
"branches": 100
"functions": 100
"lines": 100
}
"reporter": {
"dot": {"destination": "stdout"}
"spec": {"destination": "test.report"}
"lcov": {"destination": "lcov.info"}
}
"experimental-module-mocks": true
"update-snapshots": true
},
"watch": {
"preserve-output": true
"path": "./src"
}
}
What alternatives have you considered?
No response
Hướng dẫn đóng góp
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.
Hướng nghiên cứu
Bắt đầu bằng cách lần theo ánh xạ từ đối số CLI của Node sang config schema và so sánh cách các khóa test và watch hiện tại được tạo. Các ví dụ của issue xác định kết quả mong muốn: cần loại bỏ các tiền tố namespace, xử lý các tùy chọn experimental sau tiền tố của chúng và ánh xạ đệ quy các đích reporter lồng nhau.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- cli, developer-experience
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100