File tree Expand file tree Collapse file tree
fixtures/jest_and_vitest_alias_rules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "plugins" : [" jest" ],
3+ "categories" : {
4+ "correctness" : " off"
5+ },
6+ "rules" : {
7+ "jest/no-identical-title" : " error"
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ {
2+ "plugins" : [" vitest" ],
3+ "categories" : {
4+ "correctness" : " off"
5+ },
6+ "rules" : {
7+ "vitest/no-identical-title" : " error"
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ describe ( "foo" , ( ) => {
2+ it ( "works" , ( ) => { } ) ;
3+ it ( "works" , ( ) => { } ) ;
4+ } ) ;
Original file line number Diff line number Diff line change @@ -796,4 +796,27 @@ mod test {
796796 assert_eq ! ( result. number_of_warnings, 0 ) ;
797797 assert_eq ! ( result. number_of_errors, 0 ) ;
798798 }
799+
800+ #[ test]
801+ fn test_jest_and_vitest_alias_rules ( ) {
802+ let args = & [
803+ "-c" ,
804+ "fixtures/jest_and_vitest_alias_rules/oxlint-jest.json" ,
805+ "fixtures/jest_and_vitest_alias_rules/test.js" ,
806+ ] ;
807+ let result = test ( args) ;
808+ assert_eq ! ( result. number_of_files, 1 ) ;
809+ assert_eq ! ( result. number_of_warnings, 0 ) ;
810+ assert_eq ! ( result. number_of_errors, 1 ) ;
811+
812+ let args = & [
813+ "-c" ,
814+ "fixtures/jest_and_vitest_alias_rules/oxlint-vitest.json" ,
815+ "fixtures/jest_and_vitest_alias_rules/test.js" ,
816+ ] ;
817+ let result = test ( args) ;
818+ assert_eq ! ( result. number_of_files, 1 ) ;
819+ assert_eq ! ( result. number_of_warnings, 0 ) ;
820+ assert_eq ! ( result. number_of_errors, 1 ) ;
821+ }
799822}
Original file line number Diff line number Diff line change @@ -421,9 +421,16 @@ impl RulesCache {
421421 let mut all_rules: Vec < _ > = if self . plugins . is_all ( ) {
422422 RULES . clone ( )
423423 } else {
424+ let mut plugins = self . plugins ;
425+
426+ // we need to include some jest rules when vitest is enabled, see [`VITEST_COMPATIBLE_JEST_RULES`]
427+ if plugins. contains ( LintPlugins :: VITEST ) {
428+ plugins = plugins. union ( LintPlugins :: JEST ) ;
429+ }
430+
424431 RULES
425432 . iter ( )
426- . filter ( |rule| self . plugins . contains ( LintPlugins :: from ( rule. plugin_name ( ) ) ) )
433+ . filter ( |rule| plugins. contains ( LintPlugins :: from ( rule. plugin_name ( ) ) ) )
427434 . cloned ( )
428435 . collect ( )
429436 } ;
You can’t perform that action at this time.
0 commit comments