Repository navigation
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
3be81d1 to
d826344
Compare
There are two related practices are common to see across various projects: - Using a wildcard to re-export all symbols from a file in one statement - Adding "barrel" files to group together large packages into smaller modules While they might make sense for application code, we do not advise using these patterns for libraries within this repo for the following reasons: - They make it difficult to view the public surface area of a package at a glance, which is useful for security auditing purposes. - They make it difficult to notice new additions to the surface area. Any time a new export is added to one of these files, it will automatically become an export of the package, so it could be easily missed in a review (and fail to be added to the changelog). - They make it impossible to export a symbol from a file but not expose it publicly to consumers. This can be useful for testing purposes. - They can slow down static analysis tools (TypeScript, linting tools, etc.) because it increases the number of paths it takes to reach a file. We already added some guidelines discouraging teams from using wildcard re-exports, but we did not advise against creating barrel files. Crucially, we had nothing in place to enforce either, so problems have accrued in the meantime. This commit extends the existing guidelines and adds custom Oxlint plugins in `.oxlint-plugins` to enforce them (using suppressions to note the existing violations). References have also been updated in `AGENTS.md`.
d826344 to
eef6339
Compare
| 'scripts/**/*.{ts,js,sh}', | ||
| 'tests/**/*.ts', | ||
| '*.config.{js,cjs,mjs,ts}', | ||
| '.oxlint-plugins/**/*.ts', |
There was a problem hiding this comment.
I've alphabetized this list, but .oxlint-plugins is new.
| @@ -173,7 +174,8 @@ Use `yarn create-package --name <name> --description <description>` to add a new | |||
| ### General package guidelines | |||
|
|
|||
| - Each package should have an `index.ts` file in `src/` that explicitly lists all exports. | |||
There was a problem hiding this comment.
I plan on introducing a new PR which tells the agent to read the package guidelines, but for now we repeat the same information.
| }, | ||
| }); | ||
|
|
||
| ruleTester.run('no-barrel-files', noBarrelFiles, { |
There was a problem hiding this comment.
I learned about Oxlint's RuleTester class while adding this: https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html#writing-tests-for-custom-rules
There was a problem hiding this comment.
Nice, we should add that to the Oxlint config repo.
Mrtenz
left a comment
There was a problem hiding this comment.
Maybe consider moving this to the Oxlint config repo? I was thinking about creating a plugin for no-restricted-syntax too.
Explanation
There are two related practices that we have seen other teams follow:
While they might make sense for application code, we do not advise using these patterns for libraries within this repo for the following reasons:
We already added some guidelines discouraging teams from using wildcard re-exports, but we did not advise against creating barrel files (except in cases where it makes sense, such as defining entrypoints for package exports). Crucially, we had nothing in place to enforce either. As a result, problems have accrued.
This commit extends the existing guidelines and adds custom Oxlint plugins in
.oxlint-pluginsto enforce them (using suppressions to note the existing violations). References have also been updated inAGENTS.md.Manual testing steps
packages/network-controller/src/index.ts../constants.jsexplaining that named wildcard exports are not allowed.packages/profile-sync-controller/src/controllers/index.ts.References
Checklist
Note
Cursor Bugbot is generating a summary for commit eef6339. Configure here.