From 13f4c62ba3870f172e6fdb26d4f33576f7f60f7e Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 17 May 2023 13:23:01 +0300 Subject: Add basic ESLint configuration for formatting This doesn't enable any of ESLint's actual possible-issue linting, but just style normalization based on the Prettier configuration (but without line length limits). --- .eslintrc.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .eslintrc.js (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..48f9df7d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,49 @@ +module.exports = { + env: { + browser: true, + es2021: true, + }, + // "extends": "eslint:recommended", + parserOptions: { + ecmaVersion: "latest", + }, + rules: { + "arrow-spacing": "error", + "block-spacing": "error", + "brace-style": "error", + "comma-dangle": ["error", "only-multiline"], + "comma-spacing": "error", + "comma-style": ["error", "last"], + "curly": ["error", "multi-line", "consistent"], + "eol-last": "error", + "func-call-spacing": "error", + "function-call-argument-newline": ["error", "consistent"], + "function-paren-newline": ["error", "consistent"], + "indent": ["error", 4], + "key-spacing": "error", + "keyword-spacing": "error", + "linebreak-style": ["error", "unix"], + "no-extra-semi": "error", + "no-mixed-spaces-and-tabs": "error", + "no-trailing-spaces": "error", + "no-whitespace-before-property": "error", + "object-curly-newline": ["error", {consistent: true, multiline: true}], + "quote-props": ["error", "consistent-as-needed"], + "semi": ["error", "always"], + "semi-spacing": "error", + "semi-style": ["error", "last"], + "space-before-blocks": "error", + "space-before-function-paren": ["error", "never"], + "space-in-parens": ["error", "never"], + "space-infix-ops": "error", + "space-unary-ops": "error", + "switch-colon-spacing": "error", + "template-curly-spacing": ["error", "never"], + "unicode-bom": "error", + // "no-multi-spaces": "error", // TODO: enable? + // "object-curly-spacing": "off", // TODO: enable? + // "object-property-newline": "off", // TODO: enable? + // "operator-linebreak": "off", // TODO: enable? + // "quotes": ["error", "double", {avoidEscape: true}], // TODO: enable? + }, +}; -- cgit v1.2.3 From f88169a9e74066892221b6c8c74c85afb7c1fe57 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 18 May 2023 09:58:49 +0300 Subject: extend eslint config --- .eslintrc.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index 48f9df7d..78275554 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,7 @@ module.exports = { browser: true, es2021: true, }, - // "extends": "eslint:recommended", + extends: "eslint:recommended", parserOptions: { ecmaVersion: "latest", }, @@ -40,10 +40,50 @@ module.exports = { "switch-colon-spacing": "error", "template-curly-spacing": ["error", "never"], "unicode-bom": "error", - // "no-multi-spaces": "error", // TODO: enable? - // "object-curly-spacing": "off", // TODO: enable? - // "object-property-newline": "off", // TODO: enable? - // "operator-linebreak": "off", // TODO: enable? - // "quotes": ["error", "double", {avoidEscape: true}], // TODO: enable? + "no-multi-spaces": "error", + "object-curly-spacing": ["error", "never"], + "operator-linebreak": ["error", "after"], + "no-unused-vars": "off", + "no-redeclare": "off", }, + globals: { + // this file + module: "writable", + //script.js + gradioApp: "writable", + onUiLoaded: "writable", + onUiUpdate: "writable", + onOptionsChanged: "writable", + uiCurrentTab: "writable", + uiElementIsVisible: "writable", + executeCallbacks: "writable", + //ui.js + opts: "writable", + all_gallery_buttons: "writable", + selected_gallery_button: "writable", + selected_gallery_index: "writable", + args_to_array: "writable", + switch_to_txt2img: "writable", + switch_to_img2img_tab: "writable", + switch_to_img2img: "writable", + switch_to_sketch: "writable", + switch_to_inpaint: "writable", + switch_to_inpaint_sketch: "writable", + switch_to_extras: "writable", + get_tab_index: "writable", + create_submit_args: "writable", + restart_reload: "writable", + updateInput: "writable", + //extraNetworks.js + requestGet: "writable", + popup: "writable", + // from python + localization: "writable", + // progrssbar.js + randomId: "writable", + requestProgress: "writable", + // imageviewer.js + modalPrevImage: "writable", + modalNextImage: "writable", + } }; -- cgit v1.2.3 From 994f56c3f930a4f130f34ad7c8e2ec86db3db3e7 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 19 May 2023 09:54:55 +0300 Subject: linter fixes --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index 78275554..9e7ab34d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -56,6 +56,7 @@ module.exports = { onOptionsChanged: "writable", uiCurrentTab: "writable", uiElementIsVisible: "writable", + uiElementInSight: "writable", executeCallbacks: "writable", //ui.js opts: "writable", -- cgit v1.2.3 From 208f066e0e83063dea749260cfd6c7582257139e Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 12:42:01 +0300 Subject: eslintrc: Sort eslint rules --- .eslintrc.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index 9e7ab34d..4d4a2424 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,9 +25,14 @@ module.exports = { "linebreak-style": ["error", "unix"], "no-extra-semi": "error", "no-mixed-spaces-and-tabs": "error", + "no-multi-spaces": "error", + "no-redeclare": "off", "no-trailing-spaces": "error", + "no-unused-vars": "off", "no-whitespace-before-property": "error", "object-curly-newline": ["error", {consistent: true, multiline: true}], + "object-curly-spacing": ["error", "never"], + "operator-linebreak": ["error", "after"], "quote-props": ["error", "consistent-as-needed"], "semi": ["error", "always"], "semi-spacing": "error", @@ -40,11 +45,6 @@ module.exports = { "switch-colon-spacing": "error", "template-curly-spacing": ["error", "never"], "unicode-bom": "error", - "no-multi-spaces": "error", - "object-curly-spacing": ["error", "never"], - "operator-linebreak": ["error", "after"], - "no-unused-vars": "off", - "no-redeclare": "off", }, globals: { // this file -- cgit v1.2.3 From 958d68fb146f84e7df8fca115a35847f862a2e9c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 12:46:33 +0300 Subject: eslintrc: Use a file-local `global` comment for module --- .eslintrc.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index 4d4a2424..e33a22c3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,4 @@ +/* global module */ module.exports = { env: { browser: true, @@ -47,8 +48,6 @@ module.exports = { "unicode-bom": "error", }, globals: { - // this file - module: "writable", //script.js gradioApp: "writable", onUiLoaded: "writable", -- cgit v1.2.3 From 247f371d3eaa9807d1f5986937cd10bf467ef9ca Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 12:50:47 +0300 Subject: eslintrc: mark most globals read-only --- .eslintrc.js | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index e33a22c3..1591795b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,41 +49,41 @@ module.exports = { }, globals: { //script.js - gradioApp: "writable", - onUiLoaded: "writable", - onUiUpdate: "writable", - onOptionsChanged: "writable", + gradioApp: "readonly", + onUiLoaded: "readonly", + onUiUpdate: "readonly", + onOptionsChanged: "readonly", uiCurrentTab: "writable", - uiElementIsVisible: "writable", - uiElementInSight: "writable", - executeCallbacks: "writable", + uiElementIsVisible: "readonly", + uiElementInSight: "readonly", + executeCallbacks: "readonly", //ui.js opts: "writable", - all_gallery_buttons: "writable", - selected_gallery_button: "writable", - selected_gallery_index: "writable", - args_to_array: "writable", - switch_to_txt2img: "writable", - switch_to_img2img_tab: "writable", - switch_to_img2img: "writable", - switch_to_sketch: "writable", - switch_to_inpaint: "writable", - switch_to_inpaint_sketch: "writable", - switch_to_extras: "writable", - get_tab_index: "writable", - create_submit_args: "writable", - restart_reload: "writable", - updateInput: "writable", + all_gallery_buttons: "readonly", + selected_gallery_button: "readonly", + selected_gallery_index: "readonly", + args_to_array: "readonly", + switch_to_txt2img: "readonly", + switch_to_img2img_tab: "readonly", + switch_to_img2img: "readonly", + switch_to_sketch: "readonly", + switch_to_inpaint: "readonly", + switch_to_inpaint_sketch: "readonly", + switch_to_extras: "readonly", + get_tab_index: "readonly", + create_submit_args: "readonly", + restart_reload: "readonly", + updateInput: "readonly", //extraNetworks.js - requestGet: "writable", - popup: "writable", + requestGet: "readonly", + popup: "readonly", // from python - localization: "writable", + localization: "readonly", // progrssbar.js - randomId: "writable", - requestProgress: "writable", + randomId: "readonly", + requestProgress: "readonly", // imageviewer.js - modalPrevImage: "writable", - modalNextImage: "writable", + modalPrevImage: "readonly", + modalNextImage: "readonly", } }; -- cgit v1.2.3 From 3909c2b2a08eff2334020b7c8484569f8891a80c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 12:55:06 +0300 Subject: eslintrc: enable no-redeclare but with builtinGlobals: false --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index 1591795b..fe9978fa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,7 +27,7 @@ module.exports = { "no-extra-semi": "error", "no-mixed-spaces-and-tabs": "error", "no-multi-spaces": "error", - "no-redeclare": "off", + "no-redeclare": ["error", {builtinGlobals: false}], "no-trailing-spaces": "error", "no-unused-vars": "off", "no-whitespace-before-property": "error", -- cgit v1.2.3 From 563e88dd91c80856697ec4f879de9a0516ebef5b Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 13:01:36 +0300 Subject: Replace args_to_array (and facsimiles) with Array.from --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) (limited to '.eslintrc.js') diff --git a/.eslintrc.js b/.eslintrc.js index fe9978fa..944cc869 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -62,7 +62,6 @@ module.exports = { all_gallery_buttons: "readonly", selected_gallery_button: "readonly", selected_gallery_index: "readonly", - args_to_array: "readonly", switch_to_txt2img: "readonly", switch_to_img2img_tab: "readonly", switch_to_img2img: "readonly", -- cgit v1.2.3