noInvalidConstructorSuper
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/correctness/noInvalidConstructorSuper¥Diagnostic Category:
lint/correctness/noInvalidConstructorSuper -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
-
与
constructor-super相同¥Same as
constructor-super
-
¥How to configure
{ "linter": { "rules": { "correctness": { "noInvalidConstructorSuper": "error" } } }}¥Description
防止在类中错误使用 super()。它还检查扩展其他构造函数的类中是否缺少调用 super()。
¥Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.
¥Examples
¥Invalid
class A { constructor() { super(); }}code-block.js:3:9 lint/correctness/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This class should not have a super() call. You should remove it.
1 │ class A {
2 │ constructor() {
> 3 │ super();
│ ^^^^^
4 │ }
5 │ }
class A extends undefined { constructor() { super(); }}code-block.js:3:9 lint/correctness/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This class calls super(), but the class extends from a non-constructor.
1 │ class A extends undefined {
2 │ constructor() {
> 3 │ super();
│ ^^^^^
4 │ }
5 │ }
ℹ This is where the non-constructor is used.
> 1 │ class A extends undefined {
│ ^^^^^^^^^
2 │ constructor() {
3 │ super();
¥Valid
export default class A extends B { constructor() { super(); }}export class A { constructor() {}}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号