Merhaba, Yabancı!

Burada yeni gibi görünüyorsunuz. Eğer katılmak istiyorsanız düğmelerden birine tıklayınız.

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.

Yorumlar

  • July 6 düzenlendi [?]

    This now applies to updates of existing scripts.

  • 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.

  • Just curious how many scripts this affected.

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

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

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

  • 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

  • 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

  • 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.

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

  • 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.

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

  • @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

Yorum yapmak içinOturum Açın yada Kayıt Olun .