The directors of the National Basketball Association and Major League Baseball players associations were pleased yesterday about a federal judge's ruling Monday that could strike down the National Hockey League's compensation clause in free-agent signings.

Larry Fleischer, director of the NBA Players Association, said the ruling, if upheld in a trial, could hasten implementation of an agreement that would ban compensation in NBA free-agent signings. The agreement is scheduled to go into effect in two years.

Marvin Miller, executive director of the Major League Baseball Players Association, said a favorable outcome in the hockey case would benefit his union when it negotiates a new contract with the owners in 1980.

Baseball teams, as a result of the Andy Messersmith ruling, give up choices in the amateur draft as compensation for signing free agents. Miller said that he expects baseball owners to make a major point of free-agent compensation in negotiations for a new collective bargaining agreement.

In the hockey case, Dale McCourt obtained a temporary restraining order Monday allowing him to report to the Detroit Red Wings. He had been assigned to the Los Angeles Kings as compensation determined by an arbiter after the Red Wings signed goalkeeper Rogie Vachon, whose contract had expired at Los Angeles.

U.S. District Court Judge Robert DeMascio ruled that the NHL compensation clause was a restraint of trade violating antitrust laws because it was made arbitrarily by the NHL and was not the result of a collective bargaining agreement.

"If you're asking is 9A (the compensation clause) invalid, I'm not saying so yet," said Allan Eagleson, executive director of the NHLPA. "The ruling makes it more reasonable to assume McCourt will win the lawsuit and no particular damage will be done to Los Angeles if we wait for the trial."

Eagleson said yesterday that the case could go to court as soon as early next month. No date has been set, however.

What differs between the NHL case and the other three major professional sports is that the current compensation clauses in those sports were determined by collective bargaining, either in new contracts or in settlement of lawsuits.

In his ruling, Judge DeMascio said that the NHL's compensation policy was imposed by the league and was not arrived at through collective bargaining. Eagleson said the owners passed the bylaw in 1974 and said it was "not open for discussion."

Eagleson said the NHLPA has proposed compensation clauses to the owners based along the lines of those currently in effect in the landmark agreement two years ago between the National Football League and the NFLPA.

In that contract, a formula has been worked out so that club losing free agents are compensated by draft choices, depending on the free agent's salary.

In two years, the NBAPA will have the best free-agent compensation system as far as the players are concerned. Under settlement of the Robertson vs. NBA case that allowed the NBA and ABA to merge, player compensation is allowed now, but starting in 1980, teams losing a free agent will have only right of first refusal to match any other team's offer.

"It's always been our thought that compensation was lousy, and that's why we sued in the past," said Fleischer. "But we didn't want to stay in the courts forever, so that's why we agreed to what we did in the Robertson case.

"We have two more years to live with those things. Maybe now Commissioner (Lawrence) O'Brien will realize the whole system is wrong and something will come out of it . . . What would become effective in two years could become effective immediately."