@@ -798,6 +798,32 @@ describe("cli", () => {
798798 assert . strictEqual ( exit , 0 ) ;
799799 } ) ;
800800
801+ it ( `should interpret pattern that contains a slash as relative to cwd with configType:${ configType } ` , async ( ) => {
802+ process . cwd = ( ) => getFixturePath ( "cli/ignore-pattern-relative/subdir" ) ;
803+
804+ /*
805+ * The config file is in `cli/ignore-pattern-relative`, so this would fail
806+ * if `subdir/**` ignore pattern is interpreted as relative to the config base path.
807+ */
808+ const exit = await cli . execute ( "**/*.js --ignore-pattern subdir/**" , null , useFlatConfig ) ;
809+
810+ assert . strictEqual ( exit , 0 ) ;
811+
812+ await stdAssert . rejects (
813+ async ( ) => await cli . execute ( "**/*.js --ignore-pattern subsubdir/*.js" , null , useFlatConfig ) ,
814+ / A l l f i l e s m a t c h e d b y ' \* \* \/ \* \. j s ' a r e i g n o r e d / u
815+ ) ;
816+ } ) ;
817+
818+ it ( `should interpret pattern that doesn't contain a slash as relative to cwd with configType:${ configType } ` , async ( ) => {
819+ process . cwd = ( ) => getFixturePath ( "cli/ignore-pattern-relative/subdir/subsubdir" ) ;
820+
821+ await stdAssert . rejects (
822+ async ( ) => await cli . execute ( "**/*.js --ignore-pattern *.js" , null , useFlatConfig ) ,
823+ / A l l f i l e s m a t c h e d b y ' \* \* \/ \* \. j s ' a r e i g n o r e d / u
824+ ) ;
825+ } ) ;
826+
801827 if ( useFlatConfig ) {
802828 it ( "should ignore files if the pattern is a path to a directory (with trailing slash)" , async ( ) => {
803829 const filePath = getFixturePath ( "cli/syntax-error.js" ) ;
0 commit comments