Context. Observations have shown that the effective temperature of hydrogen-free Wolf-Rayet (WR) stars is considerably lower than that of the standard model, which means that the radius of the observed H-free WR stars is several times larger than that estimated by the standard model. The envelope inflation structure (EIS) caused by the radiation luminosity being close to the Eddington luminosity in the iron opacity peak region of H-free WR stars may be the key to resolving the radius problem of H-free WR stars. Aims. We study the structure and evolution of helium (He) stars with the EIS and discuss the influence of rotation on these He stars. We aim to explain the radius problem of H-free WR stars observed in the Milky Way (MW) and the Large Magellanic Cloud (LMC) through the He stars. Methods. Using the Modules for Experiments in Stellar Astrophysics code, we compute the evolution of He stars with and without MLT++ prescriptions, and discuss their effects on the EIS. We calculated the evolution of He stars using a new mass-loss rate formula and three different relative rotational velocities and compared our results with observations on Hertzsprung–Russell diagrams. Results. The EIS has different effects on the structure and evolution of He stars with different masses. Due to the luminosity well below the Eddington limit, low-mass He stars with an initial mass of less than 12 M⊙ do not produce EIS with or without the MLT++ prescription. High-mass He stars with an initial mass exceeding 12 M⊙ and without the MLT++ prescription produce the EIS. Since the EIS is Eddington factor Γ-dependent, its radius increases with the increase in metallicity and decreases with rotational velocity increase. For rotating low-mass He stars, since the rotational mixing timescale is smaller than the evolutionary timescale, rotational mixing can increase the lifetime and allow He stars to evolve into WC stars during the helium giant phase. For rotating high-mass He stars, since rotation increases the mass-loss rate, the radius of the EIS decreases as rotational velocity increases. The rotation-decay timescale of rapidly rotating He stars is very short, and the rapidly rotating He stars only appear within the first one-tenth of their lifetime, which is consistent with the observations of WR stars. Conclusions. The low-luminosity (log(L/L⊙)≤5.2) H-free WR stars in the MW and the LMC can be explained by the helium giant phase in low-mass He stars, the high XC and XO in WC stars can only evolve through low-mass He stars with a rapid rotation. High-mass He stars with the EIS can explain H-free WR stars with a luminosity exceeding 105.7 L⊙ and an effective temperature above 104.7 K in the MW. They can also explain H-free WR stars on the right-hand side of the He zero-age main sequence in the LMC. High-mass stars with the EIS evolve into WO stars at the final evolution stage, and the shorter lifetime fraction is consistent with the small number of observed WO stars.