@@ -39,7 +39,7 @@ const SAMPLE_CUSTOM_RULES: RegexRules = {
3939 NoTalkingAboutFightClub : {
4040 regex : '/fight club/gi' ,
4141 description : "The first rule of Fight Club is do not talk about Fight Club" ,
42- file_extensions : [ ".abc-def.xyz" ] ,
42+ file_extensions : [ ".abc-def.xyz" , ".lf.cls" ] ,
4343 violation_message : "The second rule of Fight Club is DO NOT. TALK. ABOUT FIGHT CLUB." ,
4444 severity : DEFAULT_SEVERITY_LEVEL ,
4545 tags : [ 'PopCulture' ]
@@ -783,6 +783,34 @@ describe('Tests for runRules', () => {
783783 }
784784 } ) ;
785785
786+ it ( 'When workspace contains files that use \\n instead of \\r\\n, violations are right regardless of OS' , async ( ) => {
787+ const runOptions : RunOptions = createRunOptions (
788+ new Workspace ( 'id' , [ path . resolve ( __dirname , "test-data" , "workspaceWithLfNewlines" ) ] ) ) ;
789+ const runResults : EngineRunResults = await engine . runRules ( [ 'NoTalkingAboutFightClub' ] , runOptions ) ;
790+
791+ const expectedViolations : Violation [ ] = [
792+ {
793+ ruleName : "NoTalkingAboutFightClub" ,
794+ message : "The second rule of Fight Club is DO NOT. TALK. ABOUT FIGHT CLUB." ,
795+ primaryLocationIndex : 0 ,
796+ codeLocations : [
797+ {
798+ file : path . resolve ( __dirname , "test-data" , "workspaceWithLfNewlines" , "testClass.lf.cls" ) ,
799+ startLine : 3 ,
800+ startColumn : 87 ,
801+ endLine : 3 ,
802+ endColumn : 97
803+ }
804+ ]
805+ }
806+ ] ;
807+
808+ expect ( runResults . violations ) . toHaveLength ( expectedViolations . length ) ;
809+ for ( const expectedViolation of expectedViolations ) {
810+ expect ( runResults . violations ) . toContainEqual ( expectedViolation ) ;
811+ }
812+ } ) ;
813+
786814 it ( "When running all rules compared to some rules, then output correctly returns what the correct violations according to specified rules" , async ( ) => {
787815 const runOptions : RunOptions = createRunOptions (
788816 new Workspace ( 'id' , [ path . resolve ( __dirname , "test-data" , "sampleWorkspace" ) ] ) ) ;
0 commit comments