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 structure to understand the codebase and locate relevant files.
- Assistant
Let me explore the directory structure more.
- Assistant
Let me explore the repository structure more to understand how it's organized. This looks like a Rust project with crates.
- Assistant
Let me explore the structure more. I need to understand how framework detection works and find where Vercel configuration is handled.
- Assistant
Let me look at the Vercel-related code more closely.
- Assistant
Let me look at the core crate to understand how plugins and frameworks are detected. I should look at the plugins directory.
- Assistant
Let me check the plugin mod.rs to understand how plugins are registered and if there's a Vercel plugin.
- Assistant
Now let me look at the discover module to see how plugins and frameworks are detected:
- Assistant
Let me look at how plugins define
always_usedpatterns - let me look at a few example plugins: - Assistant
Let me look at how plugins are defined using the
define_plugin!macro and check the nextjs plugin as a reference: - Assistant
Let me see the full Next.js plugin to understand the structure:
- Assistant
Let me look for how
always_usedis defined in the plugin definition and how it's used in the dead code detection. I need to understand how plugins detectvercel.jsonandvercel.tsconfig files. - Assistant
There's no Vercel plugin currently. I need to understand how Vercel is detected. Let me look at the sveltekit plugin for Vercel references.
- Assistant
Let me look at the infrastructure detection module:
- Assistant
Now let me look at the Plugin trait to understand the always_used method:
- Assistant
Let me look at the Plugin trait and the
always_usedmethod in more detail: - Assistant
Let me search for how Vercel projects are currently detected and how the
vercel.jsonfile is handled: - Assistant
Let me check the flags.rs file to understand how Vercel is currently detected:
- Assistant
Let me search for how "always_used" files are actually used in the dead-code detection logic:
- Assistant
Let me look at how
always_usedis used in the entry_points discovery to understand the flow better: - Assistant
Let me look at that section of the code to understand how always_used is used in entry_points.
- Assistant
Let me look at where "always_used" is used in the dead-code analysis:
- Assistant
Let me look for how dead-code analysis works and how files are marked as unused:
- Assistant
Let me search for how dead-code analysis works and how files are marked as unused:
- Assistant
Let me look at the unused_files.rs file to understand how files are marked as unused and what conditions are checked:
- Assistant
Now let me look at the
is_config_filepredicate to understand what files are currently excluded as config files: - Assistant
Let me find the predicates module.
- Assistant
Let me look at the predicates module to understand how
is_config_fileworks: - Assistant
Now I understand the issue. The
is_config_filefunction in/fallow/crates/core/src/analyze/predicates/file.rsdoesn't includevercel.as a config pattern. Let me check if there's already a test for vercel files: - Assistant
Good, there's no mention of vercel in the config file predicates. Let me look at the full list of config patterns to understand the structure:
- Assistant
Now I understand the issue. The
is_config_filefunction in/fallow/crates/core/src/analyze/predicates/file.rsneeds to include"vercel."as a config pattern. This will match all Vercel config files likevercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts.Let me check if there are any existing tests for vercel files:
- Assistant
Now I have a clear understanding of the issue. The
is_config_filefunction in/fallow/crates/core/src/analyze/predicates/file.rscontains a list of config file patterns, but it doesn't include"vercel."as a pattern. This meansvercel.ts,vercel.js,vercel.mjs,vercel.cjs, andvercel.mtsare not recognized as configuration files, so they're reported as unused.The fix is to add
"vercel."to theconfig_patternslist. Let me make the edit: - Assistant
I need to add
"vercel."to the config_patterns list. Let me add it in the appropriate section - I'll add a "Deployment" section after "Frameworks / CMS": - Assistant
Now I need to add tests for the vercel config files. Let me look at the test section to see where I should add them:
- Assistant
Let me look at the test section around the framework configs to find a good place to add the test:
- Assistant
Let me find the exact line number to add the test:
- Assistant
Let me add the test for vercel config files after the sentry configs test:
- Assistant
I see my edit got messed up - it seems there was an issue with the replacement. Let me check the current state:
- Assistant
I see the issue - my edit accidentally corrupted the sentry test function and created a duplicate. Let me fix this:
- Assistant
I still see a duplicate. Let me fix this properly:
- Assistant
Good, the file now looks correct. Let me verify the changes by running the tests:
- Assistant
The package name is
fallow-corenotfallow_core. - Assistant
All 36 tests pass. Let me also check if there are any integration tests related to unused files:
- Assistant
Let me check if there are integration tests related to the unused-files analysis:
- Assistant
Let me also check if there are integration tests for config files and run them to make sure they still pass:
- Assistant
Let me check if there's a test about config files not being reported as unused:
- Assistant
All tests pass. Let me also run a broader test suite to make sure nothing is broken:
- Assistant
All 541 tests pass. Let me also run the CLI tests to make sure nothing is broken:
- Assistant
There's a test failure in fallow-cli, but it doesn't seem to be related to my changes - it's about
fix_batch_aborts_when_a_target_directory_is_read_onlywhich is about fixing files. Let me check if this test was already failing before my changes: - Assistant
The test was already failing before my changes. Let me restore my changes:
- Assistant
Good, the test failure is pre-existing and unrelated to my changes. Now let me verify that the
is_config_filepredicate is indeed the one used in the dead code detection pipeline: - Assistant
The
is_config_filepredicate is correctly used in bothunused_files.rsandunused_deps.rs. My change will correctly preventvercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts, andvercel.jsonfrom being reported as unused.Let me also check if there's any other place in the codebase that might need to be updated:
- Assistant
Let me also check if there are any other deployment config files that might need similar treatment (like netlify.toml):
- Assistant
Now let me look at the CLAUDE.md for any conventions I should follow:
- Assistant
Let me verify my changes by looking at the final state of the modified file:
- Assistant
The diff looks clean. Let me run all the tests again to make sure everything is fine:
- Assistant
All 541 tests pass. Let me also run the clippy check to make sure there are no warnings:
- Assistant
Clippy passes with no warnings. Let me also run the formatting check:
- Assistant
All checks pass. Let me verify the final state of my changes:
- Assistant
My change is minimal and focused. Let me review the final state one more time:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.