obsidian-dev-utils 80.0.0 → 80.0.2
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 +9 -0
- package/dist/lib/cjs/library.cjs +1 -1
- package/dist/lib/cjs/script-utils/linters/over-exposure.cjs +77 -9
- package/dist/lib/cjs/script-utils/linters/over-exposure.d.cts +30 -2
- package/dist/lib/esm/library.mjs +1 -1
- package/dist/lib/esm/script-utils/linters/over-exposure.d.mts +30 -2
- package/dist/lib/esm/script-utils/linters/over-exposure.mjs +78 -9
- package/dist/templates/scripts/linters/over-exposure/find-overexposed-fix.ts +11 -2
- package/dist/templates/scripts/linters/over-exposure/find-overexposed.ts +0 -1
- package/package.json +1 -1
- package/dist/dev/main.js +0 -29135
- package/dist/dev/manifest.json +0 -9
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The analysis is whole-program and type-aware: it uses the TypeScript language service's
|
|
17
17
|
* find-all-references to locate every use of each declaration, then classifies the tightest
|
|
18
|
-
* exposure that still covers all references.
|
|
18
|
+
* exposure that still covers all references. Because `findReferences` does not link a string-literal
|
|
19
|
+
* argument back to a member declaration when the parameter is a conditional/mapped key type (e.g.
|
|
20
|
+
* `bind(component, 'someSetting')` where the key is typed `ConditionalKeys<Settings, …>`), member
|
|
21
|
+
* analysis additionally treats a string literal whose text equals the member name as a reference —
|
|
22
|
+
* but only when its contextual type is a string-literal type (or union of them) all of whose members
|
|
23
|
+
* are keys of the declaring class, so incidental same-named strings (`console.log('name')`) are not
|
|
24
|
+
* miscounted. Members invoked by the framework via registration
|
|
19
25
|
* rather than by visible references (Obsidian lifecycle hooks, settings-tab `display`, etc.) are
|
|
20
26
|
* excluded via {@link LIFECYCLE_ALLOWLIST}, as are `override` and `static` members whose exposure is
|
|
21
27
|
* constrained by a base declaration. ECMAScript hard-private members (`#name`) are also excluded —
|
|
@@ -34,6 +40,12 @@
|
|
|
34
40
|
* {@link OverExposureFinding.skipReason}. Changes that cannot be safely automated — those forced
|
|
35
41
|
* only by test references, decorated members, or an `export` shared with a still-exported sibling —
|
|
36
42
|
* are reported as skipped and left untouched.
|
|
43
|
+
*
|
|
44
|
+
* Additionally passing `shouldForce` (only meaningful together with `shouldFix`) tightens the
|
|
45
|
+
* declarations held wide purely by test references too — the production half of the canonical
|
|
46
|
+
* test-only migration: the member becomes `private` / the `export` is dropped, leaving only the
|
|
47
|
+
* test to switch to a cast-based access. Decorated members and exports shared with a still-exported
|
|
48
|
+
* sibling stay skipped even under `shouldForce`, because no edit can be applied safely.
|
|
37
49
|
*/
|
|
38
50
|
import type { CompilerOptions, LanguageService, LanguageServiceHost } from 'typescript';
|
|
39
51
|
/**
|
|
@@ -54,6 +66,13 @@ export interface AnalyzeOverExposureParams {
|
|
|
54
66
|
* {@link OverExposureFinding.skipReason}. When `false` or omitted, the analysis only reports.
|
|
55
67
|
*/
|
|
56
68
|
readonly shouldFix?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* When `true` (only meaningful together with {@link shouldFix}), declarations held wide purely by
|
|
71
|
+
* test references are tightened too, instead of being skipped with a `test-only`
|
|
72
|
+
* {@link OverExposureFinding.skipReason}. Decorated members and exports shared with a
|
|
73
|
+
* still-exported sibling stay skipped regardless, because no edit can be applied safely.
|
|
74
|
+
*/
|
|
75
|
+
readonly shouldForce?: boolean | undefined;
|
|
57
76
|
/**
|
|
58
77
|
* Absolute (canonical) path of the project's `src` folder. Only declarations in non-test files
|
|
59
78
|
* under this folder are analyzed; declarations elsewhere (test files, dependencies) are ignored
|
|
@@ -108,6 +127,13 @@ export interface FindOverExposureParams {
|
|
|
108
127
|
* project is only analyzed.
|
|
109
128
|
*/
|
|
110
129
|
readonly shouldFix?: boolean | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* When `true` (only meaningful together with {@link shouldFix}), declarations held wide purely by
|
|
132
|
+
* test references are tightened too, instead of being skipped. Decorated members and exports
|
|
133
|
+
* shared with a still-exported sibling stay skipped regardless. Forwarded to
|
|
134
|
+
* {@link analyzeOverExposure}.
|
|
135
|
+
*/
|
|
136
|
+
readonly shouldForce?: boolean | undefined;
|
|
111
137
|
}
|
|
112
138
|
/**
|
|
113
139
|
* Options for {@link formatOverExposureFindings}.
|
|
@@ -226,7 +252,9 @@ export declare const LIFECYCLE_ALLOWLIST: ReadonlySet<string>;
|
|
|
226
252
|
* when {@link AnalyzeOverExposureParams.shouldFix} is set — tightens every fixable finding in place
|
|
227
253
|
* via {@link AnalyzeOverExposureParams.writeFile}. Findings that cannot be safely automated (exposed
|
|
228
254
|
* only for tests, decorated, or sharing an `export` keyword with a still-exported sibling) carry a
|
|
229
|
-
* {@link OverExposureFinding.skipReason} and are left untouched
|
|
255
|
+
* {@link OverExposureFinding.skipReason} and are left untouched — unless
|
|
256
|
+
* {@link AnalyzeOverExposureParams.shouldForce} is set, which additionally tightens the test-only
|
|
257
|
+
* findings (decorated and shared-export ones still stay skipped).
|
|
230
258
|
*
|
|
231
259
|
* @param params - The {@link AnalyzeOverExposureParams}.
|
|
232
260
|
* @returns The over-exposed declarations, in discovery order.
|
package/dist/lib/esm/library.mjs
CHANGED
|
@@ -21,7 +21,7 @@ if you want to view the source, please visit the github repository of this plugi
|
|
|
21
21
|
globalThis.process = browserProcess;
|
|
22
22
|
})();
|
|
23
23
|
|
|
24
|
-
const LIBRARY_VERSION = "80.0.
|
|
24
|
+
const LIBRARY_VERSION = "80.0.2";
|
|
25
25
|
const LIBRARY_NAME = "obsidian-dev-utils";
|
|
26
26
|
const LIBRARY_STYLES = ".obsidian-dev-utils.code-highlighter-component textarea, .obsidian-dev-utils.code-highlighter-component pre, .obsidian-dev-utils.code-highlighter-component code {\n font-family: var(--font-monospace);\n line-height: var(--line-height-normal);\n margin: 0;\n}\n.obsidian-dev-utils.code-highlighter-component textarea, .obsidian-dev-utils.code-highlighter-component code {\n font-size: var(--code-size);\n}\n.obsidian-dev-utils.code-highlighter-component textarea {\n background: transparent;\n color: transparent;\n z-index: 2;\n width: 20em;\n height: 10em;\n}\n.obsidian-dev-utils.code-highlighter-component pre {\n position: absolute;\n pointer-events: none;\n border: var(--input-border-width) solid transparent;\n overflow: auto;\n inset: 0;\n padding: var(--size-4-1) var(--size-4-2);\n z-index: 1;\n}\n.obsidian-dev-utils.code-highlighter-component pre::after {\n content: \"\";\n display: block;\n height: var(--bottom-gap, 0);\n}\n.obsidian-dev-utils.code-highlighter-component pre.is-placeholder {\n opacity: 0.6;\n}\n.obsidian-dev-utils.code-highlighter-component code {\n display: block;\n padding: 0;\n}\n\n.obsidian-dev-utils input[type=url] {\n height: var(--input-height);\n}\n.obsidian-dev-utils input[type=month],\n.obsidian-dev-utils input[type=tel],\n.obsidian-dev-utils input[type=time],\n.obsidian-dev-utils input[type=url],\n.obsidian-dev-utils input[type=week] {\n -webkit-app-region: no-drag;\n background: var(--background-modifier-form-field);\n border: var(--input-border-width) solid var(--background-modifier-border);\n color: var(--text-normal);\n font-family: inherit;\n padding: var(--size-4-1) var(--size-4-2);\n font-size: var(--font-ui-small);\n border-radius: var(--input-radius);\n outline: none;\n}\n@media (hover: hover) {\n .obsidian-dev-utils input[type=month]:hover,\n .obsidian-dev-utils input[type=tel]:hover,\n .obsidian-dev-utils input[type=time]:hover,\n .obsidian-dev-utils input[type=url]:hover,\n .obsidian-dev-utils input[type=week]:hover {\n border-color: var(--background-modifier-border-hover);\n transition: box-shadow 0.15s ease-in-out, border 0.15s ease-in-out;\n }\n}\n.obsidian-dev-utils input[type=month]:active, .obsidian-dev-utils input[type=month]:focus,\n.obsidian-dev-utils input[type=tel]:active,\n.obsidian-dev-utils input[type=tel]:focus,\n.obsidian-dev-utils input[type=time]:active,\n.obsidian-dev-utils input[type=time]:focus,\n.obsidian-dev-utils input[type=url]:active,\n.obsidian-dev-utils input[type=url]:focus,\n.obsidian-dev-utils input[type=week]:active,\n.obsidian-dev-utils input[type=week]:focus {\n border-color: var(--background-modifier-border-focus);\n transition: box-shadow 0.15s ease-in-out, border 0.15s ease-in-out;\n}\n.obsidian-dev-utils input[type=month]:active, .obsidian-dev-utils input[type=month]:focus, .obsidian-dev-utils input[type=month]:focus-visible,\n.obsidian-dev-utils input[type=tel]:active,\n.obsidian-dev-utils input[type=tel]:focus,\n.obsidian-dev-utils input[type=tel]:focus-visible,\n.obsidian-dev-utils input[type=time]:active,\n.obsidian-dev-utils input[type=time]:focus,\n.obsidian-dev-utils input[type=time]:focus-visible,\n.obsidian-dev-utils input[type=url]:active,\n.obsidian-dev-utils input[type=url]:focus,\n.obsidian-dev-utils input[type=url]:focus-visible,\n.obsidian-dev-utils input[type=week]:active,\n.obsidian-dev-utils input[type=week]:focus,\n.obsidian-dev-utils input[type=week]:focus-visible {\n box-shadow: 0 0 0 2px var(--background-modifier-border-focus);\n}\n.obsidian-dev-utils input[type=month]::placeholder,\n.obsidian-dev-utils input[type=tel]::placeholder,\n.obsidian-dev-utils input[type=time]::placeholder,\n.obsidian-dev-utils input[type=url]::placeholder,\n.obsidian-dev-utils input[type=week]::placeholder {\n color: var(--text-faint);\n}\n.mod-rtl input[type=month],\n.mod-rtl input[type=time],\n.mod-rtl input[type=week],\n.is-rtl input[type=month],\n.is-rtl input[type=time],\n.is-rtl input[type=week],\n.rtl input[type=month],\n.rtl input[type=time],\n.rtl input[type=week] {\n direction: rtl;\n}\n.mod-rtl input[type=month]::-webkit-calendar-picker-indicator,\n.mod-rtl input[type=time]::-webkit-calendar-picker-indicator,\n.mod-rtl input[type=week]::-webkit-calendar-picker-indicator,\n.is-rtl input[type=month]::-webkit-calendar-picker-indicator,\n.is-rtl input[type=time]::-webkit-calendar-picker-indicator,\n.is-rtl input[type=week]::-webkit-calendar-picker-indicator,\n.rtl input[type=month]::-webkit-calendar-picker-indicator,\n.rtl input[type=time]::-webkit-calendar-picker-indicator,\n.rtl input[type=week]::-webkit-calendar-picker-indicator {\n right: var(--size-4-1);\n left: auto;\n}\n\n.obsidian-dev-utils input[type=month],\n.obsidian-dev-utils input[type=time],\n.obsidian-dev-utils input[type=week] {\n font-variant-numeric: tabular-nums;\n position: relative;\n}\n.obsidian-dev-utils input[type=month]::-webkit-datetime-edit-text,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-text,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-text {\n color: var(--text-faint);\n padding-inline-end: 0;\n}\n.obsidian-dev-utils input[type=month]::-webkit-calendar-picker-indicator,\n.obsidian-dev-utils input[type=time]::-webkit-calendar-picker-indicator,\n.obsidian-dev-utils input[type=week]::-webkit-calendar-picker-indicator {\n position: absolute;\n left: var(--size-4-1);\n right: auto;\n opacity: 0.5;\n}\n.obsidian-dev-utils input[type=month]::-webkit-datetime-edit-month-field:active, .obsidian-dev-utils input[type=month]::-webkit-datetime-edit-month-field:focus, .obsidian-dev-utils input[type=month]::-webkit-datetime-edit-day-field:active, .obsidian-dev-utils input[type=month]::-webkit-datetime-edit-day-field:focus, .obsidian-dev-utils input[type=month]::-webkit-datetime-edit-year-field:active, .obsidian-dev-utils input[type=month]::-webkit-datetime-edit-year-field:focus,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-month-field:active,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-month-field:focus,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-day-field:active,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-day-field:focus,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-year-field:active,\n.obsidian-dev-utils input[type=time]::-webkit-datetime-edit-year-field:focus,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-month-field:active,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-month-field:focus,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-day-field:active,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-day-field:focus,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-year-field:active,\n.obsidian-dev-utils input[type=week]::-webkit-datetime-edit-year-field:focus {\n background-color: var(--text-selection);\n color: var(--text-normal);\n cursor: text;\n}\n.mod-rtl .obsidian-dev-utils input[type=month], .is-rtl .obsidian-dev-utils input[type=month], .rtl .obsidian-dev-utils input[type=month],\n.mod-rtl .obsidian-dev-utils input[type=time],\n.is-rtl .obsidian-dev-utils input[type=time],\n.rtl .obsidian-dev-utils input[type=time],\n.mod-rtl .obsidian-dev-utils input[type=week],\n.is-rtl .obsidian-dev-utils input[type=week],\n.rtl .obsidian-dev-utils input[type=week] {\n direction: rtl;\n}\n.mod-rtl .obsidian-dev-utils input[type=month]::-webkit-calendar-picker-indicator, .is-rtl .obsidian-dev-utils input[type=month]::-webkit-calendar-picker-indicator, .rtl .obsidian-dev-utils input[type=month]::-webkit-calendar-picker-indicator,\n.mod-rtl .obsidian-dev-utils input[type=time]::-webkit-calendar-picker-indicator,\n.is-rtl .obsidian-dev-utils input[type=time]::-webkit-calendar-picker-indicator,\n.rtl .obsidian-dev-utils input[type=time]::-webkit-calendar-picker-indicator,\n.mod-rtl .obsidian-dev-utils input[type=week]::-webkit-calendar-picker-indicator,\n.is-rtl .obsidian-dev-utils input[type=week]::-webkit-calendar-picker-indicator,\n.rtl .obsidian-dev-utils input[type=week]::-webkit-calendar-picker-indicator {\n left: auto;\n right: var(--size-4-1);\n}\n\nbody:not(.is-ios):not(.is-android) .obsidian-dev-utils input[type=month],\nbody:not(.is-ios):not(.is-android) .obsidian-dev-utils input[type=time],\nbody:not(.is-ios):not(.is-android) .obsidian-dev-utils input[type=week] {\n padding-inline-start: var(--size-4-6);\n}\n\n.obsidian-dev-utils input[type=time]::-webkit-calendar-picker-indicator {\n margin-inline-start: 0;\n}\n\n.obsidian-dev-utilsprogress.loop {\n min-width: 200px;\n}\n\n.obsidian-dev-utils.modal-container .ok-button {\n margin-right: 10px;\n margin-top: 20px;\n}\n\n.obsidian-dev-utils .multiple-dropdown-component select,\n.obsidian-dev-utils .multiple-dropdown-component select:focus,\n.obsidian-dev-utils .multiple-dropdown-component .dropdown {\n height: auto;\n padding-top: 3px;\n}\n.obsidian-dev-utils .multiple-dropdown-component select option:checked,\n.obsidian-dev-utils .multiple-dropdown-component select:focus option:checked,\n.obsidian-dev-utils .multiple-dropdown-component .dropdown option:checked {\n background-color: #1967d2;\n color: #fff;\n}\n\n.obsidian-dev-utils.plugin-settings-tab a:focus {\n outline: 2px solid var(--link-color);\n}\n\n.obsidian-dev-utils.prompt-modal .text-box {\n width: 100%;\n}\n\n.obsidian-dev-utils.tri-state-checkbox-component input[type=checkbox]:indeterminate {\n appearance: checkbox;\n}\n\n.obsidian-dev-utils :invalid {\n box-shadow: 0 0 0 2px var(--text-error);\n}\n.obsidian-dev-utils input.metadata-input-text:active:invalid, .obsidian-dev-utils input.metadata-input-text:focus-visible:invalid, .obsidian-dev-utils input.metadata-input-text:focus:invalid,\n.obsidian-dev-utils input[type=date]:active:invalid,\n.obsidian-dev-utils input[type=date]:focus-visible:invalid,\n.obsidian-dev-utils input[type=date]:focus:invalid,\n.obsidian-dev-utils input[type=datetime-local]:active:invalid,\n.obsidian-dev-utils input[type=datetime-local]:focus-visible:invalid,\n.obsidian-dev-utils input[type=datetime-local]:focus:invalid,\n.obsidian-dev-utils input[type=email]:active:invalid,\n.obsidian-dev-utils input[type=email]:focus-visible:invalid,\n.obsidian-dev-utils input[type=email]:focus:invalid,\n.obsidian-dev-utils input[type=number]:active:invalid,\n.obsidian-dev-utils input[type=number]:focus-visible:invalid,\n.obsidian-dev-utils input[type=number]:focus:invalid,\n.obsidian-dev-utils input[type=password]:active:invalid,\n.obsidian-dev-utils input[type=password]:focus-visible:invalid,\n.obsidian-dev-utils input[type=password]:focus:invalid,\n.obsidian-dev-utils input[type=search]:active:invalid,\n.obsidian-dev-utils input[type=search]:focus-visible:invalid,\n.obsidian-dev-utils input[type=search]:focus:invalid,\n.obsidian-dev-utils input[type=text]:active:invalid,\n.obsidian-dev-utils input[type=text]:focus-visible:invalid,\n.obsidian-dev-utils input[type=text]:focus:invalid,\n.obsidian-dev-utils textarea:active:invalid,\n.obsidian-dev-utils textarea:focus-visible:invalid,\n.obsidian-dev-utils textarea:focus:invalid {\n box-shadow: 0 0 0 2px var(--text-error);\n}\n.obsidian-dev-utils.setting-component-wrapper {\n position: relative;\n display: inline-flex;\n}\n.obsidian-dev-utils.overlay-validator {\n caret-color: transparent;\n cursor: default;\n position: absolute;\n background-color: transparent;\n border: none;\n outline: none;\n pointer-events: none;\n z-index: 9999;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n.obsidian-dev-utils.tooltip.tooltip-validator {\n position: absolute;\n top: calc(100% + 8px);\n width: max-content;\n}\n\n/*# sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22:3,%22sourceRoot%22:%22%22,%22sources%22:%5B%22../src/styles/code-highlighter-component.scss%22,%22../src/styles/input.scss%22,%22../src/styles/input-time.scss%22,%22../src/styles/loop.scss%22,%22../src/styles/modal-container.scss%22,%22../src/styles/multiple-dropdown-component.scss%22,%22../src/styles/plugin-settings-tab.scss%22,%22../src/styles/prompt-modal.scss%22,%22../src/styles/tri-state-checkbox-component.scss%22,%22../src/styles/validation.scss%22%5D,%22names%22:%5B%5D,%22mappings%22:%22AAEI;EACE;EACA;EACA;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;;AAGF;EACE;EACA;;;ACzCJ;EACE;;AAGF;AAAA;AAAA;AAAA;AAAA;EAKE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGE;EACE;AAAA;AAAA;AAAA;AAAA;IACE;IACA,YACE;;;AAMR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAEE;EACA,YACE;;AAIJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGE;;AAGF;AAAA;AAAA;AAAA;AAAA;EACE;;AASE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGE;;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EACE;EACA;;;AC7DV;AAAA;AAAA;EAGE;EACA;;AAEA;AAAA;AAAA;EACE;EACA;;AAGF;AAAA;AAAA;EACE;EACA;EACA;EACA;;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAEE;EACA;EACA;;AAIK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGP;;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EACE;EACA;;;AAKF;AAAA;AAAA;EACE;;;AAMJ;EACE;;;ACjDJ;EACE;;;ACAA;EACE;EACA;;;ACFF;AAAA;AAAA;EAGE;EACA;;AAEA;AAAA;AAAA;EACE;EACA;;;ACRJ;EACE;;;ACDF;EACE;;;ACDF;EACE;;;ACEJ;EAJA;;AAoBI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EApBJ;;AA0BA;EACE;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA%22,%22file%22:%22styles.css%22,%22sourcesContent%22:%5B%22.obsidian-dev-utils%20%7B%5Cn%20%20&.code-highlighter-component%20%7B%5Cn%20%20%20%20textarea,%20pre,%20code%20%7B%5Cn%20%20%20%20%20%20font-family:%20var(--font-monospace);%5Cn%20%20%20%20%20%20line-height:%20var(--line-height-normal);%5Cn%20%20%20%20%20%20margin:%200;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20textarea,%20code%20%7B%5Cn%20%20%20%20%20%20font-size:%20var(--code-size);%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20textarea%20%7B%5Cn%20%20%20%20%20%20background:%20transparent;%5Cn%20%20%20%20%20%20color:%20transparent;%5Cn%20%20%20%20%20%20z-index:%202;%5Cn%20%20%20%20%20%20width:%2020em;%5Cn%20%20%20%20%20%20height:%2010em;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20pre%20%7B%5Cn%20%20%20%20%20%20position:%20absolute;%5Cn%20%20%20%20%20%20pointer-events:%20none;%5Cn%20%20%20%20%20%20border:%20var(--input-border-width)%20solid%20transparent;%5Cn%20%20%20%20%20%20overflow:%20auto;%5Cn%20%20%20%20%20%20inset:%200;%5Cn%20%20%20%20%20%20padding:%20var(--size-4-1)%20var(--size-4-2);%5Cn%20%20%20%20%20%20z-index:%201;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20pre::after%20%7B%5Cn%20%20%20%20%20%20content:%20%5C%22%5C%22;%5Cn%20%20%20%20%20%20display:%20block;%5Cn%20%20%20%20%20%20height:%20var(--bottom-gap,%200);%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20pre.is-placeholder%20%7B%5Cn%20%20%20%20%20%20opacity:%200.6;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20code%20%7B%5Cn%20%20%20%20%20%20display:%20block;%5Cn%20%20%20%20%20%20padding:%200;%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20input%5Btype='url'%5D%20%7B%5Cn%20%20%20%20height:%20var(--input-height)%5Cn%20%20%7D%5Cn%5Cn%20%20input%5Btype='month'%5D,%5Cn%20%20input%5Btype='tel'%5D,%5Cn%20%20input%5Btype='time'%5D,%5Cn%20%20input%5Btype='url'%5D,%5Cn%20%20input%5Btype='week'%5D%20%7B%5Cn%20%20%20%20-webkit-app-region:%20no-drag;%5Cn%20%20%20%20background:%20var(--background-modifier-form-field);%5Cn%20%20%20%20border:%20var(--input-border-width)%20solid%20var(--background-modifier-border);%5Cn%20%20%20%20color:%20var(--text-normal);%5Cn%20%20%20%20font-family:%20inherit;%5Cn%20%20%20%20padding:%20var(--size-4-1)%20var(--size-4-2);%5Cn%20%20%20%20font-size:%20var(--font-ui-small);%5Cn%20%20%20%20border-radius:%20var(--input-radius);%5Cn%20%20%20%20outline:%20none;%5Cn%5Cn%20%20%20%20@at-root%20%7B%5Cn%20%20%20%20%20%20@media%20(hover:%20hover)%20%7B%5Cn%20%20%20%20%20%20%20%20&:hover%20%7B%5Cn%20%20%20%20%20%20%20%20%20%20border-color:%20var(--background-modifier-border-hover);%5Cn%20%20%20%20%20%20%20%20%20%20transition:%5Cn%20%20%20%20%20%20%20%20%20%20%20%20box-shadow%200.15s%20ease-in-out,%5Cn%20%20%20%20%20%20%20%20%20%20%20%20border%200.15s%20ease-in-out;%5Cn%20%20%20%20%20%20%20%20%7D%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20&:active,%5Cn%20%20%20%20&:focus%20%7B%5Cn%20%20%20%20%20%20border-color:%20var(--background-modifier-border-focus);%5Cn%20%20%20%20%20%20transition:%5Cn%20%20%20%20%20%20%20%20box-shadow%200.15s%20ease-in-out,%5Cn%20%20%20%20%20%20%20%20border%200.15s%20ease-in-out;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20&:active,%5Cn%20%20%20%20&:focus,%5Cn%20%20%20%20&:focus-visible%20%7B%5Cn%20%20%20%20%20%20box-shadow:%200%200%200%202px%20var(--background-modifier-border-focus);%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20&::placeholder%20%7B%5Cn%20%20%20%20%20%20color:%20var(--text-faint);%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%5Cn%20%20@at-root%20%7B%5Cn%20%20%20%20.mod-rtl,%5Cn%20%20%20%20.is-rtl,%5Cn%20%20%20%20.rtl%20%7B%5Cn%20%20%20%20%20%20&%20%7B%5Cn%20%20%20%20%20%20%20%20input%5Btype='month'%5D,%5Cn%20%20%20%20%20%20%20%20input%5Btype='time'%5D,%5Cn%20%20%20%20%20%20%20%20input%5Btype='week'%5D%20%7B%5Cn%20%20%20%20%20%20%20%20%20%20direction:%20rtl;%5Cn%5Cn%20%20%20%20%20%20%20%20%20%20&::-webkit-calendar-picker-indicator%20%7B%5Cn%20%20%20%20%20%20%20%20%20%20%20%20right:%20var(--size-4-1);%5Cn%20%20%20%20%20%20%20%20%20%20%20%20left:%20auto;%5Cn%20%20%20%20%20%20%20%20%20%20%7D%5Cn%20%20%20%20%20%20%20%20%7D%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20input%5Btype='month'%5D,%5Cn%20%20input%5Btype='time'%5D,%5Cn%20%20input%5Btype='week'%5D%20%7B%5Cn%20%20%20%20font-variant-numeric:%20tabular-nums;%5Cn%20%20%20%20position:%20relative;%5Cn%5Cn%20%20%20%20&::-webkit-datetime-edit-text%20%7B%5Cn%20%20%20%20%20%20color:%20var(--text-faint);%5Cn%20%20%20%20%20%20padding-inline-end:%200;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20&::-webkit-calendar-picker-indicator%20%7B%5Cn%20%20%20%20%20%20position:%20absolute;%5Cn%20%20%20%20%20%20left:%20var(--size-4-1);%5Cn%20%20%20%20%20%20right:%20auto;%5Cn%20%20%20%20%20%20opacity:%200.5;%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20&::-webkit-datetime-edit-month-field,%5Cn%20%20%20%20&::-webkit-datetime-edit-day-field,%5Cn%20%20%20%20&::-webkit-datetime-edit-year-field%20%7B%5Cn%20%20%20%20%20%20&:active,%5Cn%20%20%20%20%20%20&:focus%20%7B%5Cn%20%20%20%20%20%20%20%20background-color:%20var(--text-selection);%5Cn%20%20%20%20%20%20%20%20color:%20var(--text-normal);%5Cn%20%20%20%20%20%20%20%20cursor:%20text;%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20@at-root%20.mod-rtl%20&,%5Cn%20%20%20%20%20%20.is-rtl%20&,%5Cn%20%20%20%20%20%20.rtl%20&%20%7B%5Cn%20%20%20%20%20%20direction:%20rtl;%5Cn%5Cn%20%20%20%20%20%20&::-webkit-calendar-picker-indicator%20%7B%5Cn%20%20%20%20%20%20%20%20left:%20auto;%5Cn%20%20%20%20%20%20%20%20right:%20var(--size-4-1);%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%5Cn%20%20%20%20@at-root%20%7B%5Cn%20%20%20%20%20%20body:not(.is-ios):not(.is-android)%20&%20%7B%5Cn%20%20%20%20%20%20%20%20padding-inline-start:%20var(--size-4-6);%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%5Cn%20%20input%5Btype='time'%5D%20%7B%5Cn%20%20%20%20&::-webkit-calendar-picker-indicator%20%7B%5Cn%20%20%20%20%20%20margin-inline-start:%200;%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20&progress.loop%20%7B%5Cn%20%20%20%20min-width:%20200px;%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20&.modal-container%20%7B%5Cn%20%20%20%20.ok-button%20%7B%5Cn%20%20%20%20%20%20margin-right:%2010px;%5Cn%20%20%20%20%20%20margin-top:%2020px;%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20.multiple-dropdown-component%20%7B%5Cn%20%20%20%20select,%5Cn%20%20%20%20select:focus,%5Cn%20%20%20%20.dropdown%20%7B%5Cn%20%20%20%20%20%20height:%20auto;%5Cn%20%20%20%20%20%20padding-top:%203px;%5Cn%5Cn%20%20%20%20%20%20option:checked%20%7B%5Cn%20%20%20%20%20%20%20%20background-color:%20%231967d2;%5Cn%20%20%20%20%20%20%20%20color:%20%23fff;%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20&.plugin-settings-tab%20%7B%5Cn%20%20%20%20a:focus%20%7B%5Cn%20%20%20%20%20%20outline:%202px%20solid%20var(--link-color);%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cn%20%20&.prompt-modal%20%7B%5Cn%20%20%20%20.text-box%20%7B%5Cn%20%20%20%20%20%20width:%20100%25;%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%5Cn%22,%22.obsidian-dev-utils%20%7B%5Cr%5Cn%20%20&.tri-state-checkbox-component%20%7B%5Cr%5Cn%20%20%20%20input%5Btype='checkbox'%5D:indeterminate%20%7B%5Cr%5Cn%20%20%20%20%20%20appearance:%20checkbox;%5Cr%5Cn%20%20%20%20%7D%5Cr%5Cn%20%20%7D%5Cr%5Cn%7D%5Cr%5Cn%22,%22@mixin%20invalid%20%7B%5Cn%20%20box-shadow:%200%200%200%202px%20var(--text-error);%5Cn%7D%5Cn%5Cn.obsidian-dev-utils%20%7B%5Cn%20%20:invalid%20%7B%5Cn%20%20%20%20@include%20invalid;%5Cn%20%20%7D%5Cn%5Cn%20%20input.metadata-input-text,%5Cn%20%20input%5Btype='date'%5D,%5Cn%20%20input%5Btype='datetime-local'%5D,%5Cn%20%20input%5Btype='email'%5D,%5Cn%20%20input%5Btype='number'%5D,%5Cn%20%20input%5Btype='password'%5D,%5Cn%20%20input%5Btype='search'%5D,%5Cn%20%20input%5Btype='text'%5D,%5Cn%20%20textarea%20%7B%5Cn%20%20%20%20&:active,%5Cn%20%20%20%20&:focus-visible,%5Cn%20%20%20%20&:focus%20%7B%5Cn%20%20%20%20%20%20&:invalid%20%7B%5Cn%20%20%20%20%20%20%20%20@include%20invalid;%5Cn%20%20%20%20%20%20%7D%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%5Cn%20%20&.setting-component-wrapper%20%7B%5Cn%20%20%20%20position:%20relative;%5Cn%20%20%20%20display:%20inline-flex;%5Cn%20%20%7D%5Cn%5Cn%20%20&.overlay-validator%20%7B%5Cn%20%20%20%20caret-color:%20transparent;%5Cn%20%20%20%20cursor:%20default;%5Cn%20%20%20%20position:%20absolute;%5Cn%20%20%20%20background-color:%20transparent;%5Cn%20%20%20%20border:%20none;%5Cn%20%20%20%20outline:%20none;%5Cn%20%20%20%20pointer-events:%20none;%5Cn%20%20%20%20z-index:%209999;%5Cn%20%20%20%20left:%200;%5Cn%20%20%20%20top:%200;%5Cn%20%20%20%20width:%20100%25;%5Cn%20%20%20%20height:%20100%25;%5Cn%20%20%7D%5Cn%5Cn%20%20&.tooltip.tooltip-validator%20%7B%5Cn%20%20%20%20position:%20absolute;%5Cn%20%20%20%20top:%20calc(100%25%20+%208px);%5Cn%20%20%20%20width:%20max-content;%5Cn%20%20%7D%5Cn%7D%5Cn%22%5D%7D */\n";
|
|
27
27
|
export {
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The analysis is whole-program and type-aware: it uses the TypeScript language service's
|
|
17
17
|
* find-all-references to locate every use of each declaration, then classifies the tightest
|
|
18
|
-
* exposure that still covers all references.
|
|
18
|
+
* exposure that still covers all references. Because `findReferences` does not link a string-literal
|
|
19
|
+
* argument back to a member declaration when the parameter is a conditional/mapped key type (e.g.
|
|
20
|
+
* `bind(component, 'someSetting')` where the key is typed `ConditionalKeys<Settings, …>`), member
|
|
21
|
+
* analysis additionally treats a string literal whose text equals the member name as a reference —
|
|
22
|
+
* but only when its contextual type is a string-literal type (or union of them) all of whose members
|
|
23
|
+
* are keys of the declaring class, so incidental same-named strings (`console.log('name')`) are not
|
|
24
|
+
* miscounted. Members invoked by the framework via registration
|
|
19
25
|
* rather than by visible references (Obsidian lifecycle hooks, settings-tab `display`, etc.) are
|
|
20
26
|
* excluded via {@link LIFECYCLE_ALLOWLIST}, as are `override` and `static` members whose exposure is
|
|
21
27
|
* constrained by a base declaration. ECMAScript hard-private members (`#name`) are also excluded —
|
|
@@ -34,6 +40,12 @@
|
|
|
34
40
|
* {@link OverExposureFinding.skipReason}. Changes that cannot be safely automated — those forced
|
|
35
41
|
* only by test references, decorated members, or an `export` shared with a still-exported sibling —
|
|
36
42
|
* are reported as skipped and left untouched.
|
|
43
|
+
*
|
|
44
|
+
* Additionally passing `shouldForce` (only meaningful together with `shouldFix`) tightens the
|
|
45
|
+
* declarations held wide purely by test references too — the production half of the canonical
|
|
46
|
+
* test-only migration: the member becomes `private` / the `export` is dropped, leaving only the
|
|
47
|
+
* test to switch to a cast-based access. Decorated members and exports shared with a still-exported
|
|
48
|
+
* sibling stay skipped even under `shouldForce`, because no edit can be applied safely.
|
|
37
49
|
*/
|
|
38
50
|
import type { CompilerOptions, LanguageService, LanguageServiceHost } from 'typescript';
|
|
39
51
|
/**
|
|
@@ -54,6 +66,13 @@ export interface AnalyzeOverExposureParams {
|
|
|
54
66
|
* {@link OverExposureFinding.skipReason}. When `false` or omitted, the analysis only reports.
|
|
55
67
|
*/
|
|
56
68
|
readonly shouldFix?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* When `true` (only meaningful together with {@link shouldFix}), declarations held wide purely by
|
|
71
|
+
* test references are tightened too, instead of being skipped with a `test-only`
|
|
72
|
+
* {@link OverExposureFinding.skipReason}. Decorated members and exports shared with a
|
|
73
|
+
* still-exported sibling stay skipped regardless, because no edit can be applied safely.
|
|
74
|
+
*/
|
|
75
|
+
readonly shouldForce?: boolean | undefined;
|
|
57
76
|
/**
|
|
58
77
|
* Absolute (canonical) path of the project's `src` folder. Only declarations in non-test files
|
|
59
78
|
* under this folder are analyzed; declarations elsewhere (test files, dependencies) are ignored
|
|
@@ -108,6 +127,13 @@ export interface FindOverExposureParams {
|
|
|
108
127
|
* project is only analyzed.
|
|
109
128
|
*/
|
|
110
129
|
readonly shouldFix?: boolean | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* When `true` (only meaningful together with {@link shouldFix}), declarations held wide purely by
|
|
132
|
+
* test references are tightened too, instead of being skipped. Decorated members and exports
|
|
133
|
+
* shared with a still-exported sibling stay skipped regardless. Forwarded to
|
|
134
|
+
* {@link analyzeOverExposure}.
|
|
135
|
+
*/
|
|
136
|
+
readonly shouldForce?: boolean | undefined;
|
|
111
137
|
}
|
|
112
138
|
/**
|
|
113
139
|
* Options for {@link formatOverExposureFindings}.
|
|
@@ -226,7 +252,9 @@ export declare const LIFECYCLE_ALLOWLIST: ReadonlySet<string>;
|
|
|
226
252
|
* when {@link AnalyzeOverExposureParams.shouldFix} is set — tightens every fixable finding in place
|
|
227
253
|
* via {@link AnalyzeOverExposureParams.writeFile}. Findings that cannot be safely automated (exposed
|
|
228
254
|
* only for tests, decorated, or sharing an `export` keyword with a still-exported sibling) carry a
|
|
229
|
-
* {@link OverExposureFinding.skipReason} and are left untouched
|
|
255
|
+
* {@link OverExposureFinding.skipReason} and are left untouched — unless
|
|
256
|
+
* {@link AnalyzeOverExposureParams.shouldForce} is set, which additionally tightens the test-only
|
|
257
|
+
* findings (decorated and shared-export ones still stay skipped).
|
|
230
258
|
*
|
|
231
259
|
* @param params - The {@link AnalyzeOverExposureParams}.
|
|
232
260
|
* @returns The over-exposed declarations, in discovery order.
|