Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.18k stars 417 forks source link

FR: For eslint, allow Custom Linter Config to expand/override current config, display the current eslint config, and/or document the eslint config used by Tampermonkey #1686

Open makyen opened 1 year ago

makyen commented 1 year ago

I want to use a Custom Linter Config that's a slight modification of the default (or currently used) eslint config for Tampermonkey, but need either:

  1. to know the full, current config (including any changes caused by Tampermonkey Editor Settings UI selections and Tampermonkey version updates), so I can manually copy it and modify it, or
  2. have a Custom Linter Config entry which automatically applies additional/changed configuration settings, rather than fully replacing the entirety of the default settings.

One possibility would be to enable modifying, rather than replacing, the default Tampermonkey config though a specific value for the eslint extends property. However, using extends might end up being difficult in the browser extension environment without explicitly writing support for it.

In general, I want to use the default configuration for eslint within Tampermonkey. I write userscripts for use by other people and would prefer to have the userscripts end up with no warnings or errors when other people use the Tampermonkey editor to edit the script using the default settings. However, for some testing, I want to use a slightly modified eslint configuration in Tampermonkey. I would prefer to be able to do this without needing to use inline eslint config directives within the userscript itself, because I would like at least some of the modifications to be global to all userscripts. In the past, I have used inline eslint config within each script to solve this issue, but that's a bit clunky, as test configs need to be removed prior to releasing the userscript, such inline configuration has to be added to each userscript, and using inline eslint configs currently has an Issue, #1685, which makes it non-functional.

Ideally, it would also be possible to set updated eslint configuration settings on a per-userscript basis (i.e. applied in the userscript's Settings tab) in addition to what could be set in Tampermonkey's Settings tab for all userscripts.

derjanb commented 1 year ago

FYI:


{
    "env": {
        "es6": true,
        "browser": true
    },
    "parserOptions": {
        "ecmaVersion": 2022,
        "sourceType": "script",
        "ecmaFeatures": {
            "globalReturn": true
        },
        "allowAwaitOutsideFunction": true
    },
    "rules": {
        "userscripts/no-invalid-grant": 1,
        "userscripts/no-invalid-headers": 1,
        "userscripts/no-invalid-metadata": [
            2,
            {
                "top": "optional"
            }
        ],
        "userscripts/require-name": [
            2,
            "required"
        ],
        "userscripts/require-description": [
            1,
            "required"
        ],
        "userscripts/require-version": [
            1,
            "required"
        ],
        "userscripts/require-attribute-space-prefix": 1,
        "userscripts/use-homepage-and-url": 0,
        "userscripts/use-download-and-update-url": 1,
        "userscripts/better-use-match": 1,
        "curly": [
            1,
            "multi-line"
        ],
        "dot-location": 0,
        "dot-notation": [
            1,
            {
                "allowKeywords": true
            }
        ],
        "no-caller": 1,
        "no-case-declarations": 2,
        "no-div-regex": 0,
        "no-empty-pattern": 2,
        "no-eq-null": 0,
        "no-eval": 1,
        "no-extra-bind": 1,
        "no-fallthrough": 1,
        "no-implicit-globals": 2,
        "no-implied-eval": 1,
        "no-lone-blocks": 1,
        "no-loop-func": 1,
        "no-multi-spaces": 1,
        "no-multi-str": 1,
        "no-native-reassign": 1,
        "no-octal-escape": 2,
        "no-octal": 2,
        "no-proto": 1,
        "no-redeclare": 2,
        "no-return-assign": 1,
        "no-sequences": 1,
        "no-undef": 1,
        "no-useless-call": 1,
        "no-useless-concat": 1,
        "no-with": 1
    },
    "globals": {
        "uneval": "writeable",
        "unsafeWindow": "writeable",
        "GM_info": "writeable",
        "GM": "writeable",
        "GM_addStyle": "writeable",
        "GM_addElement": "writeable",
        "GM_cookie": "writeable",
        "GM_deleteValue": "writeable",
        "GM_listValues": "writeable",
        "GM_getValue": "writeable",
        "GM_download": "writeable",
        "GM_log": "writeable",
        "GM_registerMenuCommand": "writeable",
        "GM_unregisterMenuCommand": "writeable",
        "GM_openInTab": "writeable",
        "GM_setValue": "writeable",
        "GM_addValueChangeListener": "writeable",
        "GM_removeValueChangeListener": "writeable",
        "GM_xmlhttpRequest": "writeable",
        "GM_webRequest": "writeable",
        "GM_getTab": "writeable",
        "GM_saveTab": "writeable",
        "GM_getTabs": "writeable",
        "GM_setClipboard": "writeable",
        "GM_notification": "writeable",
        "GM_getResourceText": "writeable",
        "GM_getResourceURL": "writeable"
    }
}

Note: ecmaVersion is dynamically determined.