tackbox 0.1.78 → 0.1.80
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/bin/tackbox-eslint.js +2 -1
- package/js/report.js +1 -2
- package/js/rules/_shared.js +13 -7
- package/js/rules/no-swallow-catch.js +1 -1
- package/package.json +1 -1
package/bin/tackbox-eslint.js
CHANGED
|
@@ -115,7 +115,8 @@ function validateDeclarations(decls) {
|
|
|
115
115
|
// line: null (location-unknown) - the caller over-reports, never drops it.
|
|
116
116
|
function emitMachine(results) {
|
|
117
117
|
for (const r of results) {
|
|
118
|
-
|
|
118
|
+
// The contract path is POSIX; path.relative yields `\` on Windows.
|
|
119
|
+
const file = path.relative(process.cwd(), r.filePath).replace(/\\/g, '/')
|
|
119
120
|
for (const m of r.messages) {
|
|
120
121
|
if (m.severity !== 2) continue
|
|
121
122
|
process.stdout.write(JSON.stringify({ file, line: m.line ?? null, rule: m.ruleId, message: m.message }) + '\n')
|
package/js/report.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Browser report helper: empty DSN = log-only no-op.
|
|
2
|
-
//
|
|
3
|
-
// Sentry capture, optional diagnostic stream.
|
|
2
|
+
// Single funnel for toast, Sentry capture, optional diagnostic stream.
|
|
4
3
|
|
|
5
4
|
const Sentry = require('@sentry/browser')
|
|
6
5
|
|
package/js/rules/_shared.js
CHANGED
|
@@ -158,10 +158,16 @@ function declaredReporters(context) {
|
|
|
158
158
|
return Array.isArray(s) ? s : []
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
// Declarations are POSIX; path.relative hands back `\` on Windows, and a key
|
|
162
|
+
// that keeps it stops matching its own declaration.
|
|
163
|
+
function toPosix(p) {
|
|
164
|
+
return p.replace(/\\/g, '/')
|
|
165
|
+
}
|
|
166
|
+
|
|
161
167
|
function relFile(context) {
|
|
162
168
|
const fn = context.filename || (context.getFilename && context.getFilename()) || ''
|
|
163
169
|
const cwd = context.cwd || process.cwd()
|
|
164
|
-
return path.isAbsolute(fn) ? path.relative(cwd, fn) : fn
|
|
170
|
+
return toPosix(path.isAbsolute(fn) ? path.relative(cwd, fn) : fn)
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
// Module extensions, compound first: a specifier that omits the extension must
|
|
@@ -235,7 +241,7 @@ function resolveAlias(context, source, absImporter) {
|
|
|
235
241
|
dir = up
|
|
236
242
|
}
|
|
237
243
|
if (root === null) return null
|
|
238
|
-
return path.relative(context.cwd || process.cwd(), path.join(root, 'src', 'lib', rest))
|
|
244
|
+
return toPosix(path.relative(context.cwd || process.cwd(), path.join(root, 'src', 'lib', rest)))
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
// resolveDeclTarget resolves an Identifier callee to the {file, name} of its
|
|
@@ -252,7 +258,7 @@ function resolveDeclTarget(context, idNode) {
|
|
|
252
258
|
const importedName = info.kind === 'named' ? info.imported : idNode.name
|
|
253
259
|
let resolved
|
|
254
260
|
if (source.startsWith('.')) {
|
|
255
|
-
resolved = path.normalize(path.join(path.dirname(relFile(context)), source))
|
|
261
|
+
resolved = path.posix.normalize(path.posix.join(path.posix.dirname(relFile(context)), source))
|
|
256
262
|
} else {
|
|
257
263
|
resolved = resolveAlias(context, source, absFile(context))
|
|
258
264
|
if (resolved === null) return null
|
|
@@ -438,9 +444,9 @@ function hasMarkerAbove(context, node, prefix) {
|
|
|
438
444
|
// One coherent path analysis for all three legal catch exits: throw and a
|
|
439
445
|
// Result-boundary return terminate a path; a recognized reporter call is a
|
|
440
446
|
// sticky event (statements after it on the path are fine). A path reaching the
|
|
441
|
-
// end of the handler without a terminator or event swallows.
|
|
442
|
-
//
|
|
443
|
-
// Result-boundary is kin to the policy layer
|
|
447
|
+
// end of the handler without a terminator or event swallows. Reporter
|
|
448
|
+
// recognition stays tackbox origin-gating.
|
|
449
|
+
// Result-boundary is kin to the error-policy layer:
|
|
444
450
|
// annotation-based (no type program) - only a syntactic Result / Attempt /
|
|
445
451
|
// Promise<Result|Attempt> return type earns the boundary credit.
|
|
446
452
|
|
|
@@ -633,7 +639,7 @@ function isBareErrReturn(expr, errName) {
|
|
|
633
639
|
// return), 'bad' (some path exits unhandled), { reported } (falls through;
|
|
634
640
|
// reported true when every falling path passed the sticky event). Constructs
|
|
635
641
|
// not modeled (switch, loops, nested try) are opaque: a hidden return fails
|
|
636
|
-
// closed, reporters inside do not count.
|
|
642
|
+
// closed, reporters inside do not count. returnIdentity
|
|
637
643
|
// credits `return <errName>` as terminal (promise handlers only: the settled
|
|
638
644
|
// value is the error object itself).
|
|
639
645
|
function makeHandledAnalysis(opts) {
|
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
module.exports = {
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'problem',
|
|
11
|
-
docs: { description: 'every path out of a catch must throw, call a reporter, convert to a Result boundary (return { ok: false, cause: err } when the function returns Result/Attempt), or the try must carry a // no-report: marker. Boundary conversion is kin to the policy layer
|
|
11
|
+
docs: { description: 'every path out of a catch must throw, call a reporter, convert to a Result boundary (return { ok: false, cause: err } when the function returns Result/Attempt), or the try must carry a // no-report: marker. Boundary conversion is kin to the policy layer.' },
|
|
12
12
|
messages: {
|
|
13
13
|
swallow: 'every catch path must throw, call a reporter, or convert to a Result boundary',
|
|
14
14
|
},
|
package/package.json
CHANGED