Skip to content

feat: ban export default function via no-restricted-syntax#6

Merged
stevensacks merged 1 commit intomainfrom
feat/no-default-exported-function
Apr 29, 2026
Merged

feat: ban export default function via no-restricted-syntax#6
stevensacks merged 1 commit intomainfrom
feat/no-default-exported-function

Conversation

@stevensacks
Copy link
Copy Markdown
Contributor

Summary

  • Closes a hardcoded upstream gap in eslint-plugin-prefer-arrow-functions: the plugin's guard.js:hasNameAndIsExportedAsDefaultExport silently exempts export default function NamedFn() {} from prefer-arrow-functions/prefer-arrow-functions, regardless of allowNamedFunctions setting.
  • Adds a companion no-restricted-syntax rule with selector ExportDefaultDeclaration > FunctionDeclaration inside the prefer-arrow config block.
  • Ignores **/*.d.ts since ambient declarations have no body to convert.
  • Patch bump (changeset included).

Migration

Convert offenders to:
```tsx
const Name = () => { ... };
export default Name;
```

Verification

  • `pnpm typecheck` passes
  • `pnpm lint` passes
  • Verified clean against `gaia/` (zero pre-existing offenders) and `docs/` (31 offenders, all converted in a separate PR)

Note

Commit subject has a typo (`eat:` instead of `feat:`) — happy to amend before merge if you'd like.

🤖 Generated with Claude Code

  The eslint-plugin-prefer-arrow-functions plugin has a hardcoded
  exemption in guard.js:hasNameAndIsExportedAsDefaultExport that silently
  passes named default-exported function declarations regardless of any
  configuration option. Add a companion no-restricted-syntax selector
  (ExportDefaultDeclaration > FunctionDeclaration) inside the
  prefer-arrow config block to close the gap. Ignore *.d.ts since ambient
  signatures have no body to convert.

  Convert offenders to: const Name = () => {}; export default Name;

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stevensacks stevensacks merged commit efebb80 into main Apr 29, 2026
1 check passed
@stevensacks stevensacks deleted the feat/no-default-exported-function branch April 29, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant