@jterrazz/typescript 10.2.0 → 10.2.1
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/lib/check-suppressions.js +31 -12
- package/package.json +1 -1
|
@@ -75,7 +75,8 @@ const hasReason = (tail) => (tail.split(REASON)[1] ?? '').replace(/\*\/\s*$/u, '
|
|
|
75
75
|
*
|
|
76
76
|
* A JS plugin's rules never appear in `--print-config`, so a directive naming
|
|
77
77
|
* one is unverifiable — and the gate says nothing rather than calling a live
|
|
78
|
-
* rule dead.
|
|
78
|
+
* rule dead. The namespaces returned are therefore the ones the printed config
|
|
79
|
+
* can ANSWER for: the plugins it loaded, and never a JS plugin's.
|
|
79
80
|
*/
|
|
80
81
|
function resolveConfig(root, oxlint) {
|
|
81
82
|
let printed;
|
|
@@ -89,21 +90,33 @@ function resolveConfig(root, oxlint) {
|
|
|
89
90
|
return null;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
let
|
|
93
|
+
let resolved;
|
|
93
94
|
try {
|
|
94
|
-
|
|
95
|
-
rules = { ...resolved.rules };
|
|
96
|
-
/* A rule armed only in an override — a test-file rule, a layer's
|
|
97
|
-
* `no-restricted-imports` — is live for the files it names. */
|
|
98
|
-
for (const override of resolved.overrides ?? []) {
|
|
99
|
-
for (const [name, level] of Object.entries(override.rules ?? {})) {
|
|
100
|
-
rules[name] ??= level;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
95
|
+
resolved = JSON.parse(printed);
|
|
103
96
|
} catch {
|
|
104
97
|
return null;
|
|
105
98
|
}
|
|
106
99
|
|
|
100
|
+
const rules = { ...resolved.rules };
|
|
101
|
+
/* A rule armed only in an override — a test-file rule, a layer's
|
|
102
|
+
* `no-restricted-imports` — is live for the files it names. */
|
|
103
|
+
for (const override of resolved.overrides ?? []) {
|
|
104
|
+
for (const [name, level] of Object.entries(override.rules ?? {})) {
|
|
105
|
+
rules[name] ??= level;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return { namespaces: namespacesOf(resolved, rules), rules };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The namespaces the printed config can ANSWER for. Where it loads a JS plugin,
|
|
114
|
+
* a namespace outside the plugins it printed is that plugin's, and the map holds
|
|
115
|
+
* at most the few of its rules a `rules` or `allow` entry happened to name —
|
|
116
|
+
* never the live ones. Such a namespace is dropped rather than read as evidence
|
|
117
|
+
* that every OTHER rule of it is off.
|
|
118
|
+
*/
|
|
119
|
+
function namespacesOf(resolved, rules) {
|
|
107
120
|
const namespaces = new Set();
|
|
108
121
|
for (const name of Object.keys(rules)) {
|
|
109
122
|
if (name.includes('/')) {
|
|
@@ -111,7 +124,13 @@ function resolveConfig(root, oxlint) {
|
|
|
111
124
|
}
|
|
112
125
|
}
|
|
113
126
|
|
|
114
|
-
|
|
127
|
+
if ((resolved.jsPlugins?.length ?? 0) === 0) {
|
|
128
|
+
return namespaces;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const loaded = new Set(resolved.plugins);
|
|
132
|
+
|
|
133
|
+
return new Set([...namespaces].filter((namespace) => loaded.has(namespace)));
|
|
115
134
|
}
|
|
116
135
|
|
|
117
136
|
/** Where a named rule stands for this project: `live`, `dead`, or `unverifiable`. */
|