From fb54cca0b49ad3f3287dc5edc93c97577fa6b1ba Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:24:17 +0000 Subject: [PATCH 1/2] Implement fix flag for tsc lint Updates `cli/src/commands/migrate.rs` to expose `migrate_source` publicly. Updates `cli/src/commands/lint.rs` to consume `migrate_source` when the `--fix` flag is true, conditionally modifying file content to remove deprecations before linting is finalized. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- cli/src/commands/lint.rs | 19 +++++++++++++++++++ cli/src/commands/migrate.rs | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/lint.rs b/cli/src/commands/lint.rs index 5726cd9d..203664d6 100644 --- a/cli/src/commands/lint.rs +++ b/cli/src/commands/lint.rs @@ -4,6 +4,7 @@ use crate::exit_code::ExitCode; use std::path::{Path, PathBuf}; +use crate::commands::migrate::migrate_source; pub fn execute(path_str: Option<&str>, fix: bool) -> ExitCode { let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); @@ -43,6 +44,7 @@ pub fn execute(path_str: Option<&str>, fix: bool) -> ExitCode { let linter = techscript_linter::Linter::new(); let mut violation_count = 0; + let mut fixed_count = 0; for file in files_to_lint { if let Ok(content) = std::fs::read_to_string(&file) { @@ -66,9 +68,26 @@ pub fn execute(path_str: Option<&str>, fix: bool) -> ExitCode { } } } + + // Fix deprecation warnings + if fix { + let migrated = migrate_source(&content); + if migrated != content { + if let Err(e) = std::fs::write(&file, migrated) { + eprintln!("Error writing fixed file {:?}: {}", file, e); + } else { + println!("Fixed deprecated keywords in: {:?}", file); + fixed_count += 1; + } + } + } } } + if fix && fixed_count > 0 { + println!("Fixed deprecation warnings in {} file(s).", fixed_count); + } + if violation_count > 0 { println!("Linting found {} violation(s).", violation_count); ExitCode::LintFailure diff --git a/cli/src/commands/migrate.rs b/cli/src/commands/migrate.rs index 8bbd611d..292592b6 100644 --- a/cli/src/commands/migrate.rs +++ b/cli/src/commands/migrate.rs @@ -66,7 +66,7 @@ pub fn execute(path_str: Option<&str>) -> ExitCode { ExitCode::Success } -fn migrate_source(source: &str) -> String { +pub fn migrate_source(source: &str) -> String { let mut reporter = techscript_errors::DiagnosticReporter::new(); let tokens = techscript_lexer::lex_recovered(source, &mut reporter); let _program = techscript_parser::parse_recovered(&tokens, &mut reporter); From 531ec3a82ebf51c86ab624f36c0060393be4e1b6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:47:03 +0000 Subject: [PATCH 2/2] Implement fix flag for tsc lint Updates `cli/src/commands/migrate.rs` to expose `migrate_source` publicly. Updates `cli/src/commands/lint.rs` to consume `migrate_source` when the `--fix` flag is true, conditionally modifying file content to remove deprecations before linting is finalized. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- cli/src/commands/lint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/lint.rs b/cli/src/commands/lint.rs index 203664d6..e2c1e182 100644 --- a/cli/src/commands/lint.rs +++ b/cli/src/commands/lint.rs @@ -2,9 +2,9 @@ //! //! Performs static analysis linting on TechScript sources. +use crate::commands::migrate::migrate_source; use crate::exit_code::ExitCode; use std::path::{Path, PathBuf}; -use crate::commands::migrate::migrate_source; pub fn execute(path_str: Option<&str>, fix: bool) -> ExitCode { let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));