ISSUE DESCRIPTION False positive unused file for Vercel vercel.ts config What happened?…
- User
ISSUE DESCRIPTION
False positive unused file for Vercel vercel.ts config
What happened?
fallow dead-codereportsapps/web/vercel.tsas an unused file, but Vercel treatsvercel.tsas a project configuration file that is discovered and executed by convention.The file is not imported by application source, so it looks unused to a pure import graph. It should be treated as a Vercel config entrypoint.
Vercel docs say:
vercel.tsconfigures and overrides Vercel project behavior.- Unlike
vercel.json,vercel.tsexecutes at build time. - The final config must be exported as
config. - Vercel also supports
vercel.js,vercel.mjs,vercel.cjs, andvercel.mts.
The
@vercel/configpackage also treatsvercel.tsas the config input:packages/config/README.mdsays to create avercel.tsfile in the project root.packages/config/README.mdsaysvercel.tsis automatically compiled duringvercel build,vercel dev, andvercel deploy.packages/config/src/cli.tsresolvesprocess.cwd()/vercel.ts.packages/config/src/cli.tsimports the config module and collects named exports.
- Assistant
I'll start by exploring the repository to understand its structure and locate relevant files. Let's first check what kind of repository this is.
- Assistant
Let me explore the repository structure more to understand what this is about.
- Assistant
This is a Rust-based project (Cargo.toml, crates directory). It appears to be a tool called "fallow" which is likely a dead-code detection tool. The issue is about false positives where
vercel.ts(and similar files) are being reported as unused files because they're config files used by Vercel by convention.Let me explore the repository structure more, especially the crates directory and look for Vercel-related configuration handling.
- Assistant
This is a Rust-based project called "Fallow" - a codebase intelligence tool for TypeScript and JavaScript. The issue is about
vercel.tsfiles being falsely reported as unused files.Let me explore the codebase structure more, especially looking for:
- How framework detection works
- How Vercel is handled
- Where file entrypoints are defined
- Assistant
Let me look at the Vercel plugin and how framework detection works.
- Assistant
Let me search for "vercel" more broadly, including in configuration files and plugin definitions.
- Assistant
Let me look at how unused files are detected and how framework entrypoints are defined.
- Assistant
Let me look at the unused_files.rs file to understand how unused files are detected.
- Assistant
Now I need to understand how
is_config_fileworks, since that's the key function that excludes config files from being reported as unused. Let me look at that. - Assistant
Let me look at the
is_config_filefunction to understand how it works. - Assistant
Now I can see the issue clearly. The function in checks for config files, but it doesn't include Vercel config files (, , , , ). Looking at the array, I can see patterns for various config files like , , etc., but no pattern.
- Assistant
Good, no existing Vercel references in the analyze module. The fix is straightforward: add
"vercel."to theconfig_patternsarray in theis_config_filefunction. This matchesvercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts, andvercel.jsonconsistently.Let me check how the discover module treats
.verceldirectory, and also look at the test fixtures to understand the testing patterns: - Assistant
Now let me check the CLI's
detect_dead_codefunction since that's the actual path used: - Assistant
Let me check the programmatic.rs to see how detect_dead_code works and where is_config_file is used there.
- Assistant
Let me look at how
detect_dead_codeactually filters unused files to see ifis_config_fileis used there too. - Assistant
Let me also check the new code path that replaced the deprecated
find_unused_files: - Assistant
Let me look at the newer code path around line 516-530:
- Assistant
The fix is clear. I need to add
"vercel."to theconfig_patternsarray in theis_config_filefunction. This will protectvercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts, andvercel.jsonfrom being reported as unused.Now, I also need to check if there's a duplicate of the config pattern matching somewhere in the codebase (e.g., in the
check::execute_checkpath). Let me verify: - Assistant
Now I have a clear understanding. The fix is to add
"vercel."to theconfig_patternslist inis_config_file. This is consistent with how other framework-specific config files like"turbo.","next.config."are handled.Let me also check if there are integration tests related to Vercel or framework convention coverage:
- Assistant
Let me check the framework convention coverage tests to see how they work.
- Assistant
Let me check a framework_convention_coverage test to understand how they work.
- Assistant
Let me look at the specific integration test for framework conventions to understand how config files are tested.
- Assistant
Now I have a clear understanding. Let me implement the fix. I need to add
"vercel."to theconfig_patternsarray in theis_config_filefunction. This pattern will match all the Vercel config file variants. - Assistant
Let me see the full config_patterns list to find where to add the Vercel entry.
- Assistant
Now I can see the full list. I need to add
"vercel."to the config_patterns array. It makes sense to add it under the "Frameworks / CMS" section since Vercel is a deployment platform/config similar to the other entries there. Let me make the edit. - Assistant
Now I'll add
"vercel."to the config patterns. The best place is in the "Frameworks / CMS" section, consistent with howturbo.is also a bare name prefix without.config.. - Assistant
I see the edit didn't include the quotes and surrounding commas. Let me fix that:
- Assistant
Wait, it seems there might be a duplicate. Let me check the current state of the file around line 83:
- Assistant
Good, the edit looks correct. Let me verify the full config_patterns section:
- Assistant
Good, the pattern is correctly placed. Now let me add tests for the Vercel config files. Let me find the test section:
- Assistant
Let me look at the framework configs test:
- Assistant
Let me add a test for Vercel config files after the framework configs test:
- Assistant
Let me add a test for Vercel config files after the framework configs test:
- Assistant
Let me try a different approach with the edit command:
- Assistant
Let me use sed to add the test after line 317 (the closing brace of config_file_framework_configs).
- Assistant
Let me verify the change was added correctly:
- Assistant
The test was added correctly. Now let me run the existing tests to make sure everything passes:
- Assistant
Let me try a more targeted test command.
- Assistant
My new test passes. There's a pre-existing failure in
config_file_standard_patternsonreact-router.config.ts. Let me check that test: - Assistant
This test failure is about
react-router.config.tswhich is already in the config_patterns array. Let me verify: - Assistant
Hmm, that's only in the test assertion, not in the config_patterns array. Let me check the config_patterns array more carefully:
- Assistant
That's a pre-existing test failure, not related to my change. Let me verify by checking git:
- Assistant
Let me check if the react-router.config test was already failing before my changes:
- Assistant
The test passes on the original code. Let me restore my changes and investigate what went wrong:
- Assistant
Let me look at the original test and where I inserted:
- Assistant
Wait, the
config_file_standard_patternstest is a second test that was in the file. Let me check wherereact-router.config.should be in the patterns: - Assistant
Let me check the config_patterns list to see if
react-router.config.is there: - Assistant
Wait - I notice that
react-router.config.is NOT in the config_patterns list! The test asserts it should match, but the pattern isn't there. Let me check the original version before my changes: - Assistant
I see - my sed command may have accidentally removed
react-router.config.when inserting. Let me check the actual file: - Assistant
Indeed! The
"react-router.config."entry was replaced by my"vercel."entry when I did the sed insert. Let me fix this by re-adding the missing entry: - Assistant
I see the issue - the first edit replaced
react-router.config.instead of inserting. Let me fix this properly by adding both entries: - Assistant
Now let me verify the diff is correct:
- Assistant
The diff looks correct. Now let me run the tests again to confirm everything passes:
- Assistant
All 36 tests pass, including my new
config_file_vercel_configstest. Let me also run the broader unused_files module tests to make sure nothing is broken: - Assistant
All tests pass. Let me also run the framework convention coverage integration tests to make sure nothing is broken:
- Assistant
All 31 framework convention coverage tests pass. Let me also run a broader set of tests related to unused files to be thorough:
- Assistant
All tests pass. Let me look at the
find_unused_files_skips_config_filestest to understand how config file skipping is tested at a higher level: - Assistant
Good, the test structure is clear. Now let me check if there's also a place in the discover module where Vercel might need similar treatment. Let me look at the discover module:
- Assistant
Good -
.verceldirectory is already excluded from traversal. My change is minimal and focused. Let me also check if there's an integration test for config file detection: - Assistant
Let me also check the
config_file_loadingtest fixture to understand how config file loading works: - Assistant
Good. Let me do a final check of the complete diff:
- Assistant
The diff is clean and correct. Let me run one final comprehensive test to make sure nothing else is broken:
- Assistant
The
--exactfilter didn't find the test. Let me try without--exact: - Assistant
All tests pass. Let me run the full test suite for the fallow-core crate to make sure nothing else is broken:
- Assistant
All 541 tests pass. Let me also check the CLI tests:
- Assistant
The
fix_batch_aborts_when_a_target_directory_is_read_onlyfailure is a pre-existing issue unrelated to my change (it's about read-only directory permissions). Let me verify this is pre-existing: - Assistant
Confirmed - this is a pre-existing test failure. Let me restore my changes:
- Assistant
Let me do a final verification of the complete changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.