Links

Use Regular Expressions

Please be aware that Packmind supports the ECMAScript flavor for regular expressions

Add a regular expression

In Packmind, select the practice on which you want to add a regular expression and click on the Configure Automatic Suggestions menu (bottom right of the modal).
Then, click on "+Add a regex configuration":
This will open this menu, where you have two main inputs in the form:
  • an input to specify your regular expression
  • an editor to test your expression against a source code
A switch button allows you to configure this regular expression for :
  • "positive": create an expression that identifies if a best practice is followed
  • "negative": create an expression that identifies if a best practice is not followed
If you have some existing examples in your best practice documentation, you'll find them listed below the editor. Just click on one of them to fill the editor with an example and test your regular expression against it.
Once you're satisfied with your regular expression, validate the operation by clicking the Add button.
Keep in mind you can add multiple regular expressions for a single practice!

Suggestion with AI

This feature automatically generates a regular expression tailored to your practice, distinguished by an "AI" icon and a distinctive purple border. The accuracy and effectiveness of the generated suggestion improve with the number of examples you associate with your practice. It's important to note that the generated suggestions are consistently designed to identify negative matches (cases where your coding practice is not followed).
This is an example of AI generated regular expression for the practice "Avoid using type any" for Typescript files

Specify file extensions

If you want to restrict the search of regular expressions to some specific file name (not the full path) or extensions, you can specify them on the right side of the regex edition:
Don't forget to click on the "+" button for each pattern you want to include.

Order regular expressions

If you've configured several regular expressions, both for positive and negative detection, you can define a priority order among them.
You can use the arrows on the left side to change the expression priorities. The algorithm will test each expression by order, and once one matches, it stops the execution. Thus, you won't get both positive and negative results since the first matching ends the search.