Skip to content

调整 eslint-plugin-userscripts 规则#1510

Open
cyfung1031 wants to merge 2 commits into
mainfrom
pr/disable-use-homepage-and-url
Open

调整 eslint-plugin-userscripts 规则#1510
cyfung1031 wants to merge 2 commits into
mainfrom
pr/disable-use-homepage-and-url

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

Description / 描述

https://yash-singh1.github.io/eslint-plugin-userscripts/#/rules/use-homepage-and-url

Screenshot 2026-06-15 at 12 56 22 Screenshot 2026-06-15 at 12 56 37

这里指的应该是 greasemonkey 只支持 @homepageURL 不支持 @homepage ?
我在网上也查不到什么相关资料

我理解是某些网站不支持 @homepage 例如 OpenUserJs.org
https://sourceforge.net/p/greasemonkey/wiki/Metadata_Block/#homepageurl

但TM早已定明 @homepage, @homepageURL, @website, @source 没有分别
https://www.tampermonkey.net/documentation.php?locale=en&q=homepage

所以 ScriptCat 根本不需要理会这个

Screenshots / 截图

@cyfung1031 cyfung1031 marked this pull request as draft June 15, 2026 02:50
@cyfung1031 cyfung1031 marked this pull request as ready for review June 15, 2026 03:57
@cyfung1031

Copy link
Copy Markdown
Collaborator Author

AI Suggestions

My recommendation for ScriptCat default:

// ScriptCat-friendly overrides
"userscripts/align-attributes": ["warn", 2],
"userscripts/use-homepage-and-url": ["off"],
"userscripts/require-download-url": ["off"],

// Recommended additional defaults:
"userscripts/filename-user": ["off"],
"userscripts/better-use-match": ["off"],
"userscripts/require-description": ["off"],
"userscripts/metadata-spacing": ["warn"],
"userscripts/require-attribute-space-prefix": ["warn"],

// Keep strict:
"userscripts/no-invalid-grant": ["error"],
"userscripts/no-invalid-headers": ["error"],
"userscripts/no-invalid-metadata": ["error"],
"userscripts/require-name": ["error"],
"userscripts/require-version": ["error"],

// Keep off unless ScriptCat provides target-runner settings:
"userscripts/compat-grant": ["off"],
"userscripts/compat-headers": ["off"],

The most important change from your current config is: turn require-download-url fully off, not warn. In ScriptCat, users often create local/private scripts, paste scripts manually, or use scripts without update infrastructure. Requiring @downloadURL is useful for distribution platforms, but noisy inside a userscript manager/editor.

I would disable these by default:

Rule Default Why
userscripts/filename-user off ScriptCat edits database/internal scripts, not necessarily physical *.user.js files.
userscripts/use-homepage-and-url off You already did this; requiring both @homepage and @homepageURL is distribution-style hygiene, not runtime safety.
userscripts/require-download-url off Too noisy for local/pasted/private scripts. The plugin says this is about pairing update/download metadata, but many ScriptCat scripts do not need that. (GitHub)
userscripts/better-use-match off @match is cleaner, but many real-world userscripts still use @include, regex-style URLs, or legacy patterns. This should be advice, not default lint pressure.
userscripts/require-description off or warn Nice for publishing, not required for execution. I prefer off for editor defaults.
userscripts/compat-grant off Not recommended by the plugin by default, and only safe if ScriptCat configures supported userscript-runner versions.
userscripts/compat-headers off Same reason as compat-grant.

I would not disable these:

Rule Keep Why
userscripts/no-invalid-grant error Catches typo bugs that become GM_* is not defined; the plugin docs explicitly frame it this way. (GitHub)
userscripts/no-invalid-headers error Header typos can silently change behavior.
userscripts/no-invalid-metadata error Metadata parsing is core to userscript behavior; the rule validates metadata structure. (GitHub)
userscripts/require-name error ScriptCat needs a display name.
userscripts/require-version error or warn Useful for update/change tracking; I’d keep error if ScriptCat relies on versioning, otherwise warn.

For style-only rules, I’d downgrade rather than disable:

"userscripts/align-attributes": ["warn", 2],
"userscripts/metadata-spacing": ["warn"],
"userscripts/require-attribute-space-prefix": ["warn"],

Final suggested block:

// -- ScriptCat overrides --

"userscripts/align-attributes": ["warn", 2],

"userscripts/filename-user": ["off"],
"userscripts/use-homepage-and-url": ["off"],
"userscripts/require-download-url": ["off"],
"userscripts/better-use-match": ["off"],
"userscripts/require-description": ["off"],

"userscripts/metadata-spacing": ["warn"],
"userscripts/require-attribute-space-prefix": ["warn"],

"userscripts/no-invalid-grant": ["error"],
"userscripts/no-invalid-headers": ["error"],
"userscripts/no-invalid-metadata": ["error"],
"userscripts/require-name": ["error"],
"userscripts/require-version": ["error"],

"userscripts/compat-grant": ["off"],
"userscripts/compat-headers": ["off"],

This gives ScriptCat a good default balance: catch metadata/runtime mistakes, avoid forcing publishing conventions on normal users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant