From f929758bfdba0837f836352cf82a9c9bcc9195fc Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sat, 22 Jan 2022 09:42:39 -0800 Subject: [PATCH] Improve the ESLint situation --- .eslintrc.js | 45 +++++++++++++++++++++++++++++++++++++++++ .eslintrc.yml | 35 -------------------------------- src/.eslintrc.json | 1 + www/.eslintrc.json | 50 ++++++++++++++++++++++++++++++++++++++++++++++ www/js/data.js | 1 + 5 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.yml create mode 100644 src/.eslintrc.json create mode 100644 www/.eslintrc.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..73495c6d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,45 @@ +/* ESLint Config */ +module.exports = { + env: { + 'es2017': true, + // others envs defined by cascading .eslintrc files + }, + extends: 'eslint:recommended', + parser: '@babel/eslint-parser', + parserOptions: { + 'sourceType': 'module', + }, + rules: { + 'brace-style': ['error','1tbs',{ 'allowSingleLine': true }], + 'indent': [ + 'off', // temporary... a lot of stuff needs to be reformatted | 2020-08-21: I guess it's not so temporary... + 4, + { 'SwitchCase': 1 } + ], + 'linebreak-style': ['error','unix'], + 'no-control-regex': ['off'], + 'no-prototype-builtins': ['off'], // should consider cleaning up the code and turning this back on at some point + 'no-trailing-spaces': ['error'], + 'no-unused-vars': [ + 'error', { + 'argsIgnorePattern': '^_', + 'varsIgnorePattern': '^_|^Promise$' + } + ], + 'semi': ['error','always'], + 'quotes': ['off'] // Old code uses double quotes, new code uses single / template + }, + ignorePatterns: [ + // These are not ours + 'www/js/dash.all.min.js', + 'www/js/jquery-1.12.4.min.js', + 'www/js/jquery-ui.js', + 'www/js/peertube.js', + 'www/js/playerjs-0.0.12.js', + 'www/js/sc.js', + 'www/js/video.js', + 'www/js/videojs-contrib-hls.min.js', + 'www/js/videojs-dash.js', + 'www/js/videojs-resolution-switcher.js', + ], +} diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 96565757..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,35 +0,0 @@ -env: - es6: true - node: true -extends: 'eslint:recommended' -parser: '@babel/eslint-parser' -parserOptions: - sourceType: module - ecmaVersion: 2017 # For async/await -rules: - brace-style: - - error - - 1tbs - - allowSingleLine: true - indent: - - off # temporary... a lot of stuff needs to be reformatted | 2020-08-21: I guess it's not so temporary... - - 4 - - SwitchCase: 1 - linebreak-style: - - error - - unix - no-control-regex: - - off - no-prototype-builtins: - - off # should consider cleaning up the code and turning this back on at some point - no-trailing-spaces: - - error - no-unused-vars: - - error - - argsIgnorePattern: ^_ - varsIgnorePattern: ^_|^Promise$ - semi: - - error - - always - quotes: - - off # Old code uses double quotes, new code uses single / template diff --git a/src/.eslintrc.json b/src/.eslintrc.json new file mode 100644 index 00000000..e3c5b9f9 --- /dev/null +++ b/src/.eslintrc.json @@ -0,0 +1 @@ +{ "env": { "node": true } } \ No newline at end of file diff --git a/www/.eslintrc.json b/www/.eslintrc.json new file mode 100644 index 00000000..55c94902 --- /dev/null +++ b/www/.eslintrc.json @@ -0,0 +1,50 @@ +{ + "env": { "browser": true, "jquery": true }, + "globals": { + "CHANNEL": "writable", + "CHANNELNAME": "writable", + "CHATHIST": "writable", + "CHATHISTIDX": "writable", + "CHATSOUND": "writable", + "CHATTHROTTLE": "writable", + "CLIENT": "writable", + "CSEMOTELIST": "writable", + "DEFAULT_THEME": "writable", + "EMOTELIST": "writable", + "EMOTELISTMODAL": "writable", + "FILTER_FROM": "writable", + "FILTER_TO": "writable", + "FOCUSED": "writable", + "GS_VERSION": "writable", + "HAS_CONNECTED_BEFORE": "writable", + "IGNORE_SCROLL_EVENT": "writable", + "IGNORED": "writable", + "IMAGE_MATCH": "writable", + "JSPREF": "writable", + "KICKED": "writable", + "LASTCHAT": "writable", + "LEADTMR": "writable", + "PAGETITLE": "writable", + "PL_ACTION_QUEUE": "writable", + "PL_AFTER": "writable", + "PL_CURRENT": "writable", + "PL_FROM": "writable", + "PL_QUEUED_ACTIONS": "writable", + "PL_WAIT_SCROLL": "writable", + "PLAYER": "writable", + "REBUILDING": "writable", + "SCROLLCHAT": "writable", + "SOCKETIO_CONNECT_ERROR_COUNT": "writable", + "SUPERADMIN": "writable", + "TITLE_BLINK": "writable", + "USEROPTS": "writable", + "VHEIGHT": "writable", + "VOLUME": "writable", + "VWIDTH": "writable", + "CyTube": "writable", + "Rank": "writable", + "getOpt": "writable", + "setOpt": "writable", + "socket": "writable" + } +} diff --git a/www/js/data.js b/www/js/data.js index 37306322..1dded2d3 100644 --- a/www/js/data.js +++ b/www/js/data.js @@ -1,3 +1,4 @@ +/*eslint no-unused-vars: "off"*/ var CL_VERSION = 3.0; var GS_VERSION = 1.7; // Google Drive Userscript