diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 440088ec0f7a6..2bc8c25176616 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -341,6 +341,13 @@ impl CliRunner { let config_store = ConfigStore::new(lint_config, nested_configs, external_plugin_store); let type_aware = self.options.type_aware || config_store.type_aware_enabled(); let type_check = self.options.type_check || config_store.type_check_enabled(); + if type_check && !type_aware { + print_and_flush_stdout( + stdout, + "The `--type-check` option requires type-aware linting.\nUse `--type-aware --type-check` or enable `options.typeAware` in your config.\n", + ); + return CliRunResult::InvalidOptionTypeCheckWithoutTypeAware; + } let deny_warnings = warning_options.deny_warnings || config_store.deny_warnings(); let max_warnings = warning_options.max_warnings.or(config_store.max_warnings()); @@ -1332,6 +1339,13 @@ mod test { Tester::new().with_cwd("fixtures/tsgolint_type_error".into()).test_and_snapshot(args); } + #[test] + #[cfg(not(target_endian = "big"))] + fn test_tsgolint_type_check_requires_type_aware() { + let args = &["--type-check"]; + Tester::new().with_cwd("fixtures/tsgolint_type_error".into()).test_and_snapshot(args); + } + #[test] #[cfg(not(target_endian = "big"))] fn test_tsgolint_type_check_via_config_file() { diff --git a/apps/oxlint/src/result.rs b/apps/oxlint/src/result.rs index 790c0a26a7818..5ac1491df1ed8 100644 --- a/apps/oxlint/src/result.rs +++ b/apps/oxlint/src/result.rs @@ -6,6 +6,7 @@ pub enum CliRunResult { JsPluginWorkspaceSetupFailed, InvalidOptionConfig, InvalidOptionTsConfig, + InvalidOptionTypeCheckWithoutTypeAware, InvalidOptionSeverityWithoutFilter, InvalidOptionSeverityWithoutPluginName, InvalidOptionSeverityWithoutRuleName, @@ -36,6 +37,7 @@ impl Termination for CliRunResult { | Self::LintMaxWarningsExceeded | Self::InvalidOptionConfig | Self::InvalidOptionTsConfig + | Self::InvalidOptionTypeCheckWithoutTypeAware | Self::InvalidOptionSeverityWithoutFilter | Self::InvalidOptionSeverityWithoutPluginName | Self::InvalidOptionSeverityWithoutRuleName diff --git a/apps/oxlint/src/snapshots/fixtures__tsgolint_type_error_--type-check@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__tsgolint_type_error_--type-check@oxlint.snap new file mode 100644 index 0000000000000..901c8980f4e39 --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__tsgolint_type_error_--type-check@oxlint.snap @@ -0,0 +1,12 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: --type-check +working directory: fixtures/tsgolint_type_error +---------- +The `--type-check` option requires type-aware linting. +Use `--type-aware --type-check` or enable `options.typeAware` in your config. +---------- +CLI result: InvalidOptionTypeCheckWithoutTypeAware +----------