-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathconstructor-syntax.js
46 lines (37 loc) · 1006 Bytes
/
constructor-syntax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const BaseDeprecation = require('./base-deprecation')
const ruleId = 'constructor-syntax'
const meta = {
type: 'best-practices',
docs: {
description: 'Constructors should use the new constructor keyword.',
category: 'Best Practices Rules',
},
isDefault: false,
recommended: false,
defaultSetup: 'warn',
schema: null,
}
class ConstructorSyntax extends BaseDeprecation {
constructor(reporter) {
super(reporter, ruleId, meta)
}
deprecationVersion() {
return '0.4.22'
}
PragmaDirective(node) {
super.PragmaDirective(node)
}
FunctionDefinition(node) {
if (node.isConstructor) {
if (node.name === null) {
if (!this.active) {
const message = 'Constructor keyword not available before 0.4.22 (' + this.version + ')'
this.error(node, message)
}
} else if (this.active) {
this.warn(node, 'Constructors should use the new constructor keyword.')
}
}
}
}
module.exports = ConstructorSyntax