Skip to content

Help writing a new lint test #289

Answered by roaldnefs
matthewsht asked this question in Q&A
Discussion options

You must be logged in to vote

If you filter out all the Jinja placeholders and comments you could easily identify the state names in a SLS file using the regex ^(\S[^:]+):. This will get you all the lines starting without a whitespace (indentation) up to the : character in a capture group.

Using this regex you could write a rule that checks if the found state name starts with the formula, state and option substate you already know based upon the filename. If one of the state names doesn't match, it's not following your teams convention and should return the found regex capture group(s).

The filename can be obtain the filename inside your match(self, file, line) function using the file['path'] variable.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by roaldnefs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #281 on January 03, 2023 12:12.