refactor(linter): s/from_json/from_configuration

This commit is contained in:
Boshen 2023-02-27 10:45:25 +08:00
parent 8b9ebcd6e5
commit 9d4367c2cd
3 changed files with 7 additions and 6 deletions

View file

@ -5,7 +5,8 @@ use crate::{context::LintContext, AstNode};
pub trait Rule: Sized + Default + Debug {
const NAME: &'static str;
fn from_json(_value: serde_json::Value) -> Self {
/// Initialize from eslint json configuration
fn from_configuration(_value: serde_json::Value) -> Self {
Self::default()
}

View file

@ -29,11 +29,11 @@ impl RuleEnum {
pub fn read_json(&self, maybe_value: Option<serde_json::Value>) -> Self {
match self {
Self::NoDebugger(_) => {
Self::NoDebugger(maybe_value.map(NoDebugger::from_json).unwrap_or_default())
}
Self::NoDebugger(_) => Self::NoDebugger(
maybe_value.map(NoDebugger::from_configuration).unwrap_or_default(),
),
Self::NoEmpty(_) => {
Self::NoEmpty(maybe_value.map(NoEmpty::from_json).unwrap_or_default())
Self::NoEmpty(maybe_value.map(NoEmpty::from_configuration).unwrap_or_default())
}
}
}

View file

@ -21,7 +21,7 @@ const RULE_NAME: &str = "no-empty";
impl Rule for NoEmpty {
const NAME: &'static str = RULE_NAME;
fn from_json(value: serde_json::Value) -> Self {
fn from_configuration(value: serde_json::Value) -> Self {
let obj = value.get(0);
Self {
allow_empty_catch: obj