@@ -1158,6 +1158,30 @@ describe('Tests for fixes and suggestions in runRules', () => {
11581158 expect ( violation . fixes ! [ 0 ] . location . file ) . toEqual ( fixableFile ) ;
11591159 }
11601160 } ) ;
1161+
1162+ it ( 'Fix locations are correct for files with multi-byte characters' , async ( ) => {
1163+ const multibyteFile : string = path . join ( workspaceWithFixableViolations , 'fixable_multibyte.js' ) ;
1164+ const engine : Engine = await createEngineFromPlugin ( DEFAULT_CONFIG_FOR_TESTING ) ;
1165+ const runOptions : RunOptions = {
1166+ ...createRunOptions ( new Workspace ( 'id' , [ workspaceWithFixableViolations ] , [ multibyteFile ] ) ) ,
1167+ includeFixes : true
1168+ } ;
1169+ const results : EngineRunResults = await engine . runRules ( [ 'prefer-const' ] , runOptions ) ;
1170+
1171+ expect ( results . violations . length ) . toBeGreaterThanOrEqual ( 1 ) ;
1172+ const violationWithFix = results . violations . find ( v => v . fixes && v . fixes . length > 0 ) ;
1173+ expect ( violationWithFix ) . toBeDefined ( ) ;
1174+
1175+ const fix = violationWithFix ! . fixes ! [ 0 ] ;
1176+ // Fix should target line 1 (let greeting) and replace with const
1177+ expect ( fix . location . file ) . toEqual ( multibyteFile ) ;
1178+ expect ( fix . location . startLine ) . toEqual ( 1 ) ;
1179+ expect ( fix . fixedCode ) . toContain ( 'const' ) ;
1180+ // Verify the line/column values are valid positive integers
1181+ expect ( fix . location . startColumn ) . toBeGreaterThanOrEqual ( 1 ) ;
1182+ expect ( fix . location . endLine ) . toBeGreaterThanOrEqual ( 1 ) ;
1183+ expect ( fix . location . endColumn ) . toBeGreaterThanOrEqual ( 1 ) ;
1184+ } ) ;
11611185} ) ;
11621186
11631187function loadRuleDescriptions ( fileNameFromTestDataFolder : string ) : RuleDescription [ ] {
0 commit comments