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

source-academy / js-slang / 23995741899

05 Apr 2026 06:14AM UTC coverage: 77.093% (+0.002%) from 77.091%
23995741899

push

github

web-flow
Upgrade to TypeScript 6 and Prettier improvements (#1936)

* Upgrade TypeScript to v6

* Fix import source

* Fix tsconfig

* Fix preexisting type errors

* Remove scm-slang

* Bump node types

* Fix tsconfig

* Fix node types specifier

* Enable trailing commas

* Enable semicolons

* Check and commit files with changed line numbers

* Update Yarn to 4.13.0

* Remove unneeded sicp package deps

3112 of 4282 branches covered (72.68%)

Branch coverage included in aggregate %.

3761 of 5218 new or added lines in 152 files covered. (72.08%)

26 existing lines in 9 files now uncovered.

7136 of 9011 relevant lines covered (79.19%)

175254.05 hits per line

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

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

5
type ExpressionNodeType = AssignmentExpression | BinaryExpression | UnaryExpression;
6

7
export class NoUnspecifiedOperatorError<T extends ExpressionNodeType> extends RuleError<T> {
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> {
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() {
NEW
34
    return '== and != are not valid operators.';
×
35
  }
36
}
37

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

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

59
      if (node.operator === '!=' || node.operator === '==') {
82,431✔
60
        return [new StrictEqualityError(node)];
2✔
61
      } else if (!permittedOperators.includes(node.operator)) {
82,429✔
62
        return [new NoUnspecifiedOperatorError(node)];
2✔
63
      } else {
64
        return [];
82,427✔
65
      }
66
    },
67
    UnaryExpression(node) {
68
      const permittedOperators = ['-', '!', 'typeof'];
4,678✔
69
      if (!permittedOperators.includes(node.operator)) {
4,678!
NEW
70
        return [new NoUnspecifiedOperatorError(node)];
×
71
      } else {
72
        return [];
4,678✔
73
      }
74
    },
75
  },
76
};
77

78
export default noUnspecifiedOperator;
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