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

source-academy / js-slang / 18446629348

12 Oct 2025 04:35PM UTC coverage: 77.428% (-0.005%) from 77.433%
18446629348

Pull #1821

github

web-flow
Merge 1f1018f6f 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 %.

8 of 11 new or added lines in 2 files covered. (72.73%)

8204 of 10298 relevant lines covered (79.67%)

172014.27 hits per line

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

71.43
/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
  public explain(): string {
NEW
8
    return 'Const declaration in init part of for statement is not allowed'
×
9
  }
10
  public elaborate(): string {
NEW
11
    return stripIndent`
×
12
      The init part of this statement cannot contain a const declaration, use a let declaration instead.
13
    `
14
  }
15
}
16
const noConstDeclarationInForLoopInit: Rule<ForStatement> = {
72✔
17
  name: 'no-const-declaration-in-for-loop-init',
18

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

25
      return []
742✔
26
    }
27
  }
28
}
29

30
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