eslint capitalized-comments
labelled safe
Analysis Nemotron 3 Super
Flags comments whose first alphabetic character after leading whitespace/punctuation is lowercase when 'always' is configured.
Fix: Capitalizes the first alphabetic character in the comment text after any leading whitespace or comment markers, preserving all other characters and whitespace exactly.
8 hazards
- Changing '// @ts-ignore' to '// @Ts-ignore' alters the directive meaning for TypeScript compiler, potentially enabling type checking where it was suppressed.
- Modifying '/* global foo */' to '/* Global foo */' breaks ESLint's special global directive parsing, causing the global declaration to be ignored.
- Uppercasing '// eslint-disable-next-line' to '// Eslint-Disable-Next-Line' disables the directive, allowing lint errors on the next line to be reported again.
- Transforming '// http://example.com' to '// Http://example.com' changes the URL case, which may break case-sensitive links or references in documentation.
- Converting '// 隆hola!' to '// 隆Hola!' modifies the initial inverted exclamation mark's linguistic context in Spanish, altering the intended tone or meaning.
- Capitalizing '// 馃榾 emoji' to '// 馃榾 Emoji' shifts focus from the emoji to the following word, potentially changing the comment's emphasis or intent in informal contexts.
- Editing '// _private' to '// _Private' implies a different naming convention for internal variables, misleading readers about encapsulation intent.
- Altering '// TODO: fix' to '// TODO: Fix' changes the casing of a conventional task label, which might break tooling that scans for exact 'TODO' patterns.
Programs
| id | result | title | hazard |
|---|---|---|---|
| r1-p001 | fix ok | Comments Attached to Removed/Moved Code | Rewriting comments adjacent to dead code can mislead maintenance or hide logic errors. |
| r1-p002 | silent prediction off | URL Case Sensitivity Hazard | Changing '//' comments containing URLs breaks case-sensitive links in documentation or config. |
| r1-p003 | fix ok | Strict vs Sloppy Mode Semantics | Comment rewrites near 'use strict' directives may obscure mode boundaries, affecting eval/scoping. |
| r1-p004 | fix ok | Arguments Object and Parameter Hazards | Comments on function parameters interact with arguments, length, defaults, or rest鈥攃hanges may mislead refactoring. |
| r1-p005 | fix ok | Getters, Setters, and DefineProperty Side Effects | Altering comments on accessors may obscure intent during debugging or affect side-effect reliance. |
| r1-p006 | silent prediction off | Task Label Convention Breakage | Changing 'TODO: fix' to 'TODO: Fix' breaks tooling scanning for exact uppercase task labels. |
| r1-p007 | invalid | TS Ignore Directive Semantics | Rewriting '// @ts-ignore' to '// @Ts-ignore' disables the directive, causing type errors where suppression was intended. |
| r1-p008 | fix ok | This Binding: Arrow vs Function, Extraction, Call/Apply/Bind | Comments on function definitions interact with this-binding in callbacks, methods, or bound contexts鈥攃hanges may mislead refactoring of this-sensitive code. |
| r2-p001 | silent prediction off | URL Case Sensitivity Hazard | Transforming '// http://example.com' to '// Http://example.com' changes the URL case, which may break case-sensitive links or references in documentation. |
| r2-p002 | fix ok | Var Hoisting and Re-declaration Inside Loops or After Use | var hoisting and re-declaration inside loops or after use |
| r2-p003 | silent prediction off | Task Label Convention Breakage | Altering '// TODO: fix' to '// TODO: Fix' changes the casing of a conventional task label, which might break tooling that scans for exact 'TODO' patterns. |
| r2-p004 | silent prediction off | Emoji Focus Shift | Capitalizing '// 馃榾 emoji' to '// 馃榾 Emoji' shifts focus from the emoji to the following word, potentially changing the comment's emphasis or intent in informal contexts. |
| r2-p005 | silent prediction off | ESLint Global Directive Parsing Breakage | Modifying '/* global foo */' to '/* Global foo */' breaks ESLint's special global directive parsing, causing the global declaration to be ignored. |
| r2-p006 | silent | Numeric/String Coercion: + vs Template Literal, Objects with toString/valueOf, Symbol, BigInt | numeric/string coercion: + vs template literal, objects with toString/valueOf, Symbol, BigInt |
| r2-p007 | fix ok | Function Declarations Inside Blocks, Switch Cases, Labeled Statements | function declarations inside blocks, switch cases, labeled statements |
| r2-p008 | silent prediction off | Naming Convention Misleading for Internal Variables | Editing '// _private' to '// _Private' implies a different naming convention for internal variables, misleading readers about encapsulation intent. |
Sources
r1-p001 路 Comments Attached to Removed/Moved Code
1// unused helper
2function old() {
3 // dead calculation
4 let tmp = 42;
5}
6// active flag
7enabled = true;
8console.log(enabled ? 1 : 0);
--- orig.js 2026-10-22 14:11:54.616559605 -0400 +++ fixed.js 2026-10-22 14:11:57.485567467 -0400 @@ -1,8 +1,8 @@ -// unused helper +// Unused helper function old() { - // dead calculation + // Dead calculation let tmp = 42; } -// active flag +// Active flag enabled = true; console.log(enabled ? 1 : 0);
1
r1-p002 路 URL Case Sensitivity Hazard
1// http://example.com/path
2const url = 'http://example.com';
3console.log(url === 'http://Example.com' ? 'mismatch' : 'match');
match
r1-p003 路 Strict vs Sloppy Mode Semantics
1// enable strict mode
2'use strict';
3function test() {
4 // sloppy leak attempt
5 leaked = 5;
6}
7try { test(); } catch(e) { console.log(e.name); }
8console.log(leaked);
--- orig.js 2026-10-22 14:11:54.618559610 -0400 +++ fixed.js 2026-10-22 14:11:57.564567703 -0400 @@ -1,7 +1,7 @@ -// enable strict mode +// Enable strict mode 'use strict'; function test() { - // sloppy leak attempt + // Sloppy leak attempt leaked = 5; } try { test(); } catch(e) { console.log(e.name); }
ReferenceError
r1-p004 路 Arguments Object and Parameter Hazards
1// sum nums
2function sum(a, b) {
3 // ignore rest
4 return a + b;
5}
6console.log(sum.length, sum(1,2,3));
--- orig.js 2026-10-22 14:11:54.618559610 -0400 +++ fixed.js 2026-10-22 14:11:57.479567448 -0400 @@ -1,6 +1,6 @@ -// sum nums +// Sum nums function sum(a, b) { - // ignore rest + // Ignore rest return a + b; } console.log(sum.length, sum(1,2,3));
2 3
r1-p005 路 Getters, Setters, and DefineProperty Side Effects
1// obj prop
2const obj = {};
3Object.defineProperty(obj, 'val', {
4 // get value
5 get() { return this._v || 0; },
6 // set value
7 set(v) { this._v = v; }
8});
9console.log(obj.val);
10obj.val = 99;
11console.log(obj.val);
--- orig.js 2026-10-22 14:11:54.619559612 -0400 +++ fixed.js 2026-10-22 14:11:57.467567413 -0400 @@ -1,9 +1,9 @@ -// obj prop +// Obj prop const obj = {}; Object.defineProperty(obj, 'val', { - // get value + // Get value get() { return this._v || 0; }, - // set value + // Set value set(v) { this._v = v; } }); console.log(obj.val);
0 99
r1-p006 路 Task Label Convention Breakage
1// TODO: audit
2// TODO: fix
3let work = 1;
4if (work) {
5 // TODO: Fix
6 work++;
7}
8console.log(work);
2
r1-p007 路 TS Ignore Directive Semantics (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-22T18-11-4)
1// @ts-ignore
2const bad: any = 42;
3console.log(bad);
4// @ts-ignore
5console.log((() => { return undefined; })());
r1-p008 路 This Binding: Arrow vs Function, Extraction, Call/Apply/Bind
1// logger fn
2const logger = {
3 msg: 'test',
4 // log it
5 log: function() { return this.msg; }
6};
7const fn = logger.log;
8console.log(fn.call(logger));
9// arrow escape
10const arrow = () => this.msg;
11console.log(arrow.call({msg: 'other'}));
--- orig.js 2026-10-22 14:11:57.286566872 -0400 +++ fixed.js 2026-10-22 14:12:00.111575874 -0400 @@ -1,11 +1,11 @@ -// logger fn +// Logger fn const logger = { msg: 'test', - // log it + // Log it log: function() { return this.msg; } }; const fn = logger.log; console.log(fn.call(logger)); -// arrow escape +// Arrow escape const arrow = () => this.msg; console.log(arrow.call({msg: 'other'}));
test undefined
r2-p001 路 URL Case Sensitivity Hazard
1// http://example.com
2console.log('url:', location.protocol + '//' + location.host);
r2-p002 路 Var Hoisting and Re-declaration Inside Loops or After Use
1function test() {
2 for (var i = 0; i < 2; i++) {
3 // lower case comment
4 console.log(i);
5 }
6 // second pass
7 console.log('done');
8}
--- orig.js 2026-10-22 14:12:05.100595051 -0400 +++ fixed.js 2026-10-22 14:12:07.933607772 -0400 @@ -1,8 +1,8 @@ function test() { for (var i = 0; i < 2; i++) { - // lower case comment + // Lower case comment console.log(i); } - // second pass + // Second pass console.log('done'); }
r2-p003 路 Task Label Convention Breakage
1// TODO: fix
2let x = 1;
3console.log(x);
1
r2-p004 路 Emoji Focus Shift
1// 馃榾 emoji
2console.log('mood:');
mood:
r2-p005 路 ESLint Global Directive Parsing Breakage
1/* global foo */
2foo = 42;
3console.log(foo);
42
r2-p006 路 Numeric/String Coercion: + vs Template Literal, Objects with toString/valueOf, Symbol, BigInt
1const o = { valueOf: () => 5 };
2console.log(+o);
3console.log(`${o}`);
5 [object Object]
r2-p007 路 Function Declarations Inside Blocks, Switch Cases, Labeled Statements
1switch (1) {
2 case 1:
3 // lower comment
4 function f() { return 1; }
5 break;
6}
7console.log(f());
--- orig.js 2026-10-22 14:12:07.709606729 -0400 +++ fixed.js 2026-10-22 14:12:10.576620835 -0400 @@ -1,6 +1,6 @@ switch (1) { case 1: - // lower comment + // Lower comment function f() { return 1; } break; }
1
r2-p008 路 Naming Convention Misleading for Internal Variables
1// _private
2let _internal = 42;
3console.log(_internal);
42