mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-11-04 13:39:07 +00:00 
			
		
		
		
	This does a deeper removal of the `lint:` prefix by removing the `DiagnosticId::as_str` method and replacing it with `as_concise_str`. We remove the associated error type and simplify the `Display` impl for `DiagnosticId` as well. This turned out to catch a `lint:` that was still in the diagnostic output: the part that says why a lint is enabled.
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
#![cfg(target_arch = "wasm32")]
 | 
						|
 | 
						|
use ty_wasm::{Position, PositionEncoding, Workspace};
 | 
						|
use wasm_bindgen_test::wasm_bindgen_test;
 | 
						|
 | 
						|
#[wasm_bindgen_test]
 | 
						|
fn check() {
 | 
						|
    let mut workspace = Workspace::new(
 | 
						|
        "/",
 | 
						|
        PositionEncoding::Utf32,
 | 
						|
        js_sys::JSON::parse("{}").unwrap(),
 | 
						|
    )
 | 
						|
    .expect("Workspace to be created");
 | 
						|
 | 
						|
    workspace
 | 
						|
        .open_file("test.py", "import random22\n")
 | 
						|
        .expect("File to be opened");
 | 
						|
 | 
						|
    let result = workspace.check().expect("Check to succeed");
 | 
						|
 | 
						|
    assert_eq!(result.len(), 1);
 | 
						|
 | 
						|
    let diagnostic = &result[0];
 | 
						|
 | 
						|
    assert_eq!(diagnostic.id(), "unresolved-import");
 | 
						|
    assert_eq!(
 | 
						|
        diagnostic.to_range(&workspace).unwrap().start,
 | 
						|
        Position { line: 1, column: 8 }
 | 
						|
    );
 | 
						|
    assert_eq!(
 | 
						|
        diagnostic.message(),
 | 
						|
        "Cannot resolve imported module `random22`"
 | 
						|
    );
 | 
						|
}
 |