prefer-arrow-functions
Which form a function is written in.
Agent checkAdvises by default
The rule
Agents read this text as written when they write and review code.
Write functions as arrow functions.
Then every function in a codebase is declared the same way.
Examples
The agent flags code like the incorrect example and accepts code like the correct one.
Incorrect
interface Params {firstName: string;lastName: string;}// Incorrect: a `function` declaration, in a codebase whose functions are arrows.export function getDisplayName({ firstName, lastName }: Params): string {return `${firstName} ${lastName}`;}
Correct
interface Params {firstName: string;lastName: string;}// Correct: an arrow function, like every other function in the codebase.export const getDisplayName = ({ firstName, lastName }: Params): string => {return `${firstName} ${lastName}`;};
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"prefer-arrow-functions": "advisory"}}