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

source-academy / js-slang / 24868044425

24 Apr 2026 01:47AM UTC coverage: 78.522% (+0.1%) from 78.391%
24868044425

push

github

web-flow
Error Handling and Stringify Changes (#1893)

* Modify stringify to prioritize toReplString

* Make the extract declarations helper actually work

* Add ability to change loader for source modules

* Add a new option for controlling how Source modules are loaded

* Improve typing for CSE machine

* Add ability to check if modules are loaded with the wrong Source chapter

* Refactor errors to extend from Error class

* Refactor modules errors

* Refactor parser errors

* Refactor cse machine errors

* Mostly fix error handling in the tracer

* Tidy up generator and explainer implementations for tracer

* Remove unnecessary imports and type guards

* Adjust rttc checks to be type guards instead of returning errors

* Adjust miscellanous error changes

* Add eslint rule for useless constructor

* Fix incorrect ordering for checking exceptionerrors

* Minor changes

* Run format

* Run linting

* Override the message property, but also enable noImplicitOverride to prevent accidental overriding

* Add some documentation to some errors

* Add errors to possible imports for modules

* Update getIds helper

* Minor fix to test case

* Run format

* Allow modules to try and load the context of other modules without crashing

* Fix incorrect stdlib name

* Add some more functions to the stdlib list library

* Change to use GeneralRuntimeError for list

* Revert "Change to use GeneralRuntimeError for list"

This reverts commit 642bd99e6.

* Update src/errors/errors.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Add ability to change manifest and docs importers

* Change how external builtins are defined

* Fix typings and list lib overloads

* Miscellanous changes

* Add the Source equality function to stdlib/misc

* Merge from main branch for tracer

* Add handling for the new importers

* Change errors and made redex a local variable

* Improve tracer typing

* Relocate... (continued)

3125 of 4193 branches covered (74.53%)

Branch coverage included in aggregate %.

899 of 1089 new or added lines in 96 files covered. (82.55%)

21 existing lines in 12 files now uncovered.

7031 of 8741 relevant lines covered (80.44%)

185057.72 hits per line

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

89.29
/src/parser/source/rules/noUnspecifiedOperator.ts
1
import type { AssignmentExpression, BinaryExpression, UnaryExpression } from 'estree';
2
import { RuleError } from '../../errors';
3
import { defineRule } 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 override explain() {
16
    return `Operator '${this.unspecifiedOperator}' is not allowed.`;
4✔
17
  }
18

19
  public override 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() {
34
    return '== and != are not valid operators.';
×
35
  }
36
}
37

38
export default defineRule('no-unspecified-operator', {
39
  BinaryExpression(node) {
40
    const permittedOperators: BinaryExpression['operator'][] = [
82,617✔
41
      '+',
42
      '-',
43
      '*',
44
      '/',
45
      '%',
46
      '===',
47
      '!==',
48
      '<',
49
      '>',
50
      '<=',
51
      '>=',
52
      // '&&',
53
      // '||'
54
    ];
55

56
    if (node.operator === '!=' || node.operator === '==') {
82,617✔
57
      return [new StrictEqualityError(node)];
2✔
58
    } else if (!permittedOperators.includes(node.operator)) {
82,615✔
59
      return [new NoUnspecifiedOperatorError(node)];
2✔
60
    } else {
61
      return [];
82,613✔
62
    }
63
  },
64
  UnaryExpression(node) {
65
    const permittedOperators = ['-', '!', 'typeof'];
4,686✔
66
    if (!permittedOperators.includes(node.operator)) {
4,686!
NEW
67
      return [new NoUnspecifiedOperatorError(node)];
×
68
    } else {
69
      return [];
4,686✔
70
    }
71
  },
72
});
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