Sleazy Fork is available in English.

討論 » Greasy Fork 回應

Script syntax checking

JasonBarnabe管理員
§
發表於:2019-06-29

Script syntax checking

New scripts are now checked for syntax errors and can't be posted if they contain any. This will eventually be applied to updates of existing scripts, then possibly deleting invalid scripts previously posted.

Let me know if see any problems with this.

JasonBarnabe管理員
§
發表於:2019-07-06
編輯:2019-07-06

This now applies to updates of existing scripts.

JasonBarnabe管理員
§
發表於:2019-08-02

The script syntax checker the site uses is backed by V8, and this means that syntax that may be valid in other contexts won't work. One example is E4X, specifically the use of CDATA blocks for string literals.

Any scripts using E4X features will need migrate off them going forward.

§
發表於:2019-09-04

Just curious how many scripts this affected.

This is a good way to clean out the old, obsolete scripts.

JasonBarnabe管理員
§
發表於:2019-09-07

This currently only happens on create/update. I have not yet run it on existing scripts to see how many are invalid.

JasonBarnabe管理員
§
發表於:2019-09-11

To answer your question, there are 976 (2%) that have syntax errors.

§
發表於:2019-09-19

I had a CDATA block, transpiled to babel and eval'ed to allow me to write es6 with some syntax highlighting in most editors. replaced it with a template block, works fine.

Before: https://gitlab.com/gingersareawesome/the-verge-parental-control/blob/0c10904c99bb537684e40e257df6a0beca0d2039/the-verge-parental-control.user.js After: https://gitlab.com/gingersareawesome/the-verge-parental-control/blob/master/the-verge-parental-control.user.js

§
發表於:2019-09-30

I have a script that was flagged and I don't know why ??? https://greasyfork.org/en/scripts/14238/

Right now the script is obsolete but I will update it later since I maintain it in my freetime.

So don't delete it please, why just don't flag those script and put a warning so the users would know about the bad syntax ?? This way other users could fix it of fork it without having to rewrite a whole new userscripts or it ca be used to learn too.

Regards

JasonBarnabe管理員
§
發表於:2019-10-09

If there's a syntax error, likely the script is non-functional. Continuing to list it is a detriment to the site.

In the case of that particular script, it looks like there's an extra } near the end.

JasonBarnabe管理員
§
發表於:2019-10-12

All remaining scripts with syntax errors have been deleted. Authors are free to fix and revive them if they wish.

§
發表於:2019-11-11

Tried to upload a new script today, but was disallowed due to errors; There are no errors (red) in my script. Only multiple warnings (yellow). This script has been running in multiple browsers for months with no problems.

The problems I encountered are; 1) missing semicolons. This is redundant since the code cannot be minimized or written on a single line anyway. The purpose for javascript semicolons is to separate multiple statements or declarations on a single line.

2) let declarations are not permitted. What modern browser doesn't recognize let?

Now I went ahead and added semicolons, and switched let for var, but...

3) spread syntax causes a unrecoverable syntax warning message, The message was: expected '}' but found '...' instead on line xxx The line was like: var test = {...first, ...second} first and second are both objects and the spread operator '...' merges the two.

These are not script syntax errors, they are false errors from the syntax checking parser.

Please advise.

JasonBarnabe管理員
§
發表於:2019-11-11

Can you post a link to your script so I can check it?

§
發表於:2019-11-13

@JasonBarnabe Solved https://greasyfork.org/en/scripts/392374-seenchute

Jshint is working on an option for spread constructs for the next version.

In the meantime I used the ignore start - stop options thus: From: var cfg = {...{attributes:!1, childList:!1, characterData:!1, subtree:!1}, ...config };

To: var cfg = { // jshint ignore:start ...{attributes:!1, childList:!1, characterData:!1, subtree:!1}, ...config // jshint ignore:end };

This satisfies the jshint syntax check! Thanks

§
發表於:2020-07-26

I can't post my script, due to errors: 'Code contains errors: Uncaught SyntaxError: Unexpected token ? at undefined:69:69'. I check my code in my IDE, it satisifies my syntax checker. I guess that jshint not support the newest language standard, such as 'nullish coalescing operator'. How can I post my script which is using new syntax? Maybe you can use an other syntax checker to support it?

JasonBarnabe管理員
§
發表於:2020-07-26

There was a recent update to the libraries the site uses that adds support for this. It should be good as of right now.

§
發表於:2020-07-27

Thanks JasonBarnabe I can post my code right now.

發表回覆

登入以回復