Skip to content

Instantly share code, notes, and snippets.

@kezzico
Created October 6, 2023 16:15
Show Gist options
  • Save kezzico/1fbc02d25f3ad4a6caf4e8170d3b1e97 to your computer and use it in GitHub Desktop.
Save kezzico/1fbc02d25f3ad4a6caf4e8170d3b1e97 to your computer and use it in GitHub Desktop.
module.exports = {
meta: {
type: 'layout', // Specify the rule type ('problem', 'suggestion', or 'layout')
fixable: 'whitespace', // Allow ESLint to fix the issues automatically
},
create: function (context) {
return {
FunctionDeclaration(node) {
const params = node.params;
for (let i = 1; i < params.length; i++) {
if (params[i].loc.start.line === params[i - 1].loc.end.line) {
context.report({
node: params[i],
message: 'Add a newline between function parameters.',
fix: function (fixer) {
return fixer.insertTextAfter(params[i - 1], '\n');
},
});
}
}
},
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment