@@ -499,16 +499,31 @@ describe('Typical tests for the runRules method of ESLintEngine', () => {
499499 "primaryLocationIndex" : 0 ,
500500 "ruleName" : "@typescript-eslint/no-wrapper-object-types"
501501 } ;
502+ const expectedHTMLViolation_enforceBemUsage : Violation = {
503+ "codeLocations" : [
504+ {
505+ "endColumn" : 27 ,
506+ "endLine" : 1 ,
507+ "file" : path . join ( workspaceWithNoCustomConfig , 'dummy1.html' ) ,
508+ "startColumn" : 11 ,
509+ "startLine" : 1
510+ }
511+ ] ,
512+ "message" : "slds-m-top--none has been retired. Update it to the new name slds-m-top_none." ,
513+ "primaryLocationIndex" : 0 ,
514+ "ruleName" : "@salesforce-ux/slds/enforce-bem-usage"
515+ } ;
502516
503- it ( 'When running with defaults and no customizations, then violations for javascript and typescript are found correctly' , async ( ) => {
517+ it ( 'When running with defaults and no customizations, then violations for javascript, typescript and html are found correctly' , async ( ) => {
504518 const engine : Engine = await createEngineFromPlugin ( DEFAULT_CONFIG_FOR_TESTING ) ;
505519 const runOptions : RunOptions = createRunOptions ( new Workspace ( 'id' , [ workspaceWithNoCustomConfig ] ) ) ;
506- const results : EngineRunResults = await engine . runRules ( [ 'no-invalid-regexp' , '@typescript-eslint/no-wrapper-object-types' ] , runOptions ) ;
520+ const results : EngineRunResults = await engine . runRules ( [ 'no-invalid-regexp' , '@typescript-eslint/no-wrapper-object-types' , '@salesforce-ux/slds/enforce-bem-usage' ] , runOptions ) ;
507521
508- expect ( results . violations ) . toHaveLength ( 3 ) ;
522+ expect ( results . violations ) . toHaveLength ( 4 ) ;
509523 expect ( results . violations ) . toContainEqual ( expectedJsViolation_noInvalidRegexp ) ;
510524 expect ( results . violations ) . toContainEqual ( expectedTsViolation_noInvalidRegexp ) ;
511525 expect ( results . violations ) . toContainEqual ( expectedTsViolation_noWrapperObjectTypes ) ;
526+ expect ( results . violations ) . toContainEqual ( expectedHTMLViolation_enforceBemUsage ) ;
512527 } ) ;
513528
514529 it ( 'When workspace only targets javascript files, then only javascript violations are returned' , async ( ) => {
@@ -528,7 +543,15 @@ describe('Typical tests for the runRules method of ESLintEngine', () => {
528543 expect ( results . violations ) . toEqual ( [ expectedTsViolation_noInvalidRegexp ] ) ;
529544 } ) ;
530545
531- it ( 'When workspace does not contains javascript or typescript files, then zero violations are returned' , async ( ) => {
546+ it ( 'When workspace only contains html files, then only html violations are returned' , async ( ) => {
547+ const engine : Engine = await createEngineFromPlugin ( DEFAULT_CONFIG_FOR_TESTING ) ;
548+ const runOptions : RunOptions = createRunOptions ( new Workspace ( 'id' , [ path . join ( workspaceWithNoCustomConfig , 'dummy1.html' ) ] ) ) ;
549+ const results : EngineRunResults = await engine . runRules ( [ '@salesforce-ux/slds/enforce-bem-usage' ] , runOptions ) ;
550+
551+ expect ( results . violations ) . toEqual ( [ expectedHTMLViolation_enforceBemUsage ] ) ;
552+ } ) ;
553+
554+ it ( 'When workspace does not contains javascript, typescript or html files, then zero violations are returned' , async ( ) => {
532555 const engine : Engine = await createEngineFromPlugin ( DEFAULT_CONFIG_FOR_TESTING ) ;
533556 const runOptions : RunOptions = createRunOptions ( new Workspace ( 'id' , [ path . join ( workspaceWithNoCustomConfig , 'dummy3.txt' ) ] ) ) ;
534557 const results : EngineRunResults = await engine . runRules ( [ 'no-invalid-regexp' ] , runOptions ) ;
@@ -587,7 +610,7 @@ describe('Typical tests for the runRules method of ESLintEngine', () => {
587610 } ) ;
588611
589612
590- it ( 'When custom rules only apply to file extensions that are not javascript or typescript based, then when specifying file extensions, the rules run' , async ( ) => {
613+ it ( 'When custom rules only apply to file extensions that are not javascript, typescript, or html based, then when specifying file extensions, the rules run' , async ( ) => {
591614 const engine : Engine = await createEngineFromPlugin ( { ...DEFAULT_CONFIG_FOR_TESTING ,
592615 eslint_config_file : path . join ( workspaceThatHasCustomConfigWithNewRules , 'eslint-config-only-for-other-files.js' ) ,
593616 file_extensions :{
@@ -622,7 +645,7 @@ describe('Typical tests for the runRules method of ESLintEngine', () => {
622645 engine . onEvent ( EventType . LogEvent , ( event : LogEvent ) => logEvents . push ( event ) ) ;
623646
624647 const runOptions : RunOptions = createRunOptions ( new Workspace ( 'id' , [ path . join ( testDataFolder , 'workspaceWithFlatConfigJs' ) ] ) ) ;
625- const results : EngineRunResults = await engine . runRules ( [ 'no-invalid-regexp' , '@typescript-eslint/no-wrapper-object-types' ] , runOptions ) ;
648+ const results : EngineRunResults = await engine . runRules ( [ 'no-invalid-regexp' , '@typescript-eslint/no-wrapper-object-types' , '@salesforce-ux/slds/enforce-bem-usage' ] , runOptions ) ;
626649
627650 expect ( results . violations ) . toHaveLength ( 2 ) ; // Should not contain js violations but should contain ts violations
628651 expect ( path . extname ( results . violations [ 0 ] . codeLocations [ 0 ] . file ) ) . toEqual ( '.ts' ) ;
0 commit comments