mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-11-04 05:34:54 +00:00 
			
		
		
		
	"origin" was accurate since ruff rules are currently always modeled after one origin (except the Ruff-specific rules). Since we however want to introduce a many-to-many mapping between codes and rules, the term "origin" no longer makes much sense. Rules usually don't have multiple origins but one linter implements a rule first and then others implement it later (often inspired from another linter). But we don't actually care much about where a rule originates from when mapping multiple rule codes to one rule implementation, so renaming RuleOrigin to Linter is less confusing with the many-to-many system.
		
			
				
	
	
		
			18 lines
		
	
	
	
		
			492 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
	
		
			492 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import os
 | 
						|
import re
 | 
						|
from pathlib import Path
 | 
						|
 | 
						|
ROOT_DIR = Path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 | 
						|
 | 
						|
 | 
						|
def dir_name(linter_name: str) -> str:
 | 
						|
    return linter_name.replace("-", "_")
 | 
						|
 | 
						|
 | 
						|
def pascal_case(linter_name: str) -> str:
 | 
						|
    """Convert from snake-case to PascalCase."""
 | 
						|
    return "".join(word.title() for word in linter_name.split("-"))
 | 
						|
 | 
						|
 | 
						|
def get_indent(line: str) -> str:
 | 
						|
    return re.match(r"^\s*", line).group()  # pyright: ignore[reportOptionalMemberAccess]
 |