ソースを参照

add skip-lint to Anchor.toml (#2026)

Drew Nutter 3 年 前
コミット
24ab7d3e84
2 ファイル変更41 行追加1 行削除
  1. 40 0
      cli/src/config.rs
  2. 1 1
      cli/src/lib.rs

+ 40 - 0
cli/src/config.rs

@@ -286,6 +286,8 @@ pub struct Config {
 pub struct FeaturesConfig {
     #[serde(default)]
     pub seeds: bool,
+    #[serde(default, rename = "skip-lint")]
+    pub skip_lint: bool,
 }
 
 #[derive(Clone, Debug, Serialize, Deserialize)]
@@ -1116,3 +1118,41 @@ impl AnchorPackage {
 }
 
 crate::home_path!(WalletPath, ".config/solana/id.json");
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    const BASE_CONFIG: &str = "
+        [provider]
+        cluster = \"localnet\"
+        wallet = \"id.json\"
+    ";
+
+    #[test]
+    fn parse_skip_lint_no_section() {
+        let config = Config::from_str(BASE_CONFIG).unwrap();
+        assert!(!config.features.skip_lint);
+    }
+
+    #[test]
+    fn parse_skip_lint_no_value() {
+        let string = BASE_CONFIG.to_owned() + "[features]";
+        let config = Config::from_str(&string).unwrap();
+        assert!(!config.features.skip_lint);
+    }
+
+    #[test]
+    fn parse_skip_lint_true() {
+        let string = BASE_CONFIG.to_owned() + "[features]\nskip-lint = true";
+        let config = Config::from_str(&string).unwrap();
+        assert!(config.features.skip_lint);
+    }
+
+    #[test]
+    fn parse_skip_lint_false() {
+        let string = BASE_CONFIG.to_owned() + "[features]\nskip-lint = false";
+        let config = Config::from_str(&string).unwrap();
+        assert!(!config.features.skip_lint);
+    }
+}

+ 1 - 1
cli/src/lib.rs

@@ -1512,7 +1512,7 @@ fn extract_idl(
         cargo.version(),
         cfg.features.seeds,
         no_docs,
-        !skip_lint,
+        !(cfg.features.skip_lint || skip_lint),
     )
 }