Use type imports - #758
Conversation
|
@coderabbitai is there any change in commit |
|
Important Review skippedToo many files! This PR contains 330 files, which is 30 over the limit of 300. To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (330)
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="31f27b337d5b4b6b38a48f2c18bb2dd84224ccf1"
git show --no-ext-diff --format=fuller --no-renames --stat "$commit"
printf '\n--- NAME STATUS ---\n'
git diff-tree --no-commit-id --name-status -r "$commit"
printf '\n--- PATCH ---\n'
git diff --no-ext-diff --no-renames "${commit}^" "$commit"Length of output: 131294 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="31f27b337d5b4b6b38a48f2c18bb2dd84224ccf1"
parent="${commit}^"
python3 - "$commit" "$parent" <<'PY'
import subprocess
import sys
import re
commit, parent = sys.argv[1:]
files = subprocess.check_output(
["git", "diff", "--name-only", "--diff-filter=ACMRT", parent, commit],
text=True,
).splitlines()
def import_line_numbers(text):
"""Return 1-based line numbers belonging to static import declarations."""
lines = text.splitlines()
covered = set()
in_import = False
for n, line in enumerate(lines, 1):
stripped = line.lstrip()
if not in_import and re.match(r"import(?:\s+type)?\b", stripped):
in_import = True
if in_import:
covered.add(n)
if ";" in line:
in_import = False
return covered
non_import = []
for path in files:
if not path.endswith((".ts", ".tsx", ".mts", ".cts")):
non_import.append((path, "non-TypeScript file changed"))
continue
old = subprocess.check_output(["git", "show", f"{parent}:{path}"], text=True)
new = subprocess.check_output(["git", "show", f"{commit}:{path}"], text=True)
old_imports = import_line_numbers(old)
new_imports = import_line_numbers(new)
diff = subprocess.check_output(
["git", "diff", "--unified=0", "--no-ext-diff", parent, commit, "--", path],
text=True,
)
old_line = new_line = None
for line in diff.splitlines():
m = re.match(r"^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@", line)
if m:
old_line, new_line = map(int, m.groups())
continue
if old_line is None or line.startswith(("---", "+++")):
continue
if line.startswith("-"):
if line[1:].strip() and old_line not in old_imports:
non_import.append((path, f"removed Line {old_line}: {line[1:]}"))
old_line += 1
elif line.startswith("+"):
if line[1:].strip() and new_line not in new_imports:
non_import.append((path, f"added Line {new_line}: {line[1:]}"))
new_line += 1
else:
old_line += 1
new_line += 1
print(f"Changed files: {len(files)}")
if non_import:
print("NON-IMPORT CHANGES:")
for path, detail in non_import:
print(f"{path}: {detail}")
else:
print("No changed non-empty lines outside static import declarations were found.")
print("\nCommit subject:")
subprocess.run(["git", "show", "-s", "--format=%s", commit], check=True)
PYLength of output: 2893 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="31f27b337d5b4b6b38a48f2c18bb2dd84224ccf1"
git diff --no-ext-diff --no-renames "${commit}^" "$commit" -- \
eslint.config.js \
libs/i18n/locales/en/translation.jsonLength of output: 1713
The All TypeScript changes in the commit are limited to import declarations. You are interacting with an AI system. |
31f27b3 to
fab19fd
Compare
Made-with: Cursor
fab19fd to
950a05a
Compare
|
@coderabbitai Please check again. There shouldn't be any change that isn't strictly necessary and related to the introduction of the new |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
commit='31f27b337d5b4b6b38a48f2c18bb2dd84224ccf1'
parent="${commit}^"
printf '%s\n' '--- COMMIT ---'
git show -s --format='fuller%n%n%B' "$commit"
printf '%s\n' '--- CHANGED FILES ---'
git diff-tree --no-commit-id --name-status -r --no-renames "$commit"
printf '%s\n' '--- NON-IMPORT AND CONFIGURATION DIFF ---'
git diff --no-ext-diff --no-renames --unified=3 "$parent" "$commit" -- \
':(exclude)**/*.ts' ':(exclude)**/*.tsx'
printf '%s\n' '--- TYPE IMPORT TRANSFORMATIONS AND USAGE CHECK ---'
python3 - "$parent" "$commit" <<'PY'
import re
import subprocess
import sys
parent, commit = sys.argv[1:]
files = subprocess.check_output(
["git", "diff", "--name-only", "--no-renames", parent, commit, "--", "*.ts", "*.tsx"],
text=True,
).splitlines()
def content(rev, path):
return subprocess.check_output(["git", "show", f"{rev}:{path}"], text=True)
def imports(source):
# Static imports, including multiline declarations.
return re.findall(r'(?ms)^import\s+(?:type\s+)?(?:[\s\S]*?)\s+from\s+[\'"][^\'"]+[\'"]\s*;?', source)
for path in files:
old = content(parent, path)
new = content(commit, path)
old_imps = imports(old)
new_imps = imports(new)
if old_imps == new_imps:
continue
print(f"\nFILE: {path}")
print("Changed imports:")
for imp in new_imps:
if imp not in old_imps:
print(" +", " ".join(imp.split()))
for imp in old_imps:
if imp not in new_imps:
print(" -", " ".join(imp.split()))
# Show all non-import modified lines. Empty lines are omitted.
diff = subprocess.check_output(
["git", "diff", "--no-ext-diff", "--unified=0", parent, commit, "--", path],
text=True,
)
in_old = in_new = False
for line in diff.splitlines():
if line.startswith("@@"):
in_old = in_new = False
elif line.startswith("-") and not line.startswith("---"):
text = line[1:].strip()
in_old = text.startswith("import ") or in_old
if text and not in_old:
print(" NON-IMPORT REMOVAL:", text)
if ";" in text:
in_old = False
elif line.startswith("+") and not line.startswith("+++"):
text = line[1:].strip()
in_new = text.startswith("import ") or in_new
if text and not in_new:
print(" NON-IMPORT ADDITION:", text)
if ";" in text:
in_new = False
PY
printf '%s\n' '--- ESLINT RULE CONTEXT ---'
git diff --no-ext-diff --no-renames --unified=12 "$parent" "$commit" -- eslint.config.jsLength of output: 183246
One unrelated change remains:
This JSON file is also excluded by All other changes are either:
The translation-key addition should be removed from this commit. You are interacting with an AI system. |
|
@coderabbitai new commit has is changed to |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
commit='950a05a95d8e785fcb5b99548cbb2392f945534a'
parent="${commit}^"
echo '--- COMMIT ---'
git show -s --format='fuller%n%n%B' "$commit"
echo '--- CHANGED FILES ---'
git diff-tree --no-commit-id --name-status -r --no-renames "$commit"
echo '--- COMPLETE DIFF STAT ---'
git diff --stat --no-renames "$parent" "$commit"
echo '--- NON-TYPESCRIPT DIFF ---'
git diff --no-ext-diff --no-renames --unified=3 "$parent" "$commit" -- \
':(exclude)**/*.ts' ':(exclude)**/*.tsx' || true
echo '--- TYPESCRIPT NON-IMPORT LINES ---'
python3 - "$parent" "$commit" <<'PY'
import re
import subprocess
import sys
parent, commit = sys.argv[1:]
paths = subprocess.check_output(
["git", "diff", "--name-only", "--no-renames", parent, commit, "--", "*.ts", "*.tsx"],
text=True,
).splitlines()
def import_lines(source):
covered = set()
active = False
for n, line in enumerate(source.splitlines(), 1):
if not active and re.match(r"^\s*import(?:\s+type)?\b", line):
active = True
if active:
covered.add(n)
if ";" in line:
active = False
return covered
found = False
for path in paths:
old = subprocess.check_output(["git", "show", f"{parent}:{path}"], text=True)
new = subprocess.check_output(["git", "show", f"{commit}:{path}"], text=True)
old_imports, new_imports = import_lines(old), import_lines(new)
diff = subprocess.check_output(
["git", "diff", "--no-ext-diff", "--unified=0", parent, commit, "--", path],
text=True,
).splitlines()
old_line = new_line = None
for line in diff:
match = re.match(r"^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@", line)
if match:
old_line, new_line = map(int, match.groups())
elif old_line is not None and line.startswith("-") and not line.startswith("---"):
if line[1:].strip() and old_line not in old_imports:
print(f"{path}: removed Line {old_line}: {line[1:]}")
found = True
old_line += 1
elif new_line is not None and line.startswith("+") and not line.startswith("+++"):
if line[1:].strip() and new_line not in new_imports:
print(f"{path}: added Line {new_line}: {line[1:]}")
found = True
new_line += 1
elif old_line is not None and not line.startswith(("diff ", "index ")):
old_line += 1
new_line += 1
if not found:
print("No non-empty TypeScript changes outside static import declarations.")
PY
echo '--- IMPORT CHANGES ---'
git diff --no-ext-diff --no-renames --unified=1 "$parent" "$commit" -- '*.ts' '*.tsx'Length of output: 145549 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit='950a05a95d8e785fcb5b99548cbb2392f945534a'
parent="${commit}^"
echo '--- SUBJECT ---'
git show -s --format='%h %s' "$commit"
echo '--- CHANGED FILE COUNTS BY EXTENSION ---'
git diff --name-only --no-renames "$parent" "$commit" |
awk '
/\.tsx?$/ { ts++ ; next }
{ other++; print "NON_TS_FILE: " $0 }
END { print "TYPESCRIPT_FILES: " (ts+0); print "NON_TYPESCRIPT_FILES: " (other+0) }
'
echo '--- NON-TYPESCRIPT PATCH ---'
git diff --no-ext-diff --no-renames --unified=0 "$parent" "$commit" -- \
':(exclude)**/*.ts' ':(exclude)**/*.tsx' || true
echo '--- TYPESCRIPT LINES OUTSIDE IMPORT DECLARATIONS ---'
python3 - "$parent" "$commit" <<'PY'
import re
import subprocess
import sys
parent, commit = sys.argv[1:]
paths = subprocess.check_output(
["git", "diff", "--name-only", "--no-renames", parent, commit, "--", "*.ts", "*.tsx"],
text=True,
).splitlines()
def import_line_set(source):
lines, result, active = source.splitlines(), set(), False
for number, line in enumerate(lines, 1):
if not active and re.match(r"^\s*import(?:\s+type)?(?:\s|\{|\*)", line):
active = True
if active:
result.add(number)
if ";" in line:
active = False
return result
changes = []
for path in paths:
old = subprocess.check_output(["git", "show", f"{parent}:{path}"], text=True)
new = subprocess.check_output(["git", "show", f"{commit}:{path}"], text=True)
old_imports, new_imports = import_line_set(old), import_line_set(new)
diff = subprocess.check_output(
["git", "diff", "--no-ext-diff", "--unified=0", parent, commit, "--", path],
text=True,
).splitlines()
old_line = new_line = None
for line in diff:
match = re.match(r"^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@", line)
if match:
old_line, new_line = map(int, match.groups())
continue
if old_line is None or line.startswith(("---", "+++", "diff ", "index ")):
continue
if line.startswith("-"):
if line[1:].strip() and old_line not in old_imports:
changes.append(f"{path}: removed Line {old_line}: {line[1:]}")
old_line += 1
elif line.startswith("+"):
if line[1:].strip() and new_line not in new_imports:
changes.append(f"{path}: added Line {new_line}: {line[1:]}")
new_line += 1
elif line.startswith(" "):
old_line += 1
new_line += 1
if changes:
print("\n".join(changes))
else:
print("NONE")
PY
echo '--- ESLINT CONFIGURATION PATCH ---'
git diff --no-ext-diff --no-renames --unified=3 "$parent" "$commit" -- eslint.config.js || trueLength of output: 4122
It contains only the required changes:
My earlier finding applied only to the pre-rebase commit. It does not apply to this commit. You are interacting with an AI system. |
Since now Coderabbitai highlights missing "type" imports across modified code, better to fix all in one go to have clean reviews.
New eslint rules that appear with
npm run lint:or