This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Recommended max-func-body-length rule ignores functions named /.+describe.+/ as well #465
Labels
Difficulty: Easy
Someone with little to no experience in TSLint should be able to send a pull request for this issue.
Good First Issue 🙌
Howdy, neighbor!
Type: Rule Feature
Adding a feature to an existing rule.
Milestone
Repro
I've prepared a easy-to-start test case. Clone the package, run
npm i
, and thennpm run lint
.OR
xyzdescribexyz
is called with a 101-line arrow function as a parameter.Expected result
"Max arrow function body length exceeded" error should be raised at the point calling
xyzdescribexyz
.Actual result
No error for
xyzdescribexyz
.Note that the test case I provided also includes a test for
describ
, to which an error is raised as expected.Considerations
This happens because the current recommended options for max-func-body-length rule sets "ignore-parameters-to-function-regex" to "describe". Therefore, functions whose name matches /.+describe.+/ (I mean not only /^describe$/) will be ignored for this rule by default.
I recognize that this option is set not to raise errors for describe() in Mocha (indeed it is stated that "this can be useful for Mocha users to ignore the describe() function" in README), and I personally think the intention itself is rational. However, since the given rule matches functions other than describe(), which is not a good idea, I would propose to change the recommended value to a stricter one, such as /^describe$/.
The text was updated successfully, but these errors were encountered: