Conversation
There was a problem hiding this comment.
Pull request overview
Updates the cjs-require rule’s configuration defaults/documentation so node_modules can be ignored via config (instead of a hardcoded path check), aiming to address “ignore” handling problems for this rule.
Changes:
- Set
cjs-requireruledefaultConfig.ignoreto['node_modules']. - Remove the hardcoded
isNodeModulesPath()issuer skip logic. - Update
Config.ignoredocstring to describe the new default.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/rules/rules/cjs-require/types.ts | Documents that ignore defaults to ['node_modules']. |
| packages/core/src/rules/rules/cjs-require/index.ts | Changes default ignore config and removes the prior issuer-only node_modules bypass. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| category: 'bundle', | ||
| severity: Linter.Severity.Warn, | ||
| defaultConfig: { | ||
| ignore: [], | ||
| ignore: ['node_modules'], | ||
| }, |
There was a problem hiding this comment.
Setting defaultConfig.ignore to ['node_modules'] will cause this rule to skip any dependency where either the issuer path or the required module path contains node_modules (see the ignore check below). Since requiredModule.path is typically inside node_modules for third-party requires, this likely suppresses the primary case this rule is meant to report (user code calling require('pkg')). Consider reverting the default to [] and keeping an explicit (cross-platform) “issuer is in node_modules” skip (e.g. the /[/\]node_modules[/\]/ pattern used in esm-resolved-to-cjs), or split config so only issuers are ignored by default.
Summary
This pull request updates the
cjs-requirerule to improve configurability and simplify the logic for ignoring certain module paths. The main changes include defaulting theignoreconfiguration to['node_modules'], removing the hardcoded check fornode_modulespaths, and updating documentation for clarity.Configuration improvements:
ignoreoption in the rule configuration is now['node_modules'], making it easier to customize which module paths are ignored without modifying code.Configinterface documentation intypes.tshas been updated to clarify thatignoredefaults to['node_modules'].Related Links