diff --git a/src/Config.php b/src/Config.php index 7c5ba06..af8bbc9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -7,6 +7,7 @@ use Closure; use Peck\Support\PresetProvider; use Peck\Support\ProjectPath; +use Peck\Support\SpellcheckFormatter; final class Config { @@ -151,6 +152,7 @@ public function isWordIgnored(string $word): bool return in_array(strtolower($word), [ ...$this->whitelistedWords, ...PresetProvider::whitelistedWords($this->preset), + ...$this->ignoreWordsFromProjectPath(), ]); } @@ -169,4 +171,16 @@ private function persist(): void ], ], JSON_PRETTY_PRINT)); } + + /** + * Ignore words from the project path including $HOME directory. Prevents spell check errors for cache constant + * + * @return list + */ + private function ignoreWordsFromProjectPath(): array + { + $directories = explode(DIRECTORY_SEPARATOR, ProjectPath::get()); + + return array_map(fn ($directory): string => SpellcheckFormatter::format($directory), array_filter($directories)); + } } diff --git a/src/Plugins/Cache.php b/src/Plugins/Cache.php index 593865e..e19f357 100644 --- a/src/Plugins/Cache.php +++ b/src/Plugins/Cache.php @@ -4,6 +4,7 @@ namespace Peck\Plugins; +use Peck\Support\ProjectPath; use RuntimeException; final readonly class Cache @@ -27,7 +28,7 @@ public function __construct( */ public static function default(): self { - $basePath = __DIR__.'/../../'; + $basePath = ProjectPath::get(); $cache = new self("{$basePath}/.peck.cache");