I am currently working on a custom rule to alphabetically sort the constructor parameters using the "quick fix" feature from eslint. I want to isolate the constructor parameters in order for eslint to display squiggly lines and my custom message when hovering over them. However, I am having trouble figuring out how to achieve this just by looking at the AST of the example code provided here:
Can someone advise me on which approach to take? How can I ensure that only the identifiers within the constructor are checked?
//example code used in AST explorer
constructor(
private _appService: AppService,
private _authService: AuthService,
private _formBuilder: FormBuilder,
private _manageScenarioService: ManageScenarioService,
) {}
This is what I have so far: The issue I am facing is that it highlights all identifiers rather than just those within the constructor.
import { Rule } from 'eslint';
export function diSortRule(context: Rule.RuleContext): Rule.RuleListener {
return {
Identifier(node) {
context.report({
node,
message: 'this pops up here',
});
},
};
}
Any assistance or guidance on this matter would be greatly appreciated!