Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements proposed max-template-depth rule #2525

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
addresses PR comments
  • Loading branch information
kevsommer committed Aug 13, 2024
commit acb4b4a84f417b7c41ba6cd12b19c533b02f6308
4 changes: 2 additions & 2 deletions docs/rules/max-template-depth.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ There is one property that can be specified for the object.

- `maxDepth` ... Specify the maximum template depth `template` block.

## `{ maxDepth: 3 }`
### `{ maxDepth: 3 }`

<eslint-code-block :rules="{'vue/max-template-depth': ['error', { maxDepth: 3 }]}">

Expand All @@ -46,7 +46,7 @@ There is one property that can be specified for the object.

</eslint-code-block>

### `{ maxDepth: 5 }`
### `{ maxDepth: 3}`

<eslint-code-block :rules="{'vue/max-template-depth': ['error', { maxDepth: 3 }]}">

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-template-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
],
messages: {
templateTooDeep:
'Template is too deep (depth of {{depth}}). Maximum allowed is {{limit}}.'
'Element is nested too deeply (depth of {{depth}}, maximum allowed is {{limit}}).'
}
},
/** @param {RuleContext} context */
Expand Down
15 changes: 10 additions & 5 deletions tests/lib/rules/max-template-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ tester.run('max-template-depth', rule, {
options: [{ maxDepth: 3 }],
errors: [
{
message: 'Template is too deep (depth of 4). Maximum allowed is 3.',
message:
'Element is nested too deeply (depth of 4, maximum allowed is 3).',
line: 6
}
]
Expand All @@ -117,7 +118,8 @@ tester.run('max-template-depth', rule, {
options: [{ maxDepth: 3 }],
errors: [
{
message: 'Template is too deep (depth of 4). Maximum allowed is 3.',
message:
'Element is nested too deeply (depth of 4, maximum allowed is 3).',
line: 9
}
]
Expand All @@ -143,17 +145,20 @@ tester.run('max-template-depth', rule, {
options: [{ maxDepth: 3 }],
errors: [
{
message: 'Template is too deep (depth of 4). Maximum allowed is 3.',
message:
'Element is nested too deeply (depth of 4, maximum allowed is 3).',
line: 9,
endLine: 12
},
{
message: 'Template is too deep (depth of 5). Maximum allowed is 3.',
message:
'Element is nested too deeply (depth of 5, maximum allowed is 3).',
line: 10,
endLine: 10
},
{
message: 'Template is too deep (depth of 5). Maximum allowed is 3.',
message:
'Element is nested too deeply (depth of 5, maximum allowed is 3).',
line: 11,
endLine: 12
}
Expand Down
Loading