• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 15237418122

25 May 2025 11:31AM UTC coverage: 77.048% (-3.5%) from 80.538%
15237418122

push

github

web-flow
Rewrite: Stepper (#1742)

3433 of 4826 branches covered (71.14%)

Branch coverage included in aggregate %.

1032 of 1260 new or added lines in 27 files covered. (81.9%)

440 existing lines in 29 files now uncovered.

10099 of 12737 relevant lines covered (79.29%)

142411.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/parser/source/rules/noUnspecifiedOperator.ts
1
import type { AssignmentExpression, BinaryExpression, UnaryExpression } from 'estree'
2
import type { Rule } from '../../types'
3
import { RuleError } from '../../errors'
77✔
4

5
type ExpressionNodeType = AssignmentExpression | BinaryExpression | UnaryExpression
6

7
export class NoUnspecifiedOperatorError<T extends ExpressionNodeType> extends RuleError<T> {
77✔
8
  public readonly unspecifiedOperator: T['operator']
9

10
  constructor(node: T) {
11
    super(node)
10✔
12
    this.unspecifiedOperator = node.operator
10✔
13
  }
14

15
  public explain() {
16
    return `Operator '${this.unspecifiedOperator}' is not allowed.`
4✔
17
  }
18

19
  public elaborate() {
20
    return ''
2✔
21
  }
22
}
23

24
export class StrictEqualityError extends NoUnspecifiedOperatorError<BinaryExpression> {
77✔
25
  public override explain() {
26
    if (this.node.operator === '==') {
2✔
27
      return 'Use === instead of ==.'
1✔
28
    } else {
29
      return 'Use !== instead of !=.'
1✔
30
    }
31
  }
32

33
  public override elaborate() {
UNCOV
34
    return '== and != are not valid operators.'
×
35
  }
36
}
37

38
const noUnspecifiedOperator: Rule<BinaryExpression | UnaryExpression> = {
77✔
39
  name: 'no-unspecified-operator',
40

41
  checkers: {
42
    BinaryExpression(node) {
43
      const permittedOperators = [
87,857✔
44
        '+',
45
        '-',
46
        '*',
47
        '/',
48
        '%',
49
        '===',
50
        '!==',
51
        '<',
52
        '>',
53
        '<=',
54
        '>=',
55
        '&&',
56
        '||'
57
      ]
58

59
      if (node.operator === '!=' || node.operator === '==') {
87,857✔
60
        return [new StrictEqualityError(node)]
2✔
61
      } else if (!permittedOperators.includes(node.operator)) {
87,855✔
62
        return [new NoUnspecifiedOperatorError(node)]
2✔
63
      } else {
64
        return []
87,853✔
65
      }
66
    },
67
    UnaryExpression(node) {
68
      const permittedOperators = ['-', '!', 'typeof']
5,124✔
69
      if (!permittedOperators.includes(node.operator)) {
5,124!
UNCOV
70
        return [new NoUnspecifiedOperatorError(node)]
×
71
      } else {
72
        return []
5,124✔
73
      }
74
    }
75
  }
76
}
77

78
export default noUnspecifiedOperator
77✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc