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

source-academy / js-slang / 18446573451

12 Oct 2025 04:29PM UTC coverage: 77.423% (-0.01%) from 77.433%
18446573451

Pull #1821

github

web-flow
Merge 2de06d8f6 into 4105ea06f
Pull Request #1821: Check for const declaration in for statement init

2749 of 3848 branches covered (71.44%)

Branch coverage included in aggregate %.

7 of 11 new or added lines in 2 files covered. (63.64%)

8204 of 10299 relevant lines covered (79.66%)

135154.4 hits per line

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

66.67
/src/parser/source/rules/noConstDeclarationInForLoopInit.ts
1
import type { ForStatement } from 'estree'
2
import type { Rule } from '../../types'
3
import { stripIndent } from '../../../utils/formatters'
72✔
4
import { RuleError } from '../../errors'
72✔
5

6
export class NoConstDeclarationInForLoopInit extends RuleError<ForStatement> {
72✔
7
  constructor(node: ForStatement) {
NEW
8
    super(node)
×
9
  }
10
  public explain(): string {
NEW
11
    return 'Const declaration in init part of for statement is not allowed'
×
12
  }
13
  public elaborate(): string {
NEW
14
    return stripIndent`
×
15
      The init part of this statement cannot contain a const declaration, use a let declaration instead.
16
    `
17
  }
18
}
19
const noConstDeclarationInForLoopInit: Rule<ForStatement> = {
72✔
20
  name: 'no-const-declaration-in-for-loop-init',
21

22
  checkers: {
23
    ForStatement(node) {
24
      if (node.init && node.init.type === 'VariableDeclaration' && node.init.kind === 'const') {
742!
NEW
25
        return [new NoConstDeclarationInForLoopInit(node)]
×
26
      }
27

28
      return []
742✔
29
    }
30
  }
31
}
32

33
export { noConstDeclarationInForLoopInit }
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