tackbox 0.1.79 → 0.1.81
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 +4 -1
- package/js/rules/_shared.js +11 -3
- package/package.json +1 -1
package/bin/tackbox-eslint.js
CHANGED
|
@@ -115,7 +115,10 @@ 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. Split on
|
|
119
|
+
// the platform separator, never a blanket replace: off Windows a `\` in a
|
|
120
|
+
// name is part of the name and rewriting it misfiles the finding.
|
|
121
|
+
const file = path.relative(process.cwd(), r.filePath).split(path.sep).join('/')
|
|
119
122
|
for (const m of r.messages) {
|
|
120
123
|
if (m.severity !== 2) continue
|
|
121
124
|
process.stdout.write(JSON.stringify({ file, line: m.line ?? null, rule: m.ruleId, message: m.message }) + '\n')
|
package/js/rules/_shared.js
CHANGED
|
@@ -158,10 +158,18 @@ 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. Only the platform separator
|
|
163
|
+
// is rewritten - off Windows `\` is a legal file name character, and replacing
|
|
164
|
+
// it would invent a key that never matches git's own spelling.
|
|
165
|
+
function toPosix(p) {
|
|
166
|
+
return p.split(path.sep).join('/')
|
|
167
|
+
}
|
|
168
|
+
|
|
161
169
|
function relFile(context) {
|
|
162
170
|
const fn = context.filename || (context.getFilename && context.getFilename()) || ''
|
|
163
171
|
const cwd = context.cwd || process.cwd()
|
|
164
|
-
return path.isAbsolute(fn) ? path.relative(cwd, fn) : fn
|
|
172
|
+
return toPosix(path.isAbsolute(fn) ? path.relative(cwd, fn) : fn)
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
// Module extensions, compound first: a specifier that omits the extension must
|
|
@@ -235,7 +243,7 @@ function resolveAlias(context, source, absImporter) {
|
|
|
235
243
|
dir = up
|
|
236
244
|
}
|
|
237
245
|
if (root === null) return null
|
|
238
|
-
return path.relative(context.cwd || process.cwd(), path.join(root, 'src', 'lib', rest))
|
|
246
|
+
return toPosix(path.relative(context.cwd || process.cwd(), path.join(root, 'src', 'lib', rest)))
|
|
239
247
|
}
|
|
240
248
|
|
|
241
249
|
// resolveDeclTarget resolves an Identifier callee to the {file, name} of its
|
|
@@ -252,7 +260,7 @@ function resolveDeclTarget(context, idNode) {
|
|
|
252
260
|
const importedName = info.kind === 'named' ? info.imported : idNode.name
|
|
253
261
|
let resolved
|
|
254
262
|
if (source.startsWith('.')) {
|
|
255
|
-
resolved = path.normalize(path.join(path.dirname(relFile(context)), source))
|
|
263
|
+
resolved = path.posix.normalize(path.posix.join(path.posix.dirname(relFile(context)), source))
|
|
256
264
|
} else {
|
|
257
265
|
resolved = resolveAlias(context, source, absFile(context))
|
|
258
266
|
if (resolved === null) return null
|
package/package.json
CHANGED