fix(plugin): close the review's gaps in names, prompts and the generated test
The collision check scanned the whole file as text, so every scaffolded app refused `core`, `tea` or `module` because they appear inside import strings. It now reads identifiers from the parse tree. Typing `npm` at the registry question silently produced a JSR-only package. An answer that is not offered is now asked again. The generated test only awaited boot(); it now checks the plugin's token is in app.graph(), and fails if it is not. engines.node moves to >=22.18, the first Node that runs `node --test` on .ts unflagged. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+163
-29
No files matched your search
@@ -110,16 +110,6 @@ pub fn is_reserved(ident: &str) -> bool {
|
||||
RESERVED.contains(&ident)
|
||||
}
|
||||
|
||||
/// True when `ident` appears as a whole identifier anywhere in `src`.
|
||||
///
|
||||
/// ponytail: a token scan, not a parse, so a match inside a comment or a string
|
||||
/// also counts. That refuses a name that would have been fine, never the other
|
||||
/// way round; a scope-aware check is the upgrade if it ever gets in the way.
|
||||
pub fn used_in(src: &str, ident: &str) -> bool {
|
||||
src.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == '$'))
|
||||
.any(|token| token == ident)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -149,11 +139,6 @@ mod tests {
|
||||
assert!(is_reserved("delete"));
|
||||
assert!(is_reserved("class"));
|
||||
assert!(!is_reserved("pluginAlgo"));
|
||||
let src = "import { createApp } from 'x';\nexport const app = createApp({});\n";
|
||||
assert!(used_in(src, "createApp"));
|
||||
assert!(used_in(src, "app"));
|
||||
assert!(!used_in(src, "appModule"));
|
||||
assert!(!used_in(src, "create"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user