• 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

72.73
/src/parser/source/rules/noDeclareMutable.ts
1
import { generate } from 'astring';
2
import type { VariableDeclaration } from 'estree';
3
import { Chapter } from '../../../langs';
4
import { getSourceVariableDeclaration } from '../../../utils/ast/helpers';
5
import { RuleError } from '../../errors';
6
import type { Rule } from '../../types';
7

8
const mutableDeclarators: VariableDeclaration['kind'][] = ['let', 'var'];
65✔
9

10
export class NoDeclareMutableError extends RuleError<VariableDeclaration> {
11
  public explain() {
12
    return `Mutable variable declaration using keyword '${this.node.kind}' is not allowed.`;
11✔
13
  }
14

15
  public elaborate() {
16
    const {
17
      id: { name },
NEW
18
      init,
×
19
    } = getSourceVariableDeclaration(this.node);
NEW
20
    const value = generate(init);
×
21

NEW
22
    return `Use keyword "const" instead, to declare a constant:\n\n\tconst ${name} = ${value};`;
×
23
  }
24
}
25

26
const noDeclareMutable: Rule<VariableDeclaration> = {
65✔
27
  name: 'no-declare-mutable',
28
  disableFromChapter: Chapter.SOURCE_3,
29

30
  checkers: {
31
    VariableDeclaration(node) {
32
      if (mutableDeclarators.includes(node.kind)) {
3,871✔
33
        return [new NoDeclareMutableError(node)];
11✔
34
      } else {
35
        return [];
3,860✔
36
      }
37
    },
38
  },
39
};
40

41
export default noDeclareMutable;
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