mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(linter): rename variable names prefix ESLint to Oxlint
This commit is contained in:
parent
809e4fc03f
commit
5bf595d6f7
17 changed files with 198 additions and 113 deletions
|
|
@ -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<PathBuf>,
|
||||
|
||||
/// TypeScript `tsconfig.json` path for reading path alias and project references for import plugin
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use serde::Deserialize;
|
|||
// TODO: list the keys we support
|
||||
// <https://eslint.org/docs/v8.x/use/configure/language-options#specifying-environments>
|
||||
#[derive(Debug, Clone, Deserialize, JsonSchema)]
|
||||
pub struct ESLintEnv(FxHashMap<String, bool>);
|
||||
pub struct OxlintEnv(FxHashMap<String, bool>);
|
||||
|
||||
impl ESLintEnv {
|
||||
impl OxlintEnv {
|
||||
pub fn from_vec(env: Vec<String>) -> 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"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rustc_hash::FxHashMap;
|
|||
/// Add or remove global variables.
|
||||
// <https://eslint.org/docs/v8.x/use/configure/language-options#using-configuration-files-1>
|
||||
#[derive(Debug, Default, Deserialize, JsonSchema)]
|
||||
pub struct ESLintGlobals(FxHashMap<String, GlobalValue>);
|
||||
pub struct OxlintGlobals(FxHashMap<String, GlobalValue>);
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::AllowWarnDeny;
|
|||
// - type RuleConf = SeverityConf | [SeverityConf, ...any[]];
|
||||
// <https://github.com/eslint/eslint/blob/ce838adc3b673e52a151f36da0eedf5876977514/lib/shared/types.js#L12>
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ESLintRules(Vec<ESLintRule>);
|
||||
pub struct OxlintRules(Vec<ESLintRule>);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ESLintRule {
|
||||
|
|
@ -25,13 +25,13 @@ pub struct ESLintRule {
|
|||
pub config: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
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<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
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<string, SeverityConf | [SeverityConf, ...any[]]>")
|
||||
|
|
@ -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<ESLintRule>;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Path>,
|
||||
|
||||
eslint_config: Arc<ESLintConfig>,
|
||||
eslint_config: Arc<OxlintConfig>,
|
||||
|
||||
// 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<ESLintConfig>) -> Self {
|
||||
pub fn with_eslint_config(mut self, eslint_config: &Arc<OxlintConfig>) -> 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<RuleWithSeverity>,
|
||||
options: LintOptions,
|
||||
eslint_config: Arc<ESLintConfig>,
|
||||
eslint_config: Arc<OxlintConfig>,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<RuleWithSeverity>, ESLintConfig), Error> {
|
||||
pub fn derive_rules_and_config(&self) -> Result<(Vec<RuleWithSeverity>, 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<RuleWithSeverity> = FxHashSet::default();
|
||||
let all_rules = self.get_filtered_rules();
|
||||
|
|
|
|||
|
|
@ -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![
|
||||
|
|
|
|||
|
|
@ -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)])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
// <https://oxc-project.github.io/docs/guide/usage/linter/cli.html>
|
||||
pub fn print_cli() {
|
||||
println!("{}", generate_cli());
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
77
tasks/website/src/linter/snapshots/cli_terminal.snap
Normal file
77
tasks/website/src/linter/snapshots/cli_terminal.snap
Normal file
|
|
@ -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
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue