codelaw-rules-data 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. codelaw_rules_data/LICENSE +23 -0
  2. codelaw_rules_data/NOTICE +31 -0
  3. codelaw_rules_data/README.md +130 -0
  4. codelaw_rules_data/codelaw-pack.toml +6 -0
  5. codelaw_rules_data/corpus.toml +41 -0
  6. codelaw_rules_data/data/schemas/github-action.json +1 -0
  7. codelaw_rules_data/data/schemas/github-workflow.json +1 -0
  8. codelaw_rules_data/data/schemas/package.json +1 -0
  9. codelaw_rules_data/data/schemas/pyproject.json +1 -0
  10. codelaw_rules_data/data/schemas/tsconfig.json +1 -0
  11. codelaw_rules_data/licenses/SchemaStore-Apache-2.0.txt +202 -0
  12. codelaw_rules_data/presets/data/conventions.toml +5 -0
  13. codelaw_rules_data/presets/data/github-actions.toml +6 -0
  14. codelaw_rules_data/presets/data/package-json.toml +7 -0
  15. codelaw_rules_data/presets/data/pyproject.toml +6 -0
  16. codelaw_rules_data/presets/data/recommended.toml +9 -0
  17. codelaw_rules_data/presets/data/tsconfig.toml +5 -0
  18. codelaw_rules_data/presets/md/recommended.toml +20 -0
  19. codelaw_rules_data/rules/json/no-duplicate-keys.cases.md +27 -0
  20. codelaw_rules_data/rules/json/no-duplicate-keys.md +45 -0
  21. codelaw_rules_data/rules/json/package-deps-sorted.cases.md +90 -0
  22. codelaw_rules_data/rules/json/package-deps-sorted.md +54 -0
  23. codelaw_rules_data/rules/json/package-engines.cases.md +24 -0
  24. codelaw_rules_data/rules/json/package-engines.md +45 -0
  25. codelaw_rules_data/rules/json/package-json-schema.md +57 -0
  26. codelaw_rules_data/rules/json/package-scripts-sorted.cases.md +45 -0
  27. codelaw_rules_data/rules/json/package-scripts-sorted.md +53 -0
  28. codelaw_rules_data/rules/json/tsconfig-schema.md +59 -0
  29. codelaw_rules_data/rules/json/tsconfig-strict.cases.md +57 -0
  30. codelaw_rules_data/rules/json/tsconfig-strict.md +45 -0
  31. codelaw_rules_data/rules/md/commands-show-output.cases.md +14 -0
  32. codelaw_rules_data/rules/md/commands-show-output.md +39 -0
  33. codelaw_rules_data/rules/md/descriptive-link-text.md +41 -0
  34. codelaw_rules_data/rules/md/fence-language.md +47 -0
  35. codelaw_rules_data/rules/md/first-line-heading.cases.md +28 -0
  36. codelaw_rules_data/rules/md/first-line-heading.md +46 -0
  37. codelaw_rules_data/rules/md/heading-increment.cases.md +61 -0
  38. codelaw_rules_data/rules/md/heading-increment.md +46 -0
  39. codelaw_rules_data/rules/md/link-fragments.cases.md +57 -0
  40. codelaw_rules_data/rules/md/link-fragments.md +49 -0
  41. codelaw_rules_data/rules/md/link-image-reference-definitions.cases.md +51 -0
  42. codelaw_rules_data/rules/md/link-image-reference-definitions.md +40 -0
  43. codelaw_rules_data/rules/md/no-alt-text.md +47 -0
  44. codelaw_rules_data/rules/md/no-bare-urls.cases.md +37 -0
  45. codelaw_rules_data/rules/md/no-bare-urls.md +37 -0
  46. codelaw_rules_data/rules/md/no-duplicate-heading.cases.md +19 -0
  47. codelaw_rules_data/rules/md/no-duplicate-heading.md +61 -0
  48. codelaw_rules_data/rules/md/no-emphasis-as-heading.cases.md +23 -0
  49. codelaw_rules_data/rules/md/no-emphasis-as-heading.md +49 -0
  50. codelaw_rules_data/rules/md/no-empty-links.md +50 -0
  51. codelaw_rules_data/rules/md/no-inline-html.cases.md +13 -0
  52. codelaw_rules_data/rules/md/no-inline-html.md +45 -0
  53. codelaw_rules_data/rules/md/no-reversed-links.md +33 -0
  54. codelaw_rules_data/rules/md/reference-links-images.cases.md +40 -0
  55. codelaw_rules_data/rules/md/reference-links-images.md +44 -0
  56. codelaw_rules_data/rules/md/relative-links.md +46 -0
  57. codelaw_rules_data/rules/md/single-h1.cases.md +29 -0
  58. codelaw_rules_data/rules/md/single-h1.md +57 -0
  59. codelaw_rules_data/rules/md/table-column-count.md +43 -0
  60. codelaw_rules_data/rules/toml/deps-sorted.cases.md +28 -0
  61. codelaw_rules_data/rules/toml/deps-sorted.md +49 -0
  62. codelaw_rules_data/rules/toml/no-duplicate-keys.cases.md +43 -0
  63. codelaw_rules_data/rules/toml/no-duplicate-keys.md +43 -0
  64. codelaw_rules_data/rules/toml/pyproject-requires-python.cases.md +24 -0
  65. codelaw_rules_data/rules/toml/pyproject-requires-python.md +41 -0
  66. codelaw_rules_data/rules/toml/pyproject-schema.md +55 -0
  67. codelaw_rules_data/rules/yaml/document-start.cases.md +31 -0
  68. codelaw_rules_data/rules/yaml/document-start.md +36 -0
  69. codelaw_rules_data/rules/yaml/gha-action-schema.md +59 -0
  70. codelaw_rules_data/rules/yaml/gha-pin-sha.cases.md +25 -0
  71. codelaw_rules_data/rules/yaml/gha-pin-sha.md +57 -0
  72. codelaw_rules_data/rules/yaml/gha-workflow-schema.md +57 -0
  73. codelaw_rules_data/rules/yaml/no-ambiguous-booleans.cases.md +29 -0
  74. codelaw_rules_data/rules/yaml/no-ambiguous-booleans.md +43 -0
  75. codelaw_rules_data/rules/yaml/no-ambiguous-numbers.cases.md +24 -0
  76. codelaw_rules_data/rules/yaml/no-ambiguous-numbers.md +46 -0
  77. codelaw_rules_data/rules/yaml/no-duplicate-keys.cases.md +35 -0
  78. codelaw_rules_data/rules/yaml/no-duplicate-keys.md +43 -0
  79. codelaw_rules_data/rules/yaml/no-undeclared-alias.cases.md +13 -0
  80. codelaw_rules_data/rules/yaml/no-undeclared-alias.md +46 -0
  81. codelaw_rules_data-0.2.0.dist-info/METADATA +140 -0
  82. codelaw_rules_data-0.2.0.dist-info/RECORD +84 -0
  83. codelaw_rules_data-0.2.0.dist-info/WHEEL +4 -0
  84. codelaw_rules_data-0.2.0.dist-info/licenses/LICENSE +23 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ description = "Opt-in house conventions for YAML and Markdown"
2
+
3
+ [rules]
4
+ "md/no-inline-html" = "warn"
5
+ "yaml/document-start" = "warn"
@@ -0,0 +1,6 @@
1
+ description = "Starter rules for GitHub Actions workflows and composite actions"
2
+
3
+ [rules]
4
+ "yaml/gha-action-schema" = "error"
5
+ "yaml/gha-pin-sha" = "warn"
6
+ "yaml/gha-workflow-schema" = "error"
@@ -0,0 +1,7 @@
1
+ description = "Starter rules for package.json"
2
+
3
+ [rules]
4
+ "json/package-deps-sorted" = "warn"
5
+ "json/package-engines" = "warn"
6
+ "json/package-json-schema" = "error"
7
+ "json/package-scripts-sorted" = "warn"
@@ -0,0 +1,6 @@
1
+ description = "Starter rules for pyproject.toml"
2
+
3
+ [rules]
4
+ "toml/deps-sorted" = "warn"
5
+ "toml/pyproject-requires-python" = "warn"
6
+ "toml/pyproject-schema" = "error"
@@ -0,0 +1,9 @@
1
+ description = "Correctness for JSON, YAML and TOML: keys defined twice, aliases without an anchor, and the scalars YAML 1.1 and 1.2 read differently"
2
+
3
+ [rules]
4
+ "json/no-duplicate-keys" = "error"
5
+ "toml/no-duplicate-keys" = "error"
6
+ "yaml/no-ambiguous-booleans" = "warn"
7
+ "yaml/no-ambiguous-numbers" = "warn"
8
+ "yaml/no-duplicate-keys" = "error"
9
+ "yaml/no-undeclared-alias" = "error"
@@ -0,0 +1,5 @@
1
+ description = "Starter rules for tsconfig.json"
2
+
3
+ [rules]
4
+ "json/tsconfig-schema" = "error"
5
+ "json/tsconfig-strict" = "warn"
@@ -0,0 +1,20 @@
1
+ description = "The non-layout rules of markdownlint 0.42.0's default set, reimplemented (layout belongs to the formatter), and the starter rule md/relative-links"
2
+
3
+ [rules]
4
+ "md/commands-show-output" = "warn"
5
+ "md/descriptive-link-text" = "warn"
6
+ "md/fence-language" = "warn"
7
+ "md/first-line-heading" = "warn"
8
+ "md/heading-increment" = "warn"
9
+ "md/link-fragments" = "error"
10
+ "md/link-image-reference-definitions" = "warn"
11
+ "md/no-alt-text" = "warn"
12
+ "md/no-bare-urls" = "warn"
13
+ "md/no-duplicate-heading" = "warn"
14
+ "md/no-emphasis-as-heading" = "warn"
15
+ "md/no-empty-links" = "error"
16
+ "md/no-reversed-links" = "error"
17
+ "md/reference-links-images" = "error"
18
+ "md/relative-links" = "error"
19
+ "md/single-h1" = "warn"
20
+ "md/table-column-count" = "error"
@@ -0,0 +1,27 @@
1
+ # json/no-duplicate-keys — edge cases
2
+
3
+ ### case: same key in different objects
4
+
5
+ ```json
6
+ {
7
+ "a": { "id": 1 },
8
+ "b": { "id": 2 }
9
+ }
10
+ ```
11
+
12
+ ```expect
13
+ (none)
14
+ ```
15
+
16
+ ### case: escaped spelling of the same key
17
+
18
+ ```json
19
+ {
20
+ "id": 1,
21
+ "\u0069d": 2
22
+ }
23
+ ```
24
+
25
+ ```expect
26
+ 3:3 json/no-duplicate-keys
27
+ ```
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: json/no-duplicate-keys
3
+ title: "No key twice in one JSON object"
4
+ languages: [json]
5
+ fix: manual
6
+ fix_reason: "which of the two values was meant can't be known from the file"
7
+ stability: preview
8
+ since: 0.1.0
9
+ ---
10
+
11
+ Each key appears once in a JSON object. Keys are compared by value, so `"a"` and `"\u0061"` are the same key.
12
+
13
+ **Why:** RFC 8259 leaves duplicate keys undefined: most parsers keep the last value and silently drop the first, others keep the first or refuse the file.
14
+
15
+ ```codelaw
16
+ native: json/no-duplicate-keys
17
+ ```
18
+
19
+ ## How to fix
20
+
21
+ 1. Decide which value the key should have.
22
+ 2. Delete the other entry, or move it under a key of its own.
23
+
24
+ ## Examples
25
+
26
+ ### JSON
27
+
28
+ #### Don't
29
+
30
+ ```json
31
+ {
32
+ "name": "app",
33
+ "version": "1.0.0",
34
+ "name": "web-app"
35
+ }
36
+ ```
37
+
38
+ #### Do
39
+
40
+ ```json
41
+ {
42
+ "name": "web-app",
43
+ "version": "1.0.0"
44
+ }
45
+ ```
@@ -0,0 +1,90 @@
1
+ # json/package-deps-sorted — edge cases
2
+
3
+ ### case: every list is checked, and each is fixed on its own
4
+
5
+ ```json
6
+ {
7
+ "dependencies": { "b": "1", "a": "1" },
8
+ "devDependencies": {
9
+ "vitest": "^3.0.0",
10
+ "typescript": "^5.0.0"
11
+ },
12
+ "peerDependencies": { "react": "*" }
13
+ }
14
+ ```
15
+
16
+ ```expect
17
+ 2:3 json/package-deps-sorted
18
+ 3:3 json/package-deps-sorted
19
+ ```
20
+
21
+ ```fixed
22
+ {
23
+ "dependencies": { "a": "1", "b": "1" },
24
+ "devDependencies": {
25
+ "typescript": "^5.0.0",
26
+ "vitest": "^3.0.0"
27
+ },
28
+ "peerDependencies": { "react": "*" }
29
+ }
30
+ ```
31
+
32
+ ### case: a list of bundled names
33
+
34
+ ```json
35
+ {
36
+ "bundleDependencies": ["zod", "ajv"]
37
+ }
38
+ ```
39
+
40
+ ```expect
41
+ 2:3 json/package-deps-sorted
42
+ ```
43
+
44
+ ```fixed
45
+ {
46
+ "bundleDependencies": ["ajv", "zod"]
47
+ }
48
+ ```
49
+
50
+ ### case: a comment between entries keeps the fix from running
51
+
52
+ ```json
53
+ {
54
+ "dependencies": {
55
+ "b": "1",
56
+ // pinned until the next major
57
+ "a": "1"
58
+ }
59
+ }
60
+ ```
61
+
62
+ ```expect
63
+ 2:3 json/package-deps-sorted
64
+ ```
65
+
66
+ ### case: the text around the list is untouched
67
+
68
+ ```json
69
+ {
70
+ // build tooling
71
+ "name": "x",
72
+ "dependencies": {"z": "1",
73
+ "a": "2"},
74
+ "version": "1.0.0"
75
+ }
76
+ ```
77
+
78
+ ```expect
79
+ 4:3 json/package-deps-sorted
80
+ ```
81
+
82
+ ```fixed
83
+ {
84
+ // build tooling
85
+ "name": "x",
86
+ "dependencies": {"a": "2",
87
+ "z": "1"},
88
+ "version": "1.0.0"
89
+ }
90
+ ```
@@ -0,0 +1,54 @@
1
+ ---
2
+ id: json/package-deps-sorted
3
+ title: "package.json dependency lists are sorted by name"
4
+ languages: [json]
5
+ files: ["**/package.json"]
6
+ fix: auto
7
+ stability: preview
8
+ since: 0.1.0
9
+ ---
10
+
11
+ The `dependencies`, `devDependencies`, `peerDependencies`, `optionalDependencies` and `bundleDependencies` of a `package.json` are in name order.
12
+
13
+ **Why:** npm writes these lists sorted, so a hand-added entry out of order turns into an unrelated diff the next time npm touches the file; a sorted list is also quicker to scan.
14
+
15
+ ```codelaw
16
+ target: [dependencies, devDependencies, peerDependencies, optionalDependencies, bundleDependencies, bundledDependencies]
17
+ assert: { sorted: true }
18
+ message: "Sort `$PATH` by package name"
19
+ fix: [sort-keys]
20
+ ```
21
+
22
+ ## Examples
23
+
24
+ ### JSON
25
+
26
+ #### Don't
27
+
28
+ ```json path=package.json
29
+ {
30
+ "name": "app",
31
+ "dependencies": {
32
+ "react": "^19.0.0",
33
+ "@tanstack/query": "^5.0.0",
34
+ "lodash": "^4.17.21"
35
+ }
36
+ }
37
+ ```
38
+
39
+ #### Do
40
+
41
+ ```json path=package.json
42
+ {
43
+ "name": "app",
44
+ "dependencies": {
45
+ "@tanstack/query": "^5.0.0",
46
+ "lodash": "^4.17.21",
47
+ "react": "^19.0.0"
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Notes
53
+
54
+ Names compare by Unicode code point, so scoped packages (`@scope/…`) come first. `bundleDependencies` may be a list of names; its items are sorted the same way. A list with comments between its entries is reported without a fix: the comments would be left behind while the entries move.
@@ -0,0 +1,24 @@
1
+ # json/package-engines — edge cases
2
+
3
+ ### case: engines without node
4
+
5
+ ```json
6
+ {
7
+ "engines": {
8
+ "npm": ">=10"
9
+ }
10
+ }
11
+ ```
12
+
13
+ ```expect
14
+ 2:14 json/package-engines
15
+ ```
16
+
17
+ ```fixed
18
+ {
19
+ "engines": {
20
+ "node": ">=22",
21
+ "npm": ">=10"
22
+ }
23
+ }
24
+ ```
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: json/package-engines
3
+ title: "package.json declares engines.node"
4
+ languages: [json]
5
+ files: ["**/package.json"]
6
+ fix: suggest
7
+ fix_reason: "the supported Node.js range is a project decision; the fix inserts the `node` option, which may not be the right range"
8
+ stability: preview
9
+ options:
10
+ node: { type: "string", default: ">=22", description: "the range the fix writes into `engines.node`" }
11
+ since: 0.1.0
12
+ ---
13
+
14
+ A `package.json` says which Node.js versions the package runs on, in `engines.node`.
15
+
16
+ **Why:** Without it, npm and package managers can't warn someone installing on an unsupported Node.js, and the package fails later with an error that doesn't say why.
17
+
18
+ ```codelaw
19
+ native: json/package-engines
20
+ ```
21
+
22
+ ## Examples
23
+
24
+ ### JSON
25
+
26
+ #### Don't
27
+
28
+ ```json path=package.json
29
+ {
30
+ "name": "app",
31
+ "version": "1.0.0"
32
+ }
33
+ ```
34
+
35
+ #### Do
36
+
37
+ ```json path=package.json
38
+ {
39
+ "name": "app",
40
+ "version": "1.0.0",
41
+ "engines": {
42
+ "node": ">=22"
43
+ }
44
+ }
45
+ ```
@@ -0,0 +1,57 @@
1
+ ---
2
+ id: json/package-json-schema
3
+ title: "package.json matches its schema"
4
+ languages: [json]
5
+ files: ["**/package.json"]
6
+ fix: manual
7
+ fix_reason: "a value the schema rejects is wrong in a way only its author knows how to correct"
8
+ stability: preview
9
+ ported_from: [schemastore/package.json]
10
+ since: 0.1.0
11
+ ---
12
+
13
+ A `package.json` matches SchemaStore's schema for it: every field has the type and the form npm reads, and `name` and `version` are written the way the registry accepts.
14
+
15
+ **Why:** npm and the tools that read `package.json` ignore or misread a field of the wrong shape — a `bin` that is a list, a `files` that is a string, an `engines` range that is a number — so the mistake surfaces later, far from the line that caused it.
16
+
17
+ ```codelaw
18
+ target: $
19
+ assert: { schema: schemas/package }
20
+ message: "$ERROR"
21
+ ```
22
+
23
+ ## How to fix
24
+
25
+ 1. Read the message: it names the field and the form the schema expects.
26
+ 2. Rewrite the value in that form, or remove the field if it was a mistake.
27
+ 3. Run `codelaw check` on the file again until it is clean.
28
+
29
+ ## Examples
30
+
31
+ ### JSON
32
+
33
+ #### Don't
34
+
35
+ ```json path=package.json
36
+ {
37
+ "name": "app",
38
+ "version": "1.0.0",
39
+ "files": "dist",
40
+ "private": "yes"
41
+ }
42
+ ```
43
+
44
+ #### Do
45
+
46
+ ```json path=package.json
47
+ {
48
+ "name": "app",
49
+ "version": "1.0.0",
50
+ "files": ["dist"],
51
+ "private": true
52
+ }
53
+ ```
54
+
55
+ ## Notes
56
+
57
+ The schema is SchemaStore's `package.json` schema, shipped with the pack in `data/schemas/package.json` with its descriptions removed; nothing is fetched. Fields whose schema lives in another SchemaStore file (`eslintConfig`, `prettier`, `stylelint`, `ava`, `release`, `nodemonConfig`, …) accept any value. `oneOf` is read as `anyOf`, and a pattern the engine's regular expressions can't read (look-around) accepts every value.
@@ -0,0 +1,45 @@
1
+ # json/package-scripts-sorted — edge cases
2
+
3
+ ### case: order-sensitive runner
4
+
5
+ ```json
6
+ {
7
+ "scripts": {
8
+ "build": "run-s build:*",
9
+ "build:js": "tsc",
10
+ "build:css": "sass"
11
+ }
12
+ }
13
+ ```
14
+
15
+ ```expect
16
+ (none)
17
+ ```
18
+
19
+ ### case: hooks sort next to their script
20
+
21
+ ```json
22
+ {
23
+ "scripts": {
24
+ "prepare": "husky",
25
+ "postbuild": "x",
26
+ "build": "tsc",
27
+ "prebuild": "rm -rf dist"
28
+ }
29
+ }
30
+ ```
31
+
32
+ ```expect
33
+ 2:3 json/package-scripts-sorted
34
+ ```
35
+
36
+ ```fixed
37
+ {
38
+ "scripts": {
39
+ "prebuild": "rm -rf dist",
40
+ "build": "tsc",
41
+ "postbuild": "x",
42
+ "prepare": "husky"
43
+ }
44
+ }
45
+ ```