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.packages/config/example/vercel.tsshows the expectedexport const configshape.
Because Vercel discovers this file by convention, Fallow should not report it as unused.
Reproduction
Create an app/workspace with a
package.jsonlike:{ "name": "@example/web", "private": true, "type": "module", "scripts": { "build": "next build", "env-pull": "vercel env pull" }, "devDependencies": { "@vercel/config": "latest", "vercel": "latest" } }Create
vercel.tsat the app root:import type { VercelConfig } from '@vercel/config/v1'; export const config = { regions: ['dub1'], fluid: true, installCommand: 'pnpm install --filter @example/web...', devCommand: 'next dev --port 3000', crons: [ { path: '/api/jobs/run', schedule: '*/5 * * * *', }, ], } satisfies VercelConfig;Run:
fallow dead-codevercel.tsis reported as an unused file.Expected behavior
Fallow should treat Vercel programmatic config files as used config entrypoints when Vercel is active.
At minimum, the Vercel plugin/config detection should mark these app-root files as always used:
vercel.tsvercel.jsvercel.mjsvercel.cjsvercel.mts
A fix could add these to the relevant Vercel plugin config/always-used patterns, similar to how other framework config files are protected from unused-file reporting.
Fallow version
2.85.0
Operating system
macOS
Configuration
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /fallow, current file: none) bash-$
Assistant
Let me analyze this issue. The problem is that
fallow dead-codereportsvercel.ts(and similar Vercel config files) as unused files, but these are convention-based configuration files that Vercel discovers and executes at build time. They're not imported by application source code, so they appear unused in a pure import graph analysis.I need to:
- Explore the repository structure to understand how the codebase is organized
- Find where other framework config files are protected from unused-file reporting
- Add support for Vercel config files (
vercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts)
Let me start by exploring the repository structure.
Assistant
This is a Rust project. Let me explore the crates directory to understand the structure better. I need to find where "unused files" detection happens and where other framework config files are protected.
Assistant
Let me search for where unused files are detected and where other framework config files (like Vercel) are handled.
Assistant
Let me look at the unused files detection code and the plugins directory.
Assistant
I don't see a specific Vercel plugin. Let me check how other similar config files are handled. Let me look at the
vercelreferences in the existing code and check thediscover/mod.rsfile.Assistant
Now let me look at the unused_files analysis to understand how files are determined to be unused and how framework config files are protected:
Assistant
Now I need to look at the
is_config_filepredicate to see how config files are detected:Assistant
Now I understand the code structure. The
is_config_filefunction in/fallow/crates/core/src/analyze/predicates/file.rsis responsible for detecting configuration files that should not be reported as unused. I need to add Vercel config file patterns to theconfig_patternsarray.The patterns for Vercel config files should be:
vercel.tsvercel.jsvercel.mjsvercel.cjsvercel.mts
Let me also check if there's a plugin system that could be a better approach, by looking at how other framework-specific configs are handled:
Assistant
Let me look at the nextjs plugin to understand how Vercel-related configs might be handled:
Assistant
Now I understand the plugin system well. There are two approaches to fix this issue:
-
Add
vercel.config.patterns tois_config_filein the predicates file - This is a simpler approach that treats Vercel config files like other framework config files. -
Create a Vercel plugin - This would be a more comprehensive solution but might be overkill for just adding config file detection.
Looking at the issue description, the simplest and most consistent approach is to add the Vercel config file patterns to
is_config_filein the predicates file. The patterns should match files likevercel.ts,vercel.js,vercel.mjs,vercel.cjs, andvercel.mts.Looking at the existing patterns in
is_config_file, they all start with a prefix like"next.config.","vite.config.", etc. So I should add"vercel."as a pattern prefix.Let me also check what the
always_usedfield does in plugins to see if there's a similar pattern there:-
Assistant
Let me understand how
always_usedfiles work and where they're used in the analysis:Assistant
Let me look at how the
always_usedpatterns are matched against files:Assistant
I think I understand the architecture now. The
always_usedpatterns from plugins are added todiscovered_always_usedwhich is then used to mark files as always used. But for theis_config_filepredicate inunused_files.rs, this is a separate check that filters out config files from being reported as unused.Let me look at how
discovered_always_usedis used:Assistant
Let me check how the always_used patterns are used in entry_points to understand the full flow:
Assistant
Now I understand the flow better. The
always_usedpatterns from plugins mark files as "always used" which effectively makes them entry points. However, theis_config_filefunction in the predicates file is used specifically to filter out config files from the unused file report.Looking at this, I think the best approach is to add the
vercel.prefix pattern to theconfig_patternsarray inis_config_file. This is consistent with how other config files likenext.config.,vite.config., etc. are handled.Let me now make the change:
Assistant
Now I can see the config patterns. I'll add
"vercel."to the patterns list. Since Vercel config files don't use the.config.naming convention but are just namedvercel.{ext}, I need to add"vercel."as a pattern. Let me add it near the other framework/deployment patterns:Assistant
Let me verify the change:
Assistant
The change has been made. Now let me add a test case for Vercel config files to ensure the pattern works correctly:
Assistant
Now let me add a test for the Vercel config files. I'll add it to the test section:
Assistant
The sed command didn't work because of multiline matching issues. Let me try a different approach:
Assistant
I see there's an issue - there are two
#[test]attributes and the doc comment is in the wrong place. Let me fix this:Assistant
The test looks good now. Let me run the tests to make sure everything compiles and passes:
Assistant
The
--no-fail-fastoption isn't recognized for cargo test in this context. Let me run the test without it:Assistant
All 36 tests passed, including the new
config_file_vercel_configstest. Now let me also run the broader unused_files tests to make sure nothing is broken:Assistant
All tests pass. Now let me check if there are any existing tests related to Vercel that I should be aware of:
Assistant
The tests directory doesn't contain unit tests in Rust - those are test fixtures. Let me run a broader set of tests to make sure the change doesn't break anything:
Assistant
All 446 tests pass. Now let me also verify that the pattern works correctly by looking at the final state of the file:
Assistant
The change looks clean and minimal. Let me now think about edge cases:
- Files with paths containing
vercel.: The pattern"vercel."will match any file starting withvercel.including files in subdirectories. Let me verify the test case for this:
- Files with paths containing
Assistant
Good, the test confirms that directory paths don't matter - only the file name is checked. Let me also verify that my change correctly handles subdirectory scenarios:
Assistant
All edge cases are handled correctly. Let me run a few more related tests to make sure the broader test suite still passes:
Assistant
All 2462 tests pass. Let me also verify the change in the context of the complete config_patterns array one more time:
Assistant
The implementation is complete. Let me now verify that there are no clippy warnings or formatting issues:
Assistant
No warnings. Let me also run the formatting check:
Assistant
No formatting issues. Let me now provide a summary of my changes and complete the checklist:
Summary of Changes
I added support for Vercel programmatic config files (
vercel.ts,vercel.js,vercel.mjs,vercel.cjs,vercel.mts) to the config file detection in the unused files analysis.File Modified
/fallow/crates/core/src/analyze/predicates/file.rs
Changes Made
- Added
"vercel."to theconfig_patternsarray in theis_config_filefunction (line 84) - Added a new test
config_file_vercel_configs()that verifies all Vercel config file variants are recognized as config files
How It Works
The
is_config_filefunction checks if a file's name matches any of the known config file patterns. The pattern"vercel."will match:vercel.tsvercel.jsvercel.mjsvercel.cjsvercel.mts- Files in subdirectories like
apps/web/vercel.ts(which is the case reported in the issue)
The pattern only matches the file name (not the full path), so it correctly handles workspace packages and nested apps.
Checklist
-
If an error was reported in the issue description, I have successfully reproduced it.
- The issue describes a false positive where
vercel.tsis reported as an unused file. I confirmed this by examining theis_config_filefunction and verifying thatvercel.tswas not in the list of recognized config file patterns.
- The issue describes a false positive where
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I added
"vercel."to the config patterns and confirmed with both unit tests and a manual test script that all Vercel config file variants are now recognized as config files.
- I added
-
I have thought about edge cases and made sure my fix handles them as well.
- Verified that files in subdirectories (like
apps/web/vercel.ts) are correctly matched - Verified that similar file names like
my-vercel.tsorvercel-utils.tsare NOT matched - Verified that
vercelwithout an extension is NOT matched
- Verified that files in subdirectories (like
-
I have run existing tests in the repository that might have been affected by the change and made sure they pass.
- All 2462 tests in
fallow-corepass, including the new test I added and all existing predicate tests.
- All 2462 tests in
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →