From 5bf595d6f7e75bfcfef6cf47f0ca02c7b7f211cb Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 24 May 2024 12:34:10 +0800 Subject: [PATCH] refactor(linter): rename variable names prefix `ESLint` to `Oxlint` --- crates/oxc_cli/src/command/lint.rs | 8 +- crates/oxc_linter/src/config/env.rs | 12 +-- crates/oxc_linter/src/config/globals.rs | 4 +- crates/oxc_linter/src/config/mod.rs | 24 +++--- crates/oxc_linter/src/config/rules.rs | 28 +++--- crates/oxc_linter/src/config/settings/mod.rs | 8 +- crates/oxc_linter/src/context.rs | 14 +-- crates/oxc_linter/src/lib.rs | 8 +- crates/oxc_linter/src/options.rs | 6 +- .../src/rules/react/rules_of_hooks.rs | 2 +- crates/oxc_linter/src/tester.rs | 6 +- crates/oxc_linter/src/utils/react.rs | 4 +- tasks/website/src/linter/cli.rs | 8 ++ tasks/website/src/linter/json_schema.rs | 6 +- tasks/website/src/linter/snapshots/cli.snap | 10 +-- .../src/linter/snapshots/cli_terminal.snap | 77 +++++++++++++++++ .../src/linter/snapshots/schema_json.snap | 86 +++++++++---------- 17 files changed, 198 insertions(+), 113 deletions(-) create mode 100644 tasks/website/src/linter/snapshots/cli_terminal.snap diff --git a/crates/oxc_cli/src/command/lint.rs b/crates/oxc_cli/src/command/lint.rs index a2498e4e7d103..faea05d0b4adb 100644 --- a/crates/oxc_cli/src/command/lint.rs +++ b/crates/oxc_cli/src/command/lint.rs @@ -63,10 +63,10 @@ pub struct LintOptions { /// Basic Configuration #[derive(Debug, Clone, Bpaf)] pub struct BasicOptions { - /// ESLint configuration file (experimental) - /// - /// * only `.json` extension is supported - #[bpaf(long, short, argument("./eslintrc.json"))] + /// Oxlint configuration file (experimental) + /// * only `.json` extension is supported + /// * tries to be compatible with the ESLint v8's format + #[bpaf(long, short, argument("./oxlintrc.json"))] pub config: Option, /// TypeScript `tsconfig.json` path for reading path alias and project references for import plugin diff --git a/crates/oxc_linter/src/config/env.rs b/crates/oxc_linter/src/config/env.rs index 2e9a682d42c18..4c7bddf63389b 100644 --- a/crates/oxc_linter/src/config/env.rs +++ b/crates/oxc_linter/src/config/env.rs @@ -6,9 +6,9 @@ use serde::Deserialize; // TODO: list the keys we support // #[derive(Debug, Clone, Deserialize, JsonSchema)] -pub struct ESLintEnv(FxHashMap); +pub struct OxlintEnv(FxHashMap); -impl ESLintEnv { +impl OxlintEnv { pub fn from_vec(env: Vec) -> Self { let map = env.into_iter().map(|key| (key, true)).collect(); @@ -21,7 +21,7 @@ impl ESLintEnv { } } -impl Default for ESLintEnv { +impl Default for OxlintEnv { fn default() -> Self { let mut map = FxHashMap::default(); map.insert("builtin".to_string(), true); @@ -32,13 +32,13 @@ impl Default for ESLintEnv { #[cfg(test)] mod test { - use super::ESLintEnv; + use super::OxlintEnv; use itertools::Itertools; use serde::Deserialize; #[test] fn test_parse_env() { - let env = ESLintEnv::deserialize(&serde_json::json!({ + let env = OxlintEnv::deserialize(&serde_json::json!({ "browser": true, "node": true, "es6": false })) .unwrap(); @@ -50,7 +50,7 @@ mod test { } #[test] fn test_parse_env_default() { - let env = ESLintEnv::default(); + let env = OxlintEnv::default(); assert_eq!(env.iter().count(), 1); assert!(env.iter().contains(&"builtin")); } diff --git a/crates/oxc_linter/src/config/globals.rs b/crates/oxc_linter/src/config/globals.rs index d9f246e060f6a..94896f4b580a1 100644 --- a/crates/oxc_linter/src/config/globals.rs +++ b/crates/oxc_linter/src/config/globals.rs @@ -6,7 +6,7 @@ use rustc_hash::FxHashMap; /// Add or remove global variables. // #[derive(Debug, Default, Deserialize, JsonSchema)] -pub struct ESLintGlobals(FxHashMap); +pub struct OxlintGlobals(FxHashMap); // TODO: support deprecated `false` #[derive(Debug, Eq, PartialEq, Deserialize, JsonSchema)] @@ -17,7 +17,7 @@ pub enum GlobalValue { Off, } -impl ESLintGlobals { +impl OxlintGlobals { pub fn is_enabled(&self, name: &str) -> bool { self.0.get(name).is_some_and(|value| *value != GlobalValue::Off) } diff --git a/crates/oxc_linter/src/config/mod.rs b/crates/oxc_linter/src/config/mod.rs index 6717fe67a22db..6414e466bb0fb 100644 --- a/crates/oxc_linter/src/config/mod.rs +++ b/crates/oxc_linter/src/config/mod.rs @@ -13,8 +13,8 @@ use serde::Deserialize; use crate::{rules::RuleEnum, AllowWarnDeny, RuleWithSeverity}; pub use self::{ - env::ESLintEnv, globals::ESLintGlobals, rules::ESLintRules, - settings::jsdoc::JSDocPluginSettings, settings::ESLintSettings, + env::OxlintEnv, globals::OxlintGlobals, rules::OxlintRules, + settings::jsdoc::JSDocPluginSettings, settings::OxlintSettings, }; /// Oxlint Configuration File @@ -50,15 +50,15 @@ pub use self::{ /// ``` #[derive(Debug, Default, Deserialize, JsonSchema)] #[serde(default)] -pub struct ESLintConfig { +pub struct OxlintConfig { /// See [Oxlint Rules](./rules) - pub(crate) rules: ESLintRules, - pub(crate) settings: ESLintSettings, - pub(crate) env: ESLintEnv, - pub(crate) globals: ESLintGlobals, + pub(crate) rules: OxlintRules, + pub(crate) settings: OxlintSettings, + pub(crate) env: OxlintEnv, + pub(crate) globals: OxlintGlobals, } -impl ESLintConfig { +impl OxlintConfig { /// # Errors /// /// * Parse Failure @@ -169,20 +169,20 @@ impl ESLintConfig { #[cfg(test)] mod test { - use super::ESLintConfig; + use super::OxlintConfig; use serde::Deserialize; use std::env; #[test] fn test_from_file() { let fixture_path = env::current_dir().unwrap().join("fixtures/eslint_config.json"); - let config = ESLintConfig::from_file(&fixture_path).unwrap(); + let config = OxlintConfig::from_file(&fixture_path).unwrap(); assert!(!config.rules.is_empty()); } #[test] fn test_deserialize() { - let config = ESLintConfig::deserialize(&serde_json::json!({ + let config = OxlintConfig::deserialize(&serde_json::json!({ "rules": { "no-console": "off", "no-debugger": 2, @@ -212,7 +212,7 @@ mod test { })); assert!(config.is_ok()); - let ESLintConfig { rules, settings, env, globals } = config.unwrap(); + let OxlintConfig { rules, settings, env, globals } = config.unwrap(); assert!(!rules.is_empty()); assert_eq!(settings.jsx_a11y.polymorphic_prop_name, Some("role".to_string())); assert_eq!(env.iter().count(), 1); diff --git a/crates/oxc_linter/src/config/rules.rs b/crates/oxc_linter/src/config/rules.rs index bf690f1931449..9188b2477077e 100644 --- a/crates/oxc_linter/src/config/rules.rs +++ b/crates/oxc_linter/src/config/rules.rs @@ -15,7 +15,7 @@ use crate::AllowWarnDeny; // - type RuleConf = SeverityConf | [SeverityConf, ...any[]]; // #[derive(Debug, Clone, Default)] -pub struct ESLintRules(Vec); +pub struct OxlintRules(Vec); #[derive(Debug, Clone)] pub struct ESLintRule { @@ -25,13 +25,13 @@ pub struct ESLintRule { pub config: Option, } -impl JsonSchema for ESLintRules { +impl JsonSchema for OxlintRules { fn schema_name() -> String { - "ESLintRules".to_owned() + "OxlintRules".to_owned() } fn schema_id() -> Cow<'static, str> { - Cow::Borrowed("ESLintRules") + Cow::Borrowed("OxlintRules") } fn json_schema(gen: &mut SchemaGenerator) -> Schema { @@ -52,15 +52,15 @@ impl JsonSchema for ESLintRules { // - Handle single value form and array form // - SeverityConf into AllowWarnDeny // - Align plugin names -impl<'de> Deserialize<'de> for ESLintRules { +impl<'de> Deserialize<'de> for OxlintRules { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct ESLintRulesVisitor; + struct OxlintRulesVisitor; - impl<'de> Visitor<'de> for ESLintRulesVisitor { - type Value = ESLintRules; + impl<'de> Visitor<'de> for OxlintRulesVisitor { + type Value = OxlintRules; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Record") @@ -77,11 +77,11 @@ impl<'de> Deserialize<'de> for ESLintRules { rules.push(ESLintRule { plugin_name, rule_name, severity, config }); } - Ok(ESLintRules(rules)) + Ok(OxlintRules(rules)) } } - deserializer.deserialize_any(ESLintRulesVisitor) + deserializer.deserialize_any(OxlintRulesVisitor) } } @@ -145,7 +145,7 @@ fn parse_rule_value( } } -impl Deref for ESLintRules { +impl Deref for OxlintRules { type Target = Vec; fn deref(&self) -> &Self::Target { @@ -159,12 +159,12 @@ fn failed_to_parse_rule_value(value: &str, err: &str) -> OxcDiagnostic { #[cfg(test)] mod test { - use super::ESLintRules; + use super::OxlintRules; use serde::Deserialize; #[test] fn test_parse_rules() { - let rules = ESLintRules::deserialize(&serde_json::json!({ + let rules = OxlintRules::deserialize(&serde_json::json!({ "no-console": "off", "foo/no-unused-vars": [1], "dummy": ["error", "arg1", "args2"], @@ -200,7 +200,7 @@ mod test { #[test] fn test_parse_rules_default() { - let rules = ESLintRules::default(); + let rules = OxlintRules::default(); assert!(rules.is_empty()); } } diff --git a/crates/oxc_linter/src/config/settings/mod.rs b/crates/oxc_linter/src/config/settings/mod.rs index ae44000930492..58a7d7ca3cce8 100644 --- a/crates/oxc_linter/src/config/settings/mod.rs +++ b/crates/oxc_linter/src/config/settings/mod.rs @@ -13,7 +13,7 @@ use self::{ /// Shared settings for plugins #[derive(Debug, Deserialize, Default, JsonSchema)] -pub struct ESLintSettings { +pub struct OxlintSettings { #[serde(default)] #[serde(rename = "jsx-a11y")] pub jsx_a11y: JSXA11yPluginSettings, @@ -30,12 +30,12 @@ pub struct ESLintSettings { #[cfg(test)] mod test { - use super::ESLintSettings; + use super::OxlintSettings; use serde::Deserialize; #[test] fn test_parse_settings() { - let settings = ESLintSettings::deserialize(&serde_json::json!({ + let settings = OxlintSettings::deserialize(&serde_json::json!({ "jsx-a11y": { "polymorphicPropName": "role", "components": { @@ -82,7 +82,7 @@ mod test { #[test] fn test_parse_settings_default() { - let settings = ESLintSettings::default(); + let settings = OxlintSettings::default(); assert!(settings.jsx_a11y.polymorphic_prop_name.is_none()); assert!(settings.jsx_a11y.components.is_empty()); } diff --git a/crates/oxc_linter/src/context.rs b/crates/oxc_linter/src/context.rs index 80d94f2964a42..8e735811d7209 100644 --- a/crates/oxc_linter/src/context.rs +++ b/crates/oxc_linter/src/context.rs @@ -9,7 +9,7 @@ use crate::{ disable_directives::{DisableDirectives, DisableDirectivesBuilder}, fixer::{Fix, Message}, javascript_globals::GLOBALS, - AllowWarnDeny, ESLintConfig, ESLintEnv, ESLintGlobals, ESLintSettings, + AllowWarnDeny, OxlintConfig, OxlintEnv, OxlintGlobals, OxlintSettings, }; #[derive(Clone)] @@ -25,7 +25,7 @@ pub struct LintContext<'a> { file_path: Rc, - eslint_config: Arc, + eslint_config: Arc, // states current_rule_name: &'static str, @@ -43,7 +43,7 @@ impl<'a> LintContext<'a> { disable_directives: Rc::new(disable_directives), fix: false, file_path: file_path.into(), - eslint_config: Arc::new(ESLintConfig::default()), + eslint_config: Arc::new(OxlintConfig::default()), current_rule_name: "", severity: Severity::Warning, } @@ -56,7 +56,7 @@ impl<'a> LintContext<'a> { } #[must_use] - pub fn with_eslint_config(mut self, eslint_config: &Arc) -> Self { + pub fn with_eslint_config(mut self, eslint_config: &Arc) -> Self { self.eslint_config = Arc::clone(eslint_config); self } @@ -93,15 +93,15 @@ impl<'a> LintContext<'a> { &self.file_path } - pub fn settings(&self) -> &ESLintSettings { + pub fn settings(&self) -> &OxlintSettings { &self.eslint_config.settings } - pub fn globals(&self) -> &ESLintGlobals { + pub fn globals(&self) -> &OxlintGlobals { &self.eslint_config.globals } - pub fn env(&self) -> &ESLintEnv { + pub fn env(&self) -> &OxlintEnv { &self.eslint_config.env } diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 7212b89fd38e7..9854a22de8810 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -26,14 +26,14 @@ use oxc_diagnostics::Error; use oxc_semantic::AstNode; pub use crate::{ - config::ESLintConfig, + config::OxlintConfig, context::LintContext, options::{AllowWarnDeny, LintOptions}, rule::{RuleCategory, RuleMeta, RuleWithSeverity}, service::{LintService, LintServiceOptions}, }; use crate::{ - config::{ESLintEnv, ESLintGlobals, ESLintSettings}, + config::{OxlintEnv, OxlintGlobals, OxlintSettings}, fixer::Fix, fixer::{Fixer, Message}, rules::RuleEnum, @@ -54,7 +54,7 @@ fn size_asserts() { pub struct Linter { rules: Vec, options: LintOptions, - eslint_config: Arc, + eslint_config: Arc, } impl Default for Linter { @@ -80,7 +80,7 @@ impl Linter { } #[must_use] - pub fn with_eslint_config(mut self, eslint_config: ESLintConfig) -> Self { + pub fn with_eslint_config(mut self, eslint_config: OxlintConfig) -> Self { self.eslint_config = Arc::new(eslint_config); self } diff --git a/crates/oxc_linter/src/options.rs b/crates/oxc_linter/src/options.rs index 0b55d9e6e5ec5..28b79201aa46f 100644 --- a/crates/oxc_linter/src/options.rs +++ b/crates/oxc_linter/src/options.rs @@ -5,7 +5,7 @@ use serde_json::{Number, Value}; use oxc_diagnostics::{Error, OxcDiagnostic, Severity}; -use crate::{config::ESLintConfig, rules::RULES, RuleCategory, RuleEnum, RuleWithSeverity}; +use crate::{config::OxlintConfig, rules::RULES, RuleCategory, RuleEnum, RuleWithSeverity}; #[derive(Debug)] pub struct LintOptions { @@ -204,9 +204,9 @@ impl LintOptions { /// # Errors /// /// * Returns `Err` if there are any errors parsing the configuration file. - pub fn derive_rules_and_config(&self) -> Result<(Vec, ESLintConfig), Error> { + pub fn derive_rules_and_config(&self) -> Result<(Vec, OxlintConfig), Error> { let config = - self.config_path.as_ref().map(|path| ESLintConfig::from_file(path)).transpose()?; + self.config_path.as_ref().map(|path| OxlintConfig::from_file(path)).transpose()?; let mut rules: FxHashSet = FxHashSet::default(); let all_rules = self.get_filtered_rules(); diff --git a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs index 8feb6a5de72b0..94582d7c76762 100644 --- a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs +++ b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs @@ -441,7 +441,7 @@ fn is_memo_or_forward_ref_callback(nodes: &AstNodes, node_id: AstNodeId) -> bool fn test() { /// Copyright (c) Meta Platforms, Inc. and affiliates. /// Most of these tests are sourced from the original react `eslint-plugin-react-hooks` package. - /// https://github.com/facebook/react/blob/5b903cdaa94c78e8fabb985d8daca5bd7d266323/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js#L43 + /// https://github.com/facebook/react/blob/5b903cdaa94c78e8fabb985d8daca5bd7d266323/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js use crate::tester::Tester; let pass = vec![ diff --git a/crates/oxc_linter/src/tester.rs b/crates/oxc_linter/src/tester.rs index 8aa5f6ed2db41..08a5c1474c13d 100644 --- a/crates/oxc_linter/src/tester.rs +++ b/crates/oxc_linter/src/tester.rs @@ -9,8 +9,8 @@ use serde::Deserialize; use serde_json::Value; use crate::{ - rules::RULES, AllowWarnDeny, ESLintConfig, Fixer, LintOptions, LintService, LintServiceOptions, - Linter, RuleEnum, RuleWithSeverity, + rules::RULES, AllowWarnDeny, Fixer, LintOptions, LintService, LintServiceOptions, Linter, + OxlintConfig, RuleEnum, RuleWithSeverity, }; #[derive(Eq, PartialEq)] @@ -208,7 +208,7 @@ impl Tester { .with_react_perf_plugin(self.react_perf_plugin); let eslint_config = eslint_config .as_ref() - .map_or_else(ESLintConfig::default, |v| ESLintConfig::deserialize(v).unwrap()); + .map_or_else(OxlintConfig::default, |v| OxlintConfig::deserialize(v).unwrap()); let linter = Linter::from_options(options) .unwrap() .with_rules(vec![RuleWithSeverity::new(rule, AllowWarnDeny::Warn)]) diff --git a/crates/oxc_linter/src/utils/react.rs b/crates/oxc_linter/src/utils/react.rs index 01cb1e26a4946..fd28088ec514b 100644 --- a/crates/oxc_linter/src/utils/react.rs +++ b/crates/oxc_linter/src/utils/react.rs @@ -7,7 +7,7 @@ use oxc_ast::{ }; use oxc_semantic::{AstNode, SymbolFlags}; -use crate::{ESLintSettings, LintContext}; +use crate::{LintContext, OxlintSettings}; pub fn is_create_element_call(call_expr: &CallExpression) -> bool { if let Some(member_expr) = call_expr.callee.get_member_expr() { @@ -241,7 +241,7 @@ pub fn get_element_type(context: &LintContext, element: &JSXOpeningElement) -> O return None; }; - let ESLintSettings { jsx_a11y, .. } = context.settings(); + let OxlintSettings { jsx_a11y, .. } = context.settings(); let polymorphic_prop = jsx_a11y .polymorphic_prop_name diff --git a/tasks/website/src/linter/cli.rs b/tasks/website/src/linter/cli.rs index 50ac5bc0eb0b4..931c8d0111d07 100644 --- a/tasks/website/src/linter/cli.rs +++ b/tasks/website/src/linter/cli.rs @@ -9,6 +9,14 @@ fn test_cli() { }); } +#[test] +fn test_cli_terminal() { + let snapshot = oxc_cli::lint_command().run_inner(&["--help"]).unwrap_err().unwrap_stdout(); + insta::with_settings!({ prepend_module_to_snapshot => false }, { + insta::assert_snapshot!(snapshot); + }); +} + // pub fn print_cli() { println!("{}", generate_cli()); diff --git a/tasks/website/src/linter/json_schema.rs b/tasks/website/src/linter/json_schema.rs index 52ab71ea692b0..b634599569402 100644 --- a/tasks/website/src/linter/json_schema.rs +++ b/tasks/website/src/linter/json_schema.rs @@ -5,7 +5,7 @@ use schemars::{ }; use serde::Serialize; -use oxc_linter::ESLintConfig; +use oxc_linter::OxlintConfig; #[test] fn test_schema_json() { @@ -20,7 +20,7 @@ pub fn print_schema_json() { } fn generate_schema_json() -> String { - let schema = schema_for!(ESLintConfig); + let schema = schema_for!(OxlintConfig); serde_json::to_string_pretty(&schema).unwrap() } @@ -37,7 +37,7 @@ pub fn print_schema_markdown() { } fn generate_schema_markdown() -> String { - let root_schema = schema_for!(ESLintConfig); + let root_schema = schema_for!(OxlintConfig); Renderer::new(root_schema).render() } diff --git a/tasks/website/src/linter/snapshots/cli.snap b/tasks/website/src/linter/snapshots/cli.snap index 1961604ba90d8..93942b11304d3 100644 --- a/tasks/website/src/linter/snapshots/cli.snap +++ b/tasks/website/src/linter/snapshots/cli.snap @@ -6,13 +6,13 @@ expression: snapshot ## Usage - **`oxlint`** \[**`-c`**=_`<./eslintrc.json>`_\] \[**`--fix`**\] \[_`PATH`_\]... + **`oxlint`** \[**`-c`**=_`<./oxlintrc.json>`_\] \[**`--fix`**\] \[_`PATH`_\]... ## Basic Configuration -- **`-c`**, **`--config`**=_`<./eslintrc.json>`_ — - ESLint configuration file (experimental) - - * only `.json` extension is supported +- **`-c`**, **`--config`**=_`<./oxlintrc.json>`_ — + Oxlint configuration file (experimental) +* only `.json` extension is supported +* tries to be compatible with the ESLint v8's format - **` --tsconfig`**=_`<./tsconfig.json>`_ — TypeScript `tsconfig.json` path for reading path alias and project references for import plugin diff --git a/tasks/website/src/linter/snapshots/cli_terminal.snap b/tasks/website/src/linter/snapshots/cli_terminal.snap new file mode 100644 index 0000000000000..f33d9613bc7da --- /dev/null +++ b/tasks/website/src/linter/snapshots/cli_terminal.snap @@ -0,0 +1,77 @@ +--- +source: tasks/website/src/linter/cli.rs +expression: snapshot +--- +Linter for the JavaScript Oxidation Compiler + +Usage: [-c=<./oxlintrc.json>] [--fix] [PATH]... + +Basic Configuration + -c, --config=<./oxlintrc.json> Oxlint configuration file (experimental) + * only `.json` extension is supported + * tries to be compatible with the ESLint v8's format + --tsconfig=<./tsconfig.json> TypeScript `tsconfig.json` path for reading path alias and + project references for import plugin + +Allowing / Denying Multiple Lints + Accumulate rules and categories from left to right on the command-line. + For example `-D correctness -A no-debugger` or `-A all -D no-debugger`. + The categories are: + * `correctness` - code that is outright wrong or useless (default) + * `suspicious` - code that is most likely wrong or useless + * `pedantic` - lints which are rather strict or have occasional false positives + * `style` - code that should be written in a more idiomatic way + * `nursery` - new lints that are still under development + * `restriction` - lints which prevent the use of language and library features + * `all` - all the categories listed above except nursery + -A, --allow=NAME Allow the rule or category (suppress the lint) + -W, --warn=NAME Deny the rule or category (emit a warning) + -D, --deny=NAME Deny the rule or category (emit an error) + +Enable Plugins + --disable-react-plugin Disable react plugin, which is turned on by default + --disable-unicorn-plugin Disable unicorn plugin, which is turned on by default + --disable-oxc-plugin Disable oxc unique rules, which is turned on by default + --disable-typescript-plugin Disable TypeScript plugin, which is turned on by default + --import-plugin Enable the experimental import plugin and detect ESM problems. It is + recommended to use along side with the `--tsconfig` option. + --jsdoc-plugin Enable the experimental jsdoc plugin and detect JSDoc problems + --jest-plugin Enable the Jest plugin and detect test problems + --jsx-a11y-plugin Enable the JSX-a11y plugin and detect accessibility problems + --nextjs-plugin Enable the Next.js plugin and detect Next.js problems + --react-perf-plugin Enable the React performance plugin and detect rendering performance + problems + +Fix Problems + --fix Fix as many issues as possible. Only unfixed issues are reported in + the output + +Ignore Files + --ignore-path=PATH Specify the file to use as your .eslintignore + --ignore-pattern=PAT Specify patterns of files to ignore (in addition to those in + .eslintignore) + --no-ignore Disables excluding of files from .eslintignore files, --ignore-path + flags and --ignore-pattern flags + --symlinks Follow symbolic links. Oxlint ignores symbolic links by default. + +Handle Warnings + --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Ensure warnings produce a non-zero exit code + --max-warnings=INT Specify a warning threshold, which can be used to force exit with an + error status if there are too many warning-level rule violations in + your project + +Output + -f, --format=ARG Use a specific output format (default, json, unix, checkstyle, github) + +Miscellaneous + --silent Do not display any diagnostics + --threads=INT Number of threads to use. Set to 1 for using only 1 CPU core + +Available positional items: + PATH Single file, single path or list of paths + +Available options: + --rules list all the rules that are currently registered + -h, --help Prints help information + -V, --version Prints version information diff --git a/tasks/website/src/linter/snapshots/schema_json.snap b/tasks/website/src/linter/snapshots/schema_json.snap index 5ecfb67748ea1..ae96e65e0b24b 100644 --- a/tasks/website/src/linter/snapshots/schema_json.snap +++ b/tasks/website/src/linter/snapshots/schema_json.snap @@ -4,26 +4,26 @@ expression: snapshot --- { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ESLintConfig", + "title": "OxlintConfig", "description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n```json\n // oxlintrc.json\n {\n // Comments are supported.\n \"env\": {\n \"browser\": true\n },\n \"globals\": {\n \"foo\": \"readonly\",\n },\n \"settings\": {\n },\n \"rules\": {\n \"eqeqeq\": \"warn\",\n },\n }\n```", "type": "object", "properties": { "env": { - "$ref": "#/definitions/ESLintEnv" + "$ref": "#/definitions/OxlintEnv" }, "globals": { - "$ref": "#/definitions/ESLintGlobals" + "$ref": "#/definitions/OxlintGlobals" }, "rules": { "description": "See [Oxlint Rules](./rules)", "allOf": [ { - "$ref": "#/definitions/ESLintRules" + "$ref": "#/definitions/OxlintRules" } ] }, "settings": { - "$ref": "#/definitions/ESLintSettings" + "$ref": "#/definitions/OxlintSettings" } }, "definitions": { @@ -83,44 +83,6 @@ expression: snapshot } ] }, - "ESLintEnv": { - "description": "Predefine global variables.", - "type": "object", - "additionalProperties": { - "type": "boolean" - } - }, - "ESLintGlobals": { - "description": "Add or remove global variables.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/GlobalValue" - } - }, - "ESLintRules": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/DummyRule" - } - }, - "ESLintSettings": { - "description": "Shared settings for plugins", - "type": "object", - "properties": { - "jsdoc": { - "$ref": "#/definitions/JSDocPluginSettings" - }, - "jsx-a11y": { - "$ref": "#/definitions/JSXA11yPluginSettings" - }, - "next": { - "$ref": "#/definitions/NextPluginSettings" - }, - "react": { - "$ref": "#/definitions/ReactPluginSettings" - } - } - }, "GlobalValue": { "type": "string", "enum": [ @@ -214,6 +176,44 @@ expression: snapshot } ] }, + "OxlintEnv": { + "description": "Predefine global variables.", + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "OxlintGlobals": { + "description": "Add or remove global variables.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/GlobalValue" + } + }, + "OxlintRules": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/DummyRule" + } + }, + "OxlintSettings": { + "description": "Shared settings for plugins", + "type": "object", + "properties": { + "jsdoc": { + "$ref": "#/definitions/JSDocPluginSettings" + }, + "jsx-a11y": { + "$ref": "#/definitions/JSXA11yPluginSettings" + }, + "next": { + "$ref": "#/definitions/NextPluginSettings" + }, + "react": { + "$ref": "#/definitions/ReactPluginSettings" + } + } + }, "ReactPluginSettings": { "type": "object", "properties": {