sxzz / eslint-config

A opinionated ESLint config preset.
https://eslint-config.sxzz.moe
MIT License
162 stars 13 forks source link

和simple-git-hooks或者husky配合使用时,直接报错,导致代码无法提交。但是在编辑使用时没有问题 #30

Closed shunichio closed 1 year ago

shunichio commented 1 year ago

Describe the bug

lint-staged

[STARTED] Preparing lint-staged... [SUCCESS] Preparing lint-staged... [STARTED] Running tasks for staged files... [STARTED] package.json — 10 files [STARTED] .{js,jsx,ts,tsx} — 4 files [STARTED] {!(package).json,.code-snippets,.!(browserslist)rc} — 0 files [STARTED] package.json — 0 files [STARTED] .vue — 6 files [STARTED] .{scss,less,html} — 0 files [STARTED] .md — 0 files [SKIPPED] {!(package).json,.code-snippets,.!(browserslist)rc} — no files [SKIPPED] package.json — no files [SKIPPED] .{scss,less,html} — no files [SKIPPED] .md — no files [STARTED] eslint [STARTED] eslint [FAILED] eslint [FAILED] [FAILED] eslint [FAILED] [FAILED] eslint [FAILED] [STARTED] Applying modifications from tasks... [SKIPPED] Skipped because of errors from tasks. [STARTED] Reverting to original state because of errors... [FAILED] eslint [FAILED] [FAILED] eslint [FAILED] [SUCCESS] Reverting to original state because of errors... [STARTED] Cleaning up temporary files... [SUCCESS] Cleaning up temporary files...

✖ eslint:

Oops! Something went wrong! :(

ESLint: 8.48.0

D:\Code\an\portal\node_modules.pnpm\eslint-plugin-unicorn@48.0.1_eslint@8.48.0\node_modules\eslint-plugin-unicorn\rules\utils\rule.js:77 listeners[selector] ??= []; ^^^

SyntaxError: Unexpected token '??=' at wrapSafe (internal/modules/cjs/loader.js:1029:16) at Module._compile (internal/modules/cjs/loader.js:1078:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10) at Module.load (internal/modules/cjs/loader.js:979:32) at Function.Module._load (internal/modules/cjs/loader.js:819:12) at Module.require (internal/modules/cjs/loader.js:1003:19) at require (internal/modules/cjs/helpers.js:107:18) at Object. (D:\Code\an\portal\node_modules.pnpm\eslint-plugin-unicorn@48.0.1_eslint@8.48.0\node_modules\eslint-plugin-unicorn\index.js:3:21) at Module._compile (internal/modules/cjs/loader.js:1114:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

Oops! Something went wrong! :(

ESLint: 8.48.0

Reproduction

-

System Info

Windows

Used Package Manager

pnpm

Validations

sxzz commented 1 year ago

Please upgrade your node version. The requirement is Node.js >= 16.14.

See also https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v47.0.0

shunichio commented 1 year ago

Please upgrade your node version. The requirement is Node.js >= 16.14.

See also https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v47.0.0

项目使用的 pnpm 来进行包管理,也需要切换 node 版本么?

sxzz commented 1 year ago

Yes. ESLint and it's rules are running on Node.js, which requires the version.

shunichio commented 1 year ago

验证了,切换 node 版本后问题就消失了,谢谢。