noExcessiveNestedTestSuites
¥Summary
-
规则生效日期:
v1.6.0¥Rule available since:
v1.6.0 -
诊断类别:
lint/complexity/noExcessiveNestedTestSuites¥Diagnostic Category:
lint/complexity/noExcessiveNestedTestSuites -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
¥Same as
jest/max-nested-describe -
与
vitest/max-nested-describe相同¥Same as
vitest/max-nested-describe
-
¥How to configure
{ "linter": { "rules": { "complexity": { "noExcessiveNestedTestSuites": "error" } } }}¥Description
此规则强制测试文件中嵌套 describe() 的最大深度。
¥This rule enforces a maximum depth to nested describe() in test files.
为了提高测试中的代码清晰度,规则将嵌套的 describe 限制为 5。
¥To improve code clarity in your tests, the rule limits nested describe to 5.
¥Examples
¥Invalid
describe('foo', () => { describe('bar', () => { describe('baz', () => { describe('qux', () => { describe('quxx', () => { describe('too many', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); }); }); });});code-block.js:6:11 lint/complexity/noExcessiveNestedTestSuites ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Excessive `describe()` nesting detected.
4 │ describe(‘qux’, () => {
5 │ describe(‘quxx’, () => {
> 6 │ describe(‘too many’, () => {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 7 │ it(‘should get something’, () => {
> 8 │ expect(getSomething()).toBe(‘Something’);
> 9 │ });
> 10 │ });
│ ^^
11 │ });
12 │ });
ℹ Excessive nesting of describe() calls can hinder test readability.
ℹ Consider refactoring and reduce the level of nested describe to improve code clarity.
¥Valid
describe('foo', () => { describe('bar', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); describe('qux', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); });});¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号