refactor: Introduce crates folder (#2088)

This PR introduces a new `crates` directory and moves all "product" crates into that folder. 

Part of #2059.
This commit is contained in:
Micha Reiser 2023-02-05 22:47:48 +01:00 committed by GitHub
parent e3dfa2e04e
commit cd8be8c0be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1785 changed files with 314 additions and 298 deletions

View file

@ -24,12 +24,12 @@ def snake_case(name: str) -> str:
def main(*, name: str, code: str, linter: str) -> None: # noqa: PLR0915
"""Generate boilerplate for a new rule."""
# Create a test fixture.
with (ROOT_DIR / "resources/test/fixtures" / dir_name(linter) / f"{code}.py").open(
with (ROOT_DIR / "crates/ruff/resources/test/fixtures" / dir_name(linter) / f"{code}.py").open(
"a",
):
pass
plugin_module = ROOT_DIR / "src/rules" / dir_name(linter)
plugin_module = ROOT_DIR / "crates/ruff/src/rules" / dir_name(linter)
rule_name_snake = snake_case(name)
# Add the relevant `#testcase` macro.
@ -102,11 +102,11 @@ pub fn {rule_name_snake}(checker: &mut Checker) {{}}
fp.write("\n")
# Add the relevant code-to-violation pair to `src/registry.rs`.
content = (ROOT_DIR / "src/registry.rs").read_text()
content = (ROOT_DIR / "crates/ruff/src/registry.rs").read_text()
seen_macro = False
has_written = False
with (ROOT_DIR / "src/registry.rs").open("w") as fp:
with (ROOT_DIR / "crates/ruff/src/registry.rs").open("w") as fp:
for line in content.splitlines():
fp.write(line)
fp.write("\n")