biome-plugin-prefer-arrow-function
v1.0.0
Published
Biome GritQL plugin to prefer arrow functions over function declarations
Maintainers
Readme
biome-plugin-prefer-arrow-function
Biome GritQL plugin that reports function declarations and suggests using arrow functions instead.
Biome's built-in useArrowFunction rule only converts function expressions (const foo = function() {}). This plugin covers the gap by detecting function declarations (function foo() {}).
Requires Biome v2.0+
Detected patterns
function foo() {} // plain declaration
function foo(a, b) { return a + b } // with params
export function foo() {} // named export
export default function foo() {} // default export
async function foo() {} // asyncExcluded patterns
function* gen() {} // generator — no arrow equivalent
export function* gen() {} // exported generatorUsage
In this repo (for testing)
npm install
npx @biomejs/biome lint __tests__/In another project
Point to the .grit file from your biome.json:
{
"plugins": [
// relative or absolute path to the .grit file
"../biome-plugin-prefer-arrow-function/prefer-arrow-function.grit"
]
}Then run biome lint as usual.
Limitations
- GritQL plugins currently support diagnostics only — no auto-fix.
- Generator functions (
function*) are naturally excluded because the pattern doesn't match the*syntax.
References
- biomejs/biome#7108 — original feature request
- Biome Linter Plugins docs
- GritQL reference
