@geonosis/oxlint-plugin-biological-architecture 3.1.0 → 3.3.0
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.
- package/CHANGELOG.md +57 -0
- package/README.md +75 -6
- package/RULES.md +202 -101
- package/corpus/.oxlintrc.json +5 -0
- package/corpus/data/bad-dynamic-orm.ts +5 -0
- package/corpus/data/bad-type-only-orm.ts +3 -0
- package/corpus/e2e/bad-list-response.spec.ts +5 -0
- package/corpus/e2e/bad-timeout.spec.ts +5 -0
- package/corpus/e2e/good-detail-response.spec.ts +5 -0
- package/corpus/e2e/good-state.spec.ts +5 -0
- package/corpus/manifest.json +2 -0
- package/corpus/medusa/queries/bad-silent-cap.ts +11 -0
- package/corpus/medusa/queries/good-paged-through.ts +19 -0
- package/corpus/medusa/queries/integration-tests/any-row.ts +10 -0
- package/corpus/tissues/bad-awaits-data.tsx +8 -0
- package/corpus/tissues/bad-fetches-data.tsx +7 -0
- package/corpus/tissues/good-takes-products.tsx +5 -0
- package/dist/discover-atoms.d.ts +2 -37
- package/dist/discover-atoms.js +1 -104
- package/dist/index.d.ts +3 -12
- package/dist/index.js +21 -176
- package/dist/presets.d.ts +11 -19
- package/dist/presets.js +94 -4
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +172 -0
- package/dist/rules/atom-no-deps.d.ts +1 -0
- package/dist/rules/atom-no-deps.js +10 -11
- package/dist/rules/boundary-time-is-primitive.d.ts +0 -7
- package/dist/rules/cell-must-be-stateful.d.ts +2 -2
- package/dist/rules/cell-must-be-stateful.js +24 -23
- package/dist/rules/cell-must-not-compose-cell.d.ts +1 -0
- package/dist/rules/cell-must-not-compose-cell.js +10 -3
- package/dist/rules/cell-no-cross-feature-organelles.d.ts +1 -0
- package/dist/rules/cell-no-cross-feature-organelles.js +7 -0
- package/dist/rules/cell-no-tissues.d.ts +1 -0
- package/dist/rules/cell-no-tissues.js +11 -7
- package/dist/rules/cells-folder-index-is-barrel.d.ts +12 -10
- package/dist/rules/cells-folder-index-is-barrel.js +66 -34
- package/dist/rules/compound-must-be-stateless.d.ts +2 -0
- package/dist/rules/compound-must-be-stateless.js +24 -26
- package/dist/rules/compound-no-stores.d.ts +1 -0
- package/dist/rules/compound-no-stores.js +12 -10
- package/dist/rules/constants-in-constants-file.d.ts +2 -8
- package/dist/rules/constants-in-constants-file.js +5 -6
- package/dist/rules/dialect-through-the-seam.d.ts +0 -13
- package/dist/rules/durable-body-reads-through-steps.d.ts +0 -14
- package/dist/rules/durable-body-reads-through-steps.js +8 -3
- package/dist/rules/effect-hook-naming.d.ts +9 -11
- package/dist/rules/effect-hook-naming.js +33 -31
- package/dist/rules/emit-declares-attempts.d.ts +0 -17
- package/dist/rules/emit-declares-attempts.js +5 -10
- package/dist/rules/font-roles-only.d.ts +0 -18
- package/dist/rules/font-roles-only.js +19 -22
- package/dist/rules/hermetic-e2e-no-wall-clock-waits.d.ts +53 -0
- package/dist/rules/hermetic-e2e-no-wall-clock-waits.js +100 -0
- package/dist/rules/icon-control-has-name.js +7 -1
- package/dist/rules/layer-walls.d.ts +0 -25
- package/dist/rules/layer-walls.js +7 -13
- package/dist/rules/lib/atom-map.d.ts +24 -0
- package/dist/rules/lib/atom-map.js +16 -0
- package/dist/rules/lib/cells-barrel.d.ts +0 -1
- package/dist/rules/lib/colors.d.ts +0 -19
- package/dist/rules/lib/colors.js +10 -243
- package/dist/rules/lib/comments.d.ts +19 -0
- package/dist/rules/lib/comments.js +5 -0
- package/dist/rules/lib/context.d.ts +0 -10
- package/dist/rules/lib/direction-rule.d.ts +4 -21
- package/dist/rules/lib/direction-rule.js +25 -4
- package/dist/rules/lib/doors.d.ts +2 -18
- package/dist/rules/lib/doors.js +81 -41
- package/dist/rules/lib/fresh.d.ts +5 -0
- package/dist/rules/lib/fresh.js +15 -0
- package/dist/rules/lib/hooks.d.ts +2 -17
- package/dist/rules/lib/hooks.js +14 -9
- package/dist/rules/lib/imports.d.ts +2 -23
- package/dist/rules/lib/imports.js +7 -2
- package/dist/rules/lib/jsx.d.ts +31 -0
- package/dist/rules/lib/jsx.js +11 -0
- package/dist/rules/lib/landing.d.ts +0 -40
- package/dist/rules/lib/literal-call.d.ts +1 -0
- package/dist/rules/lib/literal-call.js +2 -0
- package/dist/rules/lib/module-text.d.ts +3 -27
- package/dist/rules/lib/module-text.js +19 -4
- package/dist/rules/lib/mutations.d.ts +0 -14
- package/dist/rules/lib/nodes.d.ts +1 -18
- package/dist/rules/lib/nodes.js +1 -0
- package/dist/rules/lib/objects.d.ts +2 -11
- package/dist/rules/lib/objects.js +21 -0
- package/dist/rules/lib/options.d.ts +3 -52
- package/dist/rules/lib/options.js +49 -18
- package/dist/rules/lib/package-imports.d.ts +0 -5
- package/dist/rules/lib/package-imports.js +4 -10
- package/dist/rules/lib/paths.d.ts +15 -41
- package/dist/rules/lib/paths.js +34 -1
- package/dist/rules/lib/pattern-match.d.ts +2 -12
- package/dist/rules/lib/pattern-match.js +5 -1
- package/dist/rules/lib/probe.d.ts +0 -43
- package/dist/rules/lib/reexports.d.ts +0 -18
- package/dist/rules/lib/render-tracking.d.ts +0 -8
- package/dist/rules/lib/run-files.d.ts +18 -0
- package/dist/rules/lib/run-files.js +144 -0
- package/dist/rules/lib/shared-features.d.ts +0 -8
- package/dist/rules/lib/shared-features.js +2 -9
- package/dist/rules/lib/state-sources.d.ts +8 -0
- package/dist/rules/lib/state-sources.js +55 -0
- package/dist/rules/lib/steps.d.ts +3 -5
- package/dist/rules/lib/steps.js +6 -1
- package/dist/rules/lib/styling.d.ts +9 -42
- package/dist/rules/lib/styling.js +36 -10
- package/dist/rules/lib/tiers.d.ts +11 -24
- package/dist/rules/lib/tiers.js +41 -1
- package/dist/rules/lib/tissue-entrypoint.d.ts +0 -1
- package/dist/rules/lib/tissue-entrypoint.js +4 -5
- package/dist/rules/lib/token-layer.d.ts +19 -0
- package/dist/rules/lib/token-layer.js +170 -0
- package/dist/rules/lib/tsconfig-paths.d.ts +0 -4
- package/dist/rules/lib/tsconfig-paths.js +47 -15
- package/dist/rules/lib/type-members.d.ts +6 -0
- package/dist/rules/lib/type-members.js +165 -0
- package/dist/rules/lib/visitors.d.ts +0 -22
- package/dist/rules/lib/workspace-members.d.ts +2 -0
- package/dist/rules/lib/workspace-members.js +113 -0
- package/dist/rules/list-take-without-order.d.ts +24 -0
- package/dist/rules/list-take-without-order.js +293 -16
- package/dist/rules/max-comment-density.d.ts +3 -18
- package/dist/rules/max-comment-density.js +3 -3
- package/dist/rules/molecule-atoms-only.d.ts +1 -0
- package/dist/rules/molecule-atoms-only.js +11 -7
- package/dist/rules/molecule-must-compose.d.ts +2 -0
- package/dist/rules/molecule-must-compose.js +17 -21
- package/dist/rules/mutating-step-declares-retry.d.ts +2 -7
- package/dist/rules/mutating-step-declares-retry.js +29 -11
- package/dist/rules/named-when-block.d.ts +0 -2
- package/dist/rules/named-when-block.js +2 -8
- package/dist/rules/next-route-segment-is-thin-delegate.d.ts +4 -19
- package/dist/rules/next-route-segment-is-thin-delegate.js +47 -71
- package/dist/rules/no-brand-names.d.ts +0 -9
- package/dist/rules/no-brand-names.js +1 -1
- package/dist/rules/no-card-shaped-div.d.ts +4 -42
- package/dist/rules/no-card-shaped-div.js +12 -4
- package/dist/rules/no-cross-feature-stores.d.ts +1 -0
- package/dist/rules/no-cross-feature-stores.js +9 -5
- package/dist/rules/no-d1-transaction.d.ts +2 -5
- package/dist/rules/no-d1-transaction.js +7 -0
- package/dist/rules/no-date-string-compare.d.ts +2 -0
- package/dist/rules/no-date-string-compare.js +14 -8
- package/dist/rules/no-duplicate-jsx-patterns.d.ts +3 -1
- package/dist/rules/no-duplicate-jsx-patterns.js +16 -1
- package/dist/rules/no-generic-utility-package.d.ts +48 -2
- package/dist/rules/no-generic-utility-package.js +48 -9
- package/dist/rules/no-hook-in-component-disguise.d.ts +27 -13
- package/dist/rules/no-hook-in-component-disguise.js +38 -30
- package/dist/rules/no-index-count-as-exact.d.ts +0 -3
- package/dist/rules/no-inert-hidden-jsx.d.ts +4 -21
- package/dist/rules/no-inert-hidden-jsx.js +13 -12
- package/dist/rules/no-inline-data-in-jsx.d.ts +2 -0
- package/dist/rules/no-inline-data-in-jsx.js +17 -2
- package/dist/rules/no-invalid-feature-folders.d.ts +2 -0
- package/dist/rules/no-invalid-feature-folders.js +12 -4
- package/dist/rules/no-loader-side-effect-in-index-file.d.ts +2 -9
- package/dist/rules/no-logic-in-component-files.d.ts +6 -5
- package/dist/rules/no-logic-in-component-files.js +52 -31
- package/dist/rules/no-mock-db-in-integration.d.ts +0 -15
- package/dist/rules/no-mock-db-in-integration.js +3 -4
- package/dist/rules/no-orm-outside-db.d.ts +1 -0
- package/dist/rules/no-orm-outside-db.js +10 -7
- package/dist/rules/no-raw-html-atoms.d.ts +3 -22
- package/dist/rules/no-raw-html-atoms.js +5 -17
- package/dist/rules/no-raw-sql-outside-allowed.d.ts +2 -0
- package/dist/rules/no-raw-sql-outside-allowed.js +10 -15
- package/dist/rules/no-react-namespace.d.ts +2 -0
- package/dist/rules/no-react-namespace.js +13 -0
- package/dist/rules/no-renamed-html-props.d.ts +2 -0
- package/dist/rules/no-renamed-html-props.js +11 -2
- package/dist/rules/no-render-prop-reader.d.ts +4 -20
- package/dist/rules/no-render-prop-reader.js +13 -5
- package/dist/rules/no-runtime-dead-affordance.d.ts +3 -26
- package/dist/rules/no-runtime-dead-affordance.js +7 -20
- package/dist/rules/no-swallowed-catch.js +2 -8
- package/dist/rules/no-trivial-wrapper-component.d.ts +4 -19
- package/dist/rules/no-trivial-wrapper-component.js +24 -33
- package/dist/rules/no-ts-in-bio-folders.d.ts +2 -13
- package/dist/rules/no-ts-in-bio-folders.js +9 -7
- package/dist/rules/no-type-definitions-in-components.d.ts +2 -0
- package/dist/rules/no-type-definitions-in-components.js +12 -1
- package/dist/rules/no-unregistered-plugin-dir.d.ts +0 -41
- package/dist/rules/no-unregistered-plugin-dir.js +1 -9
- package/dist/rules/no-void-port.d.ts +2 -4
- package/dist/rules/no-void-port.js +7 -0
- package/dist/rules/organelle-dependency.d.ts +1 -0
- package/dist/rules/organelle-dependency.js +10 -8
- package/dist/rules/organelle-single-source.d.ts +2 -0
- package/dist/rules/organelle-single-source.js +58 -9
- package/dist/rules/plugin-route-namespaced.d.ts +0 -11
- package/dist/rules/plugin-route-namespaced.js +2 -2
- package/dist/rules/queries-require-org-scope.d.ts +0 -3
- package/dist/rules/queries-require-org-scope.js +3 -10
- package/dist/rules/queue-loop-is-the-library.js +3 -2
- package/dist/rules/route-no-inline-mutation.d.ts +1 -25
- package/dist/rules/route-no-inline-mutation.js +2 -7
- package/dist/rules/router-schema-parity.d.ts +0 -9
- package/dist/rules/router-schema-parity.js +5 -9
- package/dist/rules/service-name-not-reserved.d.ts +0 -3
- package/dist/rules/service-name-not-reserved.js +1 -34
- package/dist/rules/ssot-no-inline-facts.js +2 -5
- package/dist/rules/ssot-no-process-env.js +4 -12
- package/dist/rules/step-declares-compensation-or-none.d.ts +2 -1
- package/dist/rules/step-declares-compensation-or-none.js +17 -1
- package/dist/rules/step-opens-its-own-cell.d.ts +3 -26
- package/dist/rules/step-opens-its-own-cell.js +8 -13
- package/dist/rules/store-route-scopes-tenant-data.js +8 -26
- package/dist/rules/subpath-over-barrel.d.ts +3 -10
- package/dist/rules/subpath-over-barrel.js +55 -10
- package/dist/rules/subscriber-declares-id.d.ts +0 -2
- package/dist/rules/subscriber-declares-id.js +2 -8
- package/dist/rules/tables-declare-their-plane.d.ts +0 -2
- package/dist/rules/tables-declare-their-plane.js +4 -10
- package/dist/rules/tenant-tables-carry-org-id.d.ts +1 -4
- package/dist/rules/tenant-tables-carry-org-id.js +5 -12
- package/dist/rules/test-no-clock-polling-for-promise-flips.d.ts +7 -1
- package/dist/rules/test-no-clock-polling-for-promise-flips.js +21 -1
- package/dist/rules/time-through-the-door.d.ts +0 -24
- package/dist/rules/time-through-the-door.js +5 -5
- package/dist/rules/tissue-must-compose.d.ts +4 -2
- package/dist/rules/tissue-must-compose.js +25 -20
- package/dist/rules/tissue-no-data-props.d.ts +57 -1
- package/dist/rules/tissue-no-data-props.js +114 -32
- package/dist/rules/tissue-no-fetch.d.ts +26 -0
- package/dist/rules/tissue-no-fetch.js +57 -0
- package/dist/rules/tissue-no-hooks.d.ts +21 -23
- package/dist/rules/tissue-no-hooks.js +22 -4
- package/dist/rules/tissue-no-organelles.d.ts +1 -0
- package/dist/rules/tissue-no-organelles.js +9 -1
- package/dist/rules/tissue-no-stores.d.ts +1 -0
- package/dist/rules/tissue-no-stores.js +9 -1
- package/dist/rules/todo-names-its-plan.d.ts +1 -28
- package/dist/rules/todo-names-its-plan.js +2 -2
- package/dist/rules/tokens-only-colors.d.ts +8 -46
- package/dist/rules/tokens-only-colors.js +64 -20
- package/dist/rules/unique-query-step-name.d.ts +0 -7
- package/dist/rules/unique-query-step-name.js +6 -10
- package/dist/rules/worker-handles-are-scoped.d.ts +11 -8
- package/dist/rules/worker-handles-are-scoped.js +12 -5
- package/dist/rules/zustand-v5-best-practices.d.ts +8 -18
- package/dist/rules/zustand-v5-best-practices.js +32 -56
- package/dist/timing.d.ts +18 -0
- package/dist/timing.js +75 -0
- package/package.json +2 -2
package/dist/rules/lib/colors.js
CHANGED
|
@@ -1,257 +1,24 @@
|
|
|
1
1
|
// src/rules/lib/colors.ts
|
|
2
|
-
var
|
|
3
|
-
"color",
|
|
4
|
-
"color-mix",
|
|
5
|
-
"hsl",
|
|
6
|
-
"hsla",
|
|
7
|
-
"hwb",
|
|
8
|
-
"lab",
|
|
9
|
-
"lch",
|
|
10
|
-
"oklab",
|
|
11
|
-
"oklch",
|
|
12
|
-
"rgb",
|
|
13
|
-
"rgba"
|
|
14
|
-
];
|
|
2
|
+
var words = (list) => new Set(list.split(" "));
|
|
15
3
|
var HEX = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
16
|
-
var
|
|
4
|
+
var FUNCTION_NAMES = "color|color-mix|hsl|hsla|hwb|lab|lch|oklab|oklch|rgb|rgba";
|
|
5
|
+
var FUNCTION_CALL = new RegExp(`\\b(?:${FUNCTION_NAMES})\\(`, "i");
|
|
6
|
+
var FUNCTION_START = new RegExp(`^(?:${FUNCTION_NAMES})\\(`, "i");
|
|
17
7
|
var HEX_ANYWHERE = /(?:^|[\s(,])#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})\b/i;
|
|
18
|
-
var NAMED =
|
|
19
|
-
"aliceblue",
|
|
20
|
-
"antiquewhite",
|
|
21
|
-
"aqua",
|
|
22
|
-
"aquamarine",
|
|
23
|
-
"azure",
|
|
24
|
-
"beige",
|
|
25
|
-
"bisque",
|
|
26
|
-
"black",
|
|
27
|
-
"blanchedalmond",
|
|
28
|
-
"blue",
|
|
29
|
-
"blueviolet",
|
|
30
|
-
"brown",
|
|
31
|
-
"burlywood",
|
|
32
|
-
"cadetblue",
|
|
33
|
-
"chartreuse",
|
|
34
|
-
"chocolate",
|
|
35
|
-
"coral",
|
|
36
|
-
"cornflowerblue",
|
|
37
|
-
"cornsilk",
|
|
38
|
-
"crimson",
|
|
39
|
-
"cyan",
|
|
40
|
-
"darkblue",
|
|
41
|
-
"darkcyan",
|
|
42
|
-
"darkgoldenrod",
|
|
43
|
-
"darkgray",
|
|
44
|
-
"darkgreen",
|
|
45
|
-
"darkgrey",
|
|
46
|
-
"darkkhaki",
|
|
47
|
-
"darkmagenta",
|
|
48
|
-
"darkolivegreen",
|
|
49
|
-
"darkorange",
|
|
50
|
-
"darkorchid",
|
|
51
|
-
"darkred",
|
|
52
|
-
"darksalmon",
|
|
53
|
-
"darkseagreen",
|
|
54
|
-
"darkslateblue",
|
|
55
|
-
"darkslategray",
|
|
56
|
-
"darkslategrey",
|
|
57
|
-
"darkturquoise",
|
|
58
|
-
"darkviolet",
|
|
59
|
-
"deeppink",
|
|
60
|
-
"deepskyblue",
|
|
61
|
-
"dimgray",
|
|
62
|
-
"dimgrey",
|
|
63
|
-
"dodgerblue",
|
|
64
|
-
"firebrick",
|
|
65
|
-
"floralwhite",
|
|
66
|
-
"forestgreen",
|
|
67
|
-
"fuchsia",
|
|
68
|
-
"gainsboro",
|
|
69
|
-
"ghostwhite",
|
|
70
|
-
"gold",
|
|
71
|
-
"goldenrod",
|
|
72
|
-
"gray",
|
|
73
|
-
"green",
|
|
74
|
-
"greenyellow",
|
|
75
|
-
"grey",
|
|
76
|
-
"honeydew",
|
|
77
|
-
"hotpink",
|
|
78
|
-
"indianred",
|
|
79
|
-
"indigo",
|
|
80
|
-
"ivory",
|
|
81
|
-
"khaki",
|
|
82
|
-
"lavender",
|
|
83
|
-
"lavenderblush",
|
|
84
|
-
"lawngreen",
|
|
85
|
-
"lemonchiffon",
|
|
86
|
-
"lightblue",
|
|
87
|
-
"lightcoral",
|
|
88
|
-
"lightcyan",
|
|
89
|
-
"lightgoldenrodyellow",
|
|
90
|
-
"lightgray",
|
|
91
|
-
"lightgreen",
|
|
92
|
-
"lightgrey",
|
|
93
|
-
"lightpink",
|
|
94
|
-
"lightsalmon",
|
|
95
|
-
"lightseagreen",
|
|
96
|
-
"lightskyblue",
|
|
97
|
-
"lightslategray",
|
|
98
|
-
"lightslategrey",
|
|
99
|
-
"lightsteelblue",
|
|
100
|
-
"lightyellow",
|
|
101
|
-
"lime",
|
|
102
|
-
"limegreen",
|
|
103
|
-
"linen",
|
|
104
|
-
"magenta",
|
|
105
|
-
"maroon",
|
|
106
|
-
"mediumaquamarine",
|
|
107
|
-
"mediumblue",
|
|
108
|
-
"mediumorchid",
|
|
109
|
-
"mediumpurple",
|
|
110
|
-
"mediumseagreen",
|
|
111
|
-
"mediumslateblue",
|
|
112
|
-
"mediumspringgreen",
|
|
113
|
-
"mediumturquoise",
|
|
114
|
-
"mediumvioletred",
|
|
115
|
-
"midnightblue",
|
|
116
|
-
"mintcream",
|
|
117
|
-
"mistyrose",
|
|
118
|
-
"moccasin",
|
|
119
|
-
"navajowhite",
|
|
120
|
-
"navy",
|
|
121
|
-
"oldlace",
|
|
122
|
-
"olive",
|
|
123
|
-
"olivedrab",
|
|
124
|
-
"orange",
|
|
125
|
-
"orangered",
|
|
126
|
-
"orchid",
|
|
127
|
-
"palegoldenrod",
|
|
128
|
-
"palegreen",
|
|
129
|
-
"paleturquoise",
|
|
130
|
-
"palevioletred",
|
|
131
|
-
"papayawhip",
|
|
132
|
-
"peachpuff",
|
|
133
|
-
"peru",
|
|
134
|
-
"pink",
|
|
135
|
-
"plum",
|
|
136
|
-
"powderblue",
|
|
137
|
-
"purple",
|
|
138
|
-
"rebeccapurple",
|
|
139
|
-
"red",
|
|
140
|
-
"rosybrown",
|
|
141
|
-
"royalblue",
|
|
142
|
-
"saddlebrown",
|
|
143
|
-
"salmon",
|
|
144
|
-
"sandybrown",
|
|
145
|
-
"seagreen",
|
|
146
|
-
"seashell",
|
|
147
|
-
"sienna",
|
|
148
|
-
"silver",
|
|
149
|
-
"skyblue",
|
|
150
|
-
"slateblue",
|
|
151
|
-
"slategray",
|
|
152
|
-
"slategrey",
|
|
153
|
-
"snow",
|
|
154
|
-
"springgreen",
|
|
155
|
-
"steelblue",
|
|
156
|
-
"tan",
|
|
157
|
-
"teal",
|
|
158
|
-
"thistle",
|
|
159
|
-
"tomato",
|
|
160
|
-
"turquoise",
|
|
161
|
-
"violet",
|
|
162
|
-
"wheat",
|
|
163
|
-
"white",
|
|
164
|
-
"whitesmoke",
|
|
165
|
-
"yellow",
|
|
166
|
-
"yellowgreen"
|
|
167
|
-
]);
|
|
8
|
+
var NAMED = words("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen");
|
|
168
9
|
var isColorLiteral = (value) => {
|
|
169
10
|
const trimmed = value.trim();
|
|
170
11
|
if (trimmed === "")
|
|
171
12
|
return false;
|
|
172
|
-
|
|
173
|
-
return true;
|
|
174
|
-
if (NAMED.has(trimmed.toLowerCase()))
|
|
175
|
-
return true;
|
|
176
|
-
return new RegExp(`^(?:${FUNCTIONS.join("|")})\\(`, "i").test(trimmed);
|
|
13
|
+
return HEX.test(trimmed) || NAMED.has(trimmed.toLowerCase()) || FUNCTION_START.test(trimmed);
|
|
177
14
|
};
|
|
178
15
|
var containsColorLiteral = (value) => HEX_ANYWHERE.test(value) || FUNCTION_CALL.test(value);
|
|
179
|
-
var COLOR_PROPERTIES =
|
|
180
|
-
|
|
181
|
-
"backgroundColor",
|
|
182
|
-
"borderBlockColor",
|
|
183
|
-
"borderBlockEndColor",
|
|
184
|
-
"borderBlockStartColor",
|
|
185
|
-
"borderBottomColor",
|
|
186
|
-
"borderColor",
|
|
187
|
-
"borderInlineColor",
|
|
188
|
-
"borderInlineEndColor",
|
|
189
|
-
"borderInlineStartColor",
|
|
190
|
-
"borderLeftColor",
|
|
191
|
-
"borderRightColor",
|
|
192
|
-
"borderTopColor",
|
|
193
|
-
"caretColor",
|
|
194
|
-
"color",
|
|
195
|
-
"columnRuleColor",
|
|
196
|
-
"fill",
|
|
197
|
-
"floodColor",
|
|
198
|
-
"lightingColor",
|
|
199
|
-
"outlineColor",
|
|
200
|
-
"stopColor",
|
|
201
|
-
"stroke",
|
|
202
|
-
"textDecorationColor",
|
|
203
|
-
"textEmphasisColor",
|
|
204
|
-
"WebkitTextFillColor",
|
|
205
|
-
"WebkitTextStrokeColor",
|
|
206
|
-
"webkitTextFillColor",
|
|
207
|
-
"webkitTextStrokeColor"
|
|
208
|
-
]);
|
|
209
|
-
var COLOR_SHORTHANDS = new Set([
|
|
210
|
-
"background",
|
|
211
|
-
"border",
|
|
212
|
-
"borderBottom",
|
|
213
|
-
"borderLeft",
|
|
214
|
-
"borderRight",
|
|
215
|
-
"borderTop",
|
|
216
|
-
"boxShadow",
|
|
217
|
-
"columnRule",
|
|
218
|
-
"filter",
|
|
219
|
-
"outline",
|
|
220
|
-
"textDecoration",
|
|
221
|
-
"textShadow"
|
|
222
|
-
]);
|
|
16
|
+
var COLOR_PROPERTIES = words("accentColor backgroundColor borderBlockColor borderBlockEndColor borderBlockStartColor borderBottomColor borderColor borderInlineColor borderInlineEndColor borderInlineStartColor borderLeftColor borderRightColor borderTopColor caretColor color columnRuleColor fill floodColor lightingColor outlineColor stopColor stroke textDecorationColor textEmphasisColor WebkitTextFillColor WebkitTextStrokeColor webkitTextFillColor webkitTextStrokeColor");
|
|
17
|
+
var COLOR_SHORTHANDS = words("background border borderBottom borderLeft borderRight borderTop boxShadow columnRule filter outline textDecoration textShadow");
|
|
223
18
|
var isColorProperty = (property) => COLOR_PROPERTIES.has(property);
|
|
224
19
|
var isColorShorthand = (property) => COLOR_SHORTHANDS.has(property);
|
|
225
|
-
var COLOR_UTILITIES =
|
|
226
|
-
|
|
227
|
-
"bg",
|
|
228
|
-
"border",
|
|
229
|
-
"border-b",
|
|
230
|
-
"border-e",
|
|
231
|
-
"border-l",
|
|
232
|
-
"border-r",
|
|
233
|
-
"border-s",
|
|
234
|
-
"border-t",
|
|
235
|
-
"border-x",
|
|
236
|
-
"border-y",
|
|
237
|
-
"caret",
|
|
238
|
-
"decoration",
|
|
239
|
-
"divide",
|
|
240
|
-
"fill",
|
|
241
|
-
"from",
|
|
242
|
-
"inset-ring",
|
|
243
|
-
"inset-shadow",
|
|
244
|
-
"outline",
|
|
245
|
-
"placeholder",
|
|
246
|
-
"ring",
|
|
247
|
-
"ring-offset",
|
|
248
|
-
"shadow",
|
|
249
|
-
"stroke",
|
|
250
|
-
"text",
|
|
251
|
-
"to",
|
|
252
|
-
"via"
|
|
253
|
-
]);
|
|
254
|
-
var isColorUtility = (utility) => COLOR_UTILITIES.has(utility.replace(/^.*:/, ""));
|
|
20
|
+
var COLOR_UTILITIES = words("accent bg border border-b border-e border-l border-r border-s border-t border-x border-y caret decoration divide fill from inset-ring inset-shadow outline placeholder ring ring-offset shadow stroke text to via");
|
|
21
|
+
var isColorUtility = (utility) => COLOR_UTILITIES.has(utility);
|
|
255
22
|
export {
|
|
256
23
|
containsColorLiteral,
|
|
257
24
|
isColorLiteral,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Comment = {
|
|
2
|
+
loc: {
|
|
3
|
+
end: {
|
|
4
|
+
line: number;
|
|
5
|
+
};
|
|
6
|
+
start: {
|
|
7
|
+
line: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export type SourceCode = {
|
|
14
|
+
ast?: {
|
|
15
|
+
comments?: Comment[];
|
|
16
|
+
};
|
|
17
|
+
getAllComments?: () => Comment[];
|
|
18
|
+
};
|
|
19
|
+
export declare const commentsOf: (sourceCode: SourceCode | undefined) => Comment[];
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `create(context)` parameter every rule hand-typed for itself.
|
|
3
|
-
*
|
|
4
|
-
* Fifty-six rules wrote out `{ filename: string; report: (descriptor: { data, messageId, node }) =>
|
|
5
|
-
* void }` themselves — sometimes with the descriptor's fields in a different order, sometimes with
|
|
6
|
-
* the parameter named `d` instead of `descriptor` — because oxlint's plugin API hands `create` a
|
|
7
|
-
* plain object and names nothing a rule can import. One shape, named once.
|
|
8
|
-
*/
|
|
9
1
|
type ReportDescriptor = {
|
|
10
2
|
data: Record<string, string>;
|
|
11
3
|
messageId: string;
|
|
@@ -15,11 +7,9 @@ export type RuleContext = {
|
|
|
15
7
|
filename: string;
|
|
16
8
|
report: (descriptor: ReportDescriptor) => void;
|
|
17
9
|
};
|
|
18
|
-
/** A rule whose schema is read, so oxlint hands it whatever the config named for it. */
|
|
19
10
|
export type RuleContextWithOptions<Options> = RuleContext & {
|
|
20
11
|
options?: [Options?];
|
|
21
12
|
};
|
|
22
|
-
/** A rule that reads its own options bag through `bagOf`, rather than a typed positional tuple. */
|
|
23
13
|
export type RuleContextWithRawOptions = RuleContext & {
|
|
24
14
|
options: readonly unknown[];
|
|
25
15
|
};
|
|
@@ -1,42 +1,24 @@
|
|
|
1
|
+
import { type Probe, type ProbeTree } from './probe.js';
|
|
1
2
|
import { type Tier } from './tiers.js';
|
|
2
3
|
import { type Visitor } from './visitors.js';
|
|
3
|
-
/**
|
|
4
|
-
* Ten of this plugin's rules said the same sentence: files HERE may not import things THERE. Each
|
|
5
|
-
* one wrote its own scope test, its own source parse, its own visitor set and its own loop, and the
|
|
6
|
-
* differences between them were not decisions — they were the order the rules happened to be
|
|
7
|
-
* written in. One rule watched three node types and its neighbour four; one resolved a relative
|
|
8
|
-
* source and its neighbour was blind to it; two counted type-only imports and the rest did not.
|
|
9
|
-
*
|
|
10
|
-
* So a direction rule is DATA now: which files it polices, which targets are forbidden, and what it
|
|
11
|
-
* says. Everything mechanical — reading the filename, reading the source, which doors to watch —
|
|
12
|
-
* happens once, here, where a fix reaches all ten.
|
|
13
|
-
*/
|
|
14
|
-
/** A file or an import source, said in the terms a direction rule judges by. */
|
|
15
4
|
type Classified = {
|
|
16
|
-
/** The last segment, as a diagnostic names it. */
|
|
17
5
|
file: string;
|
|
18
|
-
/** The feature it belongs to, if the layout has features. */
|
|
19
6
|
feature: string | undefined;
|
|
20
|
-
/** The path it is at — normalised, and for a relative source, resolved against the importer. */
|
|
21
7
|
path: string;
|
|
22
|
-
/** The source exactly as it was written, for the message and for a rule that matches on it. */
|
|
23
8
|
source: string;
|
|
24
|
-
/** The tier it sits in, if any. */
|
|
25
9
|
tier: Tier | undefined;
|
|
26
10
|
};
|
|
27
11
|
export declare const classify: (path: string, source?: string) => Classified;
|
|
28
12
|
type Declaration<Options> = {
|
|
29
|
-
/** The message data, when `{ file, source }` is not what the message names. */
|
|
30
13
|
data?: (target: Classified, importer: Classified) => Record<string, string>;
|
|
31
14
|
description: string;
|
|
32
15
|
fixShape: string;
|
|
33
|
-
/** True when this import is a breach. */
|
|
34
16
|
forbidden: (target: Classified, importer: Classified, options: Options) => boolean;
|
|
35
|
-
|
|
17
|
+
mayForbid?: (source: string) => boolean;
|
|
36
18
|
messageId?: string;
|
|
19
|
+
probe?: (options: readonly unknown[]) => Probe | ProbeTree;
|
|
37
20
|
messages: Record<string, string>;
|
|
38
21
|
optionsFrom?: (raw: unknown) => Options;
|
|
39
|
-
/** Which files the rule polices: a tier, or a predicate for a scope no tier name describes. */
|
|
40
22
|
scope: Tier | ((importer: Classified) => boolean);
|
|
41
23
|
schema?: unknown[];
|
|
42
24
|
typeOnly?: 'skip' | 'visit';
|
|
@@ -53,6 +35,7 @@ type Context = {
|
|
|
53
35
|
export declare const directionRule: <Options = undefined>(declaration: Declaration<Options>) => {
|
|
54
36
|
create(context: Context): Visitor;
|
|
55
37
|
fixShape: string;
|
|
38
|
+
probe?: ((options: readonly unknown[]) => Probe | ProbeTree) | undefined;
|
|
56
39
|
meta: {
|
|
57
40
|
docs: {
|
|
58
41
|
description: string;
|
|
@@ -3,6 +3,7 @@ import { dirname, relative } from "node:path";
|
|
|
3
3
|
import { resolveRelative } from "./imports.js";
|
|
4
4
|
import { exportedNamesOf, landingsOf, namesATierFolder, rootOf } from "./landing.js";
|
|
5
5
|
import { propertyNameOf } from "./nodes.js";
|
|
6
|
+
import { destructuredNamesOf, withoutTypes } from "./objects.js";
|
|
6
7
|
import { fileOf, normalise } from "./paths.js";
|
|
7
8
|
import { featureOf, inTier, tierOf } from "./tiers.js";
|
|
8
9
|
import { onImportSource } from "./visitors.js";
|
|
@@ -13,7 +14,6 @@ var classify = (path, source = path) => ({
|
|
|
13
14
|
source,
|
|
14
15
|
tier: tierOf(path)
|
|
15
16
|
});
|
|
16
|
-
var FORBIDDEN = "forbidden";
|
|
17
17
|
var placeAndSource = (target, importer) => ({
|
|
18
18
|
file: importer.file,
|
|
19
19
|
source: target.source
|
|
@@ -30,7 +30,7 @@ var namespaceBoundBy = (node) => {
|
|
|
30
30
|
return typeof local === "string" ? local : undefined;
|
|
31
31
|
};
|
|
32
32
|
var WHOLE = "whole";
|
|
33
|
-
var
|
|
33
|
+
var targetsFor = (filename, importer, source, taken) => {
|
|
34
34
|
const spelled = classify(resolveRelative(importer.path, source), source);
|
|
35
35
|
const door = landingsOf(filename, source, []).door;
|
|
36
36
|
const landed = landingsOf(filename, source, taken === WHOLE ? door === undefined ? [] : [...exportedNamesOf(door)] : taken);
|
|
@@ -48,10 +48,20 @@ var targetsOf = (filename, importer, source, taken) => {
|
|
|
48
48
|
targets.push(classify(judged(landed.door), source));
|
|
49
49
|
return targets;
|
|
50
50
|
};
|
|
51
|
+
var targetsMemo = new Map;
|
|
52
|
+
var targetsOf = (filename, importer, source, taken) => {
|
|
53
|
+
const key = `${filename}\x00${source}\x00${taken === WHOLE ? WHOLE : taken.join("\x00")}`;
|
|
54
|
+
const known = targetsMemo.get(key);
|
|
55
|
+
if (known !== undefined)
|
|
56
|
+
return known;
|
|
57
|
+
const found = targetsFor(filename, importer, source, taken);
|
|
58
|
+
targetsMemo.set(key, found);
|
|
59
|
+
return found;
|
|
60
|
+
};
|
|
51
61
|
var directionRule = (declaration) => {
|
|
52
62
|
const {
|
|
53
63
|
data = placeAndSource,
|
|
54
|
-
messageId =
|
|
64
|
+
messageId = "forbidden",
|
|
55
65
|
optionsFrom,
|
|
56
66
|
scope,
|
|
57
67
|
typeOnly = "skip"
|
|
@@ -64,6 +74,8 @@ var directionRule = (declaration) => {
|
|
|
64
74
|
if (!inScope(importer))
|
|
65
75
|
return {};
|
|
66
76
|
const judge = (source, node, taken) => {
|
|
77
|
+
if (declaration.mayForbid?.(source) === false)
|
|
78
|
+
return;
|
|
67
79
|
const target = targetsOf(context.filename, importer, source, taken).find((one) => declaration.forbidden(one, importer, options));
|
|
68
80
|
if (target === undefined)
|
|
69
81
|
return;
|
|
@@ -89,7 +101,8 @@ var directionRule = (declaration) => {
|
|
|
89
101
|
reachedThrough.set(local, reached);
|
|
90
102
|
namespaces.push({ node, reached, source });
|
|
91
103
|
}, { typeOnly });
|
|
92
|
-
const
|
|
104
|
+
const destructured = new WeakMap;
|
|
105
|
+
const whole = onImportSource((source, node) => judge(source, node, destructured.get(node) ?? WHOLE), { typeOnly });
|
|
93
106
|
return {
|
|
94
107
|
CallExpression: whole.CallExpression,
|
|
95
108
|
ExportAllDeclaration: whole.ExportAllDeclaration,
|
|
@@ -103,6 +116,13 @@ var directionRule = (declaration) => {
|
|
|
103
116
|
MemberExpression(node) {
|
|
104
117
|
reach(node.object, propertyNameOf(node));
|
|
105
118
|
},
|
|
119
|
+
VariableDeclarator(node) {
|
|
120
|
+
const names = destructuredNamesOf(node.id);
|
|
121
|
+
const init = withoutTypes(node.init);
|
|
122
|
+
const call = init?.type === "AwaitExpression" ? withoutTypes(init.argument) : init;
|
|
123
|
+
if (names !== null && call !== undefined)
|
|
124
|
+
destructured.set(call, names);
|
|
125
|
+
},
|
|
106
126
|
"Program:exit"() {
|
|
107
127
|
for (const { node, reached, source } of namespaces) {
|
|
108
128
|
judge(source, node, reached.size === 0 ? WHOLE : [...reached]);
|
|
@@ -111,6 +131,7 @@ var directionRule = (declaration) => {
|
|
|
111
131
|
};
|
|
112
132
|
},
|
|
113
133
|
fixShape: declaration.fixShape,
|
|
134
|
+
...declaration.probe === undefined ? {} : { probe: declaration.probe },
|
|
114
135
|
meta: {
|
|
115
136
|
docs: { description: declaration.description },
|
|
116
137
|
messages: declaration.messages,
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A package's doors, read off its own `package.json` `exports`: each subpath, and the names the
|
|
3
|
-
* file behind it exports — the map `subpath-over-barrel` needs, which one consumer kept by hand.
|
|
4
|
-
*
|
|
5
|
-
* Read with the same regexes three rules already read a re-export shim with, never a parser: a
|
|
6
|
-
* door's entry is `export … from` lines and declarations, and `export *` is followed inside the
|
|
7
|
-
* package to a small fixed depth. A door written as a pattern (`./icons/*`) names no file to read
|
|
8
|
-
* and is left out; a name two doors both export is placed under neither, because the rule could
|
|
9
|
-
* not tell a reader which one to open.
|
|
10
|
-
*/
|
|
11
1
|
export type Doors = {
|
|
12
2
|
name: string;
|
|
13
|
-
|
|
3
|
+
homes: Map<string, string>;
|
|
14
4
|
};
|
|
15
|
-
/** The doors a manifest declares, each with the names behind it. */
|
|
16
5
|
export declare const doorsOf: (manifestPath: string) => Doors | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Where a bare specifier resolves from a file: the nearest `node_modules/<name>/package.json`
|
|
19
|
-
* walking up. `own` says whether it is the repo's: linked in from outside any `node_modules` (a
|
|
20
|
-
* workspace link — pnpm links a dependency too, but into its store's `node_modules/<name>`) or
|
|
21
|
-
* private (npm refuses to publish one, so under `node_modules` it is the repo's).
|
|
22
|
-
*/
|
|
23
6
|
export declare const resolvePackage: (from: string, name: string) => {
|
|
24
7
|
manifest: string;
|
|
25
8
|
own: boolean;
|
|
26
9
|
} | undefined;
|
|
10
|
+
export declare const nodeModulesAbove: (from: string) => boolean;
|
package/dist/rules/lib/doors.js
CHANGED
|
@@ -1,48 +1,56 @@
|
|
|
1
1
|
// src/rules/lib/doors.ts
|
|
2
|
-
import { existsSync, lstatSync,
|
|
2
|
+
import { existsSync, lstatSync, readdirSync, realpathSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { remembered } from "./fresh.js";
|
|
5
|
+
import { exportedNamesOf } from "./landing.js";
|
|
6
|
+
import { conditionTargetOf, fileFor, readManifest, recordOf } from "./module-text.js";
|
|
7
|
+
import { workspaceMemberNamed } from "./workspace-members.js";
|
|
8
|
+
var LISTED_FILES = 4000;
|
|
9
|
+
var filesBelow = (dir, budget) => {
|
|
10
|
+
let entries;
|
|
11
|
+
try {
|
|
12
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
13
|
+
} catch {
|
|
12
14
|
return [];
|
|
13
|
-
const names = [...table.declared, ...table.reexports.keys()];
|
|
14
|
-
for (const star of table.stars) {
|
|
15
|
-
const next = fileFor(file, star);
|
|
16
|
-
if (next !== undefined)
|
|
17
|
-
names.push(...exportsOf(next, seen, depth + 1));
|
|
18
15
|
}
|
|
19
|
-
return
|
|
16
|
+
return entries.flatMap((entry) => {
|
|
17
|
+
if (budget.left <= 0 || entry.name === "node_modules")
|
|
18
|
+
return [];
|
|
19
|
+
if (entry.isDirectory()) {
|
|
20
|
+
return filesBelow(join(dir, entry.name), budget).map((one) => `${entry.name}/${one}`);
|
|
21
|
+
}
|
|
22
|
+
budget.left -= 1;
|
|
23
|
+
return [entry.name];
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var expanded = (dir, key, target) => {
|
|
27
|
+
const star = target.indexOf("*");
|
|
28
|
+
const before = target.slice(0, star);
|
|
29
|
+
const suffix = target.slice(star + 1);
|
|
30
|
+
const folder = before.slice(0, before.lastIndexOf("/") + 1);
|
|
31
|
+
const stem = before.slice(folder.length);
|
|
32
|
+
return filesBelow(join(dir, folder), { left: LISTED_FILES }).flatMap((relative) => {
|
|
33
|
+
if (!relative.startsWith(stem) || !relative.endsWith(suffix))
|
|
34
|
+
return [];
|
|
35
|
+
const matched = relative.slice(stem.length, relative.length - suffix.length);
|
|
36
|
+
return matched === "" ? [] : [[key.replace("*", matched).slice(2), `${folder}${relative}`]];
|
|
37
|
+
});
|
|
20
38
|
};
|
|
21
39
|
var doorsOf = (manifestPath) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} catch {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (typeof manifest.name !== "string")
|
|
29
|
-
return;
|
|
30
|
-
if (typeof manifest.exports !== "object" || manifest.exports === null)
|
|
40
|
+
const manifest = readManifest(manifestPath);
|
|
41
|
+
const exported = recordOf(manifest?.exports);
|
|
42
|
+
if (typeof manifest?.name !== "string" || exported === undefined)
|
|
31
43
|
return;
|
|
32
44
|
const dir = dirname(manifestPath);
|
|
33
45
|
const placed = new Map;
|
|
34
46
|
const contested = new Set;
|
|
35
|
-
|
|
36
|
-
if (key === "." || !key.startsWith("./") || key.includes("*"))
|
|
37
|
-
continue;
|
|
38
|
-
const target = conditionTargetOf(value);
|
|
39
|
-
if (target === undefined)
|
|
40
|
-
continue;
|
|
47
|
+
const place = (door, target) => {
|
|
41
48
|
const entry = fileFor(join(dir, "package.json"), target);
|
|
42
49
|
if (entry === undefined)
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
50
|
+
return;
|
|
51
|
+
for (const name of exportedNamesOf(entry)) {
|
|
52
|
+
if (name === "default")
|
|
53
|
+
continue;
|
|
46
54
|
if (contested.has(name))
|
|
47
55
|
continue;
|
|
48
56
|
const already = placed.get(name);
|
|
@@ -53,10 +61,26 @@ var doorsOf = (manifestPath) => {
|
|
|
53
61
|
}
|
|
54
62
|
placed.set(name, door);
|
|
55
63
|
}
|
|
64
|
+
};
|
|
65
|
+
for (const [key, value] of Object.entries(exported)) {
|
|
66
|
+
if (key === "." || !key.startsWith("./"))
|
|
67
|
+
continue;
|
|
68
|
+
const target = conditionTargetOf(value);
|
|
69
|
+
if (target === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
if (key.includes("*")) {
|
|
72
|
+
if (!target.includes("*"))
|
|
73
|
+
continue;
|
|
74
|
+
for (const [door, concrete] of expanded(dir, key, target))
|
|
75
|
+
place(door, concrete);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
place(key.slice(2), target);
|
|
56
79
|
}
|
|
57
80
|
return { homes: placed, name: manifest.name };
|
|
58
81
|
};
|
|
59
|
-
var
|
|
82
|
+
var resolvedIn = new Map;
|
|
83
|
+
var resolveInNodeModules = (from, name) => remembered(resolvedIn, `${dirname(from)}\x00${name}`, () => {
|
|
60
84
|
let dir = dirname(from);
|
|
61
85
|
for (;; ) {
|
|
62
86
|
const packageDir = join(dir, "node_modules", name);
|
|
@@ -68,13 +92,8 @@ var resolvePackage = (from, name) => {
|
|
|
68
92
|
} catch {
|
|
69
93
|
own = false;
|
|
70
94
|
}
|
|
71
|
-
if (!own)
|
|
72
|
-
|
|
73
|
-
own = JSON.parse(readFileSync(manifest, "utf8")).private === true;
|
|
74
|
-
} catch {
|
|
75
|
-
own = false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
95
|
+
if (!own)
|
|
96
|
+
own = readManifest(manifest)?.private === true;
|
|
78
97
|
return { manifest, own };
|
|
79
98
|
}
|
|
80
99
|
const parent = dirname(dir);
|
|
@@ -82,8 +101,29 @@ var resolvePackage = (from, name) => {
|
|
|
82
101
|
return;
|
|
83
102
|
dir = parent;
|
|
84
103
|
}
|
|
104
|
+
});
|
|
105
|
+
var resolvePackage = (from, name) => {
|
|
106
|
+
const found = resolveInNodeModules(from, name);
|
|
107
|
+
if (found?.own === true)
|
|
108
|
+
return found;
|
|
109
|
+
const member = workspaceMemberNamed(from, name);
|
|
110
|
+
if (member === undefined)
|
|
111
|
+
return found;
|
|
112
|
+
return { manifest: found?.manifest ?? member, own: true };
|
|
113
|
+
};
|
|
114
|
+
var nodeModulesAbove = (from) => {
|
|
115
|
+
let dir = dirname(from);
|
|
116
|
+
for (;; ) {
|
|
117
|
+
if (existsSync(join(dir, "node_modules")))
|
|
118
|
+
return true;
|
|
119
|
+
const parent = dirname(dir);
|
|
120
|
+
if (parent === dir)
|
|
121
|
+
return false;
|
|
122
|
+
dir = parent;
|
|
123
|
+
}
|
|
85
124
|
};
|
|
86
125
|
export {
|
|
87
126
|
doorsOf,
|
|
127
|
+
nodeModulesAbove,
|
|
88
128
|
resolvePackage
|
|
89
129
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/rules/lib/fresh.ts
|
|
2
|
+
var FRESH_MS = 1000;
|
|
3
|
+
var remembered = (held, key, compute) => {
|
|
4
|
+
const now = Date.now();
|
|
5
|
+
const known = held.get(key);
|
|
6
|
+
if (known !== undefined && now - known.at < FRESH_MS)
|
|
7
|
+
return known.value;
|
|
8
|
+
const value = compute();
|
|
9
|
+
held.set(key, { at: now, value });
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
FRESH_MS,
|
|
14
|
+
remembered
|
|
15
|
+
};
|