rip-lang 3.13.81 → 3.13.83
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/README.md +1 -1
- package/bin/rip +6 -1
- package/package.json +1 -1
- package/src/typecheck.js +27 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.83-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1%2C436%2F1%2C436-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
package/bin/rip
CHANGED
|
@@ -124,7 +124,12 @@ async function main() {
|
|
|
124
124
|
|
|
125
125
|
if (args[0] === 'check') {
|
|
126
126
|
const { runCheck } = await import('../src/typecheck.js');
|
|
127
|
-
const
|
|
127
|
+
const checkArgs = args.slice(1);
|
|
128
|
+
const dir = checkArgs.find(a => !a.startsWith('-')) || '.';
|
|
129
|
+
const exitCode = await runCheck(dir, {
|
|
130
|
+
quiet: checkArgs.includes('-q') || checkArgs.includes('--quiet'),
|
|
131
|
+
allowAny: checkArgs.includes('--allow-any'),
|
|
132
|
+
});
|
|
128
133
|
process.exit(exitCode);
|
|
129
134
|
}
|
|
130
135
|
|
package/package.json
CHANGED
package/src/typecheck.js
CHANGED
|
@@ -322,6 +322,32 @@ export async function runCheck(targetDir, opts = {}) {
|
|
|
322
322
|
else if (severity === 'warning') totalWarnings++;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
// Untyped component prop checking — flag props without :: annotation
|
|
326
|
+
if (!opts.allowAny && entry.dts) {
|
|
327
|
+
const dtsLines = entry.dts.split('\n');
|
|
328
|
+
const srcLines = entry.source.split('\n');
|
|
329
|
+
for (let d = 0; d < dtsLines.length; d++) {
|
|
330
|
+
const cm = dtsLines[d].match(/^export declare class (\w+)/);
|
|
331
|
+
if (!cm) continue;
|
|
332
|
+
for (let p = d + 1; p < dtsLines.length; p++) {
|
|
333
|
+
if (/^\}/.test(dtsLines[p])) break;
|
|
334
|
+
const pm = dtsLines[p].match(/^\s+(\w+)\??\s*:/);
|
|
335
|
+
if (!pm) continue;
|
|
336
|
+
const propName = pm[1];
|
|
337
|
+
for (let s = 0; s < srcLines.length; s++) {
|
|
338
|
+
const m = new RegExp('@' + propName + '\\s*(::|([:!]?=))').exec(srcLines[s]);
|
|
339
|
+
if (m) {
|
|
340
|
+
if (m[1] !== '::') {
|
|
341
|
+
errors.push({ line: s + 1, message: `Prop '${propName}' on component ${cm[1]} has no type annotation`, severity: 'error', code: 'rip' });
|
|
342
|
+
totalErrors++;
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
325
351
|
if (errors.length > 0) {
|
|
326
352
|
fileResults.push({ file: fp, errors });
|
|
327
353
|
}
|
|
@@ -333,7 +359,7 @@ export async function runCheck(targetDir, opts = {}) {
|
|
|
333
359
|
for (const e of errors) {
|
|
334
360
|
const loc = `${cyan(rel)}${dim(':')}${yellow(String(e.line))}`;
|
|
335
361
|
const sev = e.severity === 'error' ? red('error') : yellow('warning');
|
|
336
|
-
console.log(`${loc} ${sev} ${e.message} ${dim(`TS${e.code}`)}`);
|
|
362
|
+
console.log(`${loc} ${sev} ${e.message} ${dim(typeof e.code === 'number' ? `TS${e.code}` : '')}`);
|
|
337
363
|
}
|
|
338
364
|
}
|
|
339
365
|
|