如果我从项目根目录运行
eslint .
,它会将所有错误和警告打印到控制台,正如我所期望的那样。
但是,当我
cd
进入项目的子目录时,eslint .
会产生以下错误消息:
<--- Last few GCs --->
[10574:0x4e6ca40] 72313 ms: Mark-sweep (reduce) 4073.6 (4143.3) -> 4073.0 (4143.8) MB, 3637.8 / 0.0 ms (average mu = 0.082, current mu = 0.001) allocation failure scavenge might not succeed
[10574:0x4e6ca40] 75948 ms: Mark-sweep (reduce) 4074.1 (4143.8) -> 4073.0 (4144.1) MB, 3630.7 / 0.0 ms (average mu = 0.043, current mu = 0.001) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0xb12b00 node::Abort() [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
2: 0xa2fe25 node::FatalError(char const*, char const*) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
3: 0xcf8a9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
4: 0xcf8e17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
5: 0xee2d65 [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
6: 0xef1ae1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
7: 0xef4d3c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
8: 0xec12eb v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
9: 0x122acab v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
10: 0x160c479 [/home/tim/.nvm/versions/node/v16.0.0/bin/node]
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
eslint 文档指出,
.eslintrc.js
适用于它所在的目录以及所有子目录。所以它应该使用相同的配置文件。
当它不必搜索整个项目时,理论上它不应该发现更少的警告吗?因此,我希望 eslint 也能使用更少的内存。
eslint 版本是
v7.26.0
。