From a85d3133b53aacf145fd102e61b59919af47f573 Mon Sep 17 00:00:00 2001 From: Loic Date: Fri, 12 Apr 2024 11:10:22 +0200 Subject: [PATCH 1/3] fix JS linter in CI the es lint upgrade changed the way eslint config file is declared. we had to rename and migrate config options to the new configuration system --- .eslintrc.json | 101 ----------------------------------------- admin/.eslintrc.json | 7 --- eslint.config.mjs | 105 +++++++++++++++++++++++++++++++++++++++++++ package.json | 27 +++++++++++ 4 files changed, 132 insertions(+), 108 deletions(-) delete mode 100644 .eslintrc.json delete mode 100644 admin/.eslintrc.json create mode 100644 eslint.config.mjs create mode 100644 package.json diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 18178945e5b..00000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 2019 - }, - "env": { - "es6": true, - "browser": true, - "jquery": true - }, - "rules": { - "block-scoped-var": 0, - "camelcase": 0, - "comma-dangle": 0, - "comma-spacing": 0, - "computed-property-spacing": 0, - "consistent-return": 0, - "default-case": 0, - "dot-notation": 0, - "eqeqeq": 0, - "func-names": 0, - "guard-for-in": 0, - "indent": 0, - "key-spacing": 0, - "keyword-spacing": 0, - "linebreak-style": ["error", "unix"], - "max-len": 0, - "new-cap": 0, - "no-alert": 0, - "no-bitwise": 0, - "no-console": ["warn", { - "allow": ["warn"] - }], - "no-else-return": 0, - "no-extra-semi": "error", - "no-global-assign": ["error", { - "exceptions": ["Tabs"] - }], - "no-multi-spaces": 0, - "no-multi-str": 0, - "no-new": 0, - "no-param-reassign": 0, - "no-plusplus": 0, - "no-redeclare": "error", - "no-restricted-globals": 0, - "no-restricted-syntax": 0, - "no-shadow": 0, - "no-undef": "error", - "no-underscore-dangle": ["error", { - "allow": ["_sync", "_this", "_flatpickr"] - }], - "no-unused-vars": ["error", { - "vars": "all", "args": "none" - }], - "no-use-before-define": 0, - "no-unused-expressions": 0, - "no-var": 0, - "one-var": 0, - "one-var-declaration-per-line": 0, - "object-curly-newline": 0, - "object-curly-spacing": 0, - "object-shorthand": 0, - "operator-linebreak": 0, - "prefer-arrow-callback": 0, - "prefer-destructuring": 0, - "prefer-rest-params": 0, - "prefer-template": 0, - "quote-props": 0, - "quotes": 0, - "radix": 0, - "semi": 0, - "space-before-function-paren": 0, - "space-before-blocks": 0, - "space-infix-ops": 0, - "space-unary-ops": 0, - "spaced-comment": 0, - "strict": 0, - "vars-on-top": 0, - "wrap-iife": 0 - }, - "globals": { - "_": "readonly", - "accounting": "readonly", - "addVariantFromStockLocation": "writable", - "adjustShipmentItems": "writable", - "Backbone": "readonly", - "error": "writable", - "flatpickr": "readonly", - "Handlebars": "readonly", - "HandlebarsTemplates": "readonly", - "json": "writable", - "message": "writable", - "Select2": "readonly", - "shipments": "writable", - "show_flash": "writable", - "Sortable": "readonly", - "Spree": "readonly", - "Turbolinks": "readonly", - "update_state": "writable" - } -} diff --git a/admin/.eslintrc.json b/admin/.eslintrc.json deleted file mode 100644 index 892c2fdca41..00000000000 --- a/admin/.eslintrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 2023, - "sourceType": "module" - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000000..6b1930fb053 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,105 @@ +import globals from "globals"; +import js from "@eslint/js"; + +export default [ + js.configs.recommended, + { + "languageOptions": { + "ecmaVersion": 2023, + "sourceType": "module", + "globals": { + ...globals.browser, + ...globals.jquery, + "_": "readonly", + "accounting": "readonly", + "addVariantFromStockLocation": "writable", + "adjustShipmentItems": "writable", + "Backbone": "readonly", + "error": "writable", + "flatpickr": "readonly", + "Handlebars": "readonly", + "HandlebarsTemplates": "readonly", + "json": "writable", + "message": "writable", + "Select2": "readonly", + "shipments": "writable", + "show_flash": "writable", + "Sortable": "readonly", + "Spree": "readonly", + "Turbolinks": "readonly", + "update_state": "writable", + } + }, + "rules": { + "block-scoped-var": 0, + "camelcase": 0, + "comma-dangle": 0, + "comma-spacing": 0, + "computed-property-spacing": 0, + "consistent-return": 0, + "default-case": 0, + "dot-notation": 0, + "eqeqeq": 0, + "func-names": 0, + "guard-for-in": 0, + "indent": 0, + "key-spacing": 0, + "keyword-spacing": 0, + "linebreak-style": ["error", "unix"], + "max-len": 0, + "new-cap": 0, + "no-alert": 0, + "no-bitwise": 0, + "no-console": ["warn", { + "allow": ["warn"] + }], + "no-else-return": 0, + "no-extra-semi": "error", + "no-global-assign": ["error", { + "exceptions": ["Tabs"] + }], + "no-multi-spaces": 0, + "no-multi-str": 0, + "no-new": 0, + "no-param-reassign": 0, + "no-plusplus": 0, + "no-redeclare": "error", + "no-restricted-globals": 0, + "no-restricted-syntax": 0, + "no-shadow": 0, + "no-undef": "error", + "no-underscore-dangle": ["error", { + "allow": ["_sync", "_this", "_flatpickr"] + }], + "no-unused-vars": ["error", { + "vars": "all", "args": "none" + }], + "no-use-before-define": 0, + "no-unused-expressions": 0, + "no-var": 0, + "one-var": 0, + "one-var-declaration-per-line": 0, + "object-curly-newline": 0, + "object-curly-spacing": 0, + "object-shorthand": 0, + "operator-linebreak": 0, + "prefer-arrow-callback": 0, + "prefer-destructuring": 0, + "prefer-rest-params": 0, + "prefer-template": 0, + "quote-props": 0, + "quotes": 0, + "radix": 0, + "semi": 0, + "space-before-function-paren": 0, + "space-before-blocks": 0, + "space-infix-ops": 0, + "space-unary-ops": 0, + "spaced-comment": 0, + "strict": 0, + "vars-on-top": 0, + "wrap-iife": 0 + }, + + } +] diff --git a/package.json b/package.json new file mode 100644 index 00000000000..0687d8f0366 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "solidus", + "version": "0.0.1", + "description": "\"Solidus", + "main": "eslint.config.js", + "directories": { + "lib": "lib" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/solidusio/solidus.git" + }, + "author": "", + "license": "Spree License (https://github.com/solidusio/solidus/blob/main/LICENSE.md)", + "bugs": { + "url": "https://github.com/solidusio/solidus/issues" + }, + "homepage": "https://github.com/solidusio/solidus#readme", + "devDependencies": { + "@eslint/js": "^9.0.0", + "eslint": "^9.0.0", + "globals": "^15.0.0" + } +} From d134781aa32539175cd5463c9dcd4c6e4dda1645 Mon Sep 17 00:00:00 2001 From: Loic Date: Fri, 12 Apr 2024 11:27:18 +0200 Subject: [PATCH 2/3] make the package.json file minimal and private --- package.json | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/package.json b/package.json index 0687d8f0366..161d9dd5949 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,7 @@ { "name": "solidus", "version": "0.0.1", - "description": "\"Solidus", - "main": "eslint.config.js", - "directories": { - "lib": "lib" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/solidusio/solidus.git" - }, - "author": "", - "license": "Spree License (https://github.com/solidusio/solidus/blob/main/LICENSE.md)", - "bugs": { - "url": "https://github.com/solidusio/solidus/issues" - }, - "homepage": "https://github.com/solidusio/solidus#readme", + "private": true, "devDependencies": { "@eslint/js": "^9.0.0", "eslint": "^9.0.0", From 2f7a74ef058ae1298e3da550a6089d73c880c6a0 Mon Sep 17 00:00:00 2001 From: Loic Date: Fri, 12 Apr 2024 12:44:37 +0200 Subject: [PATCH 3/3] add npm install to CI linting job npm install is needed to run the lint:js rake task --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f9cee07c97a..f094d940da2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,6 @@ version: 2.1 orbs: browser-tools: circleci/browser-tools@1.4.6 codecov: codecov/codecov@3.3.0 - executors: base: parameters: ¶meters @@ -237,6 +236,7 @@ jobs: BUNDLE_ONLY: "lint" steps: - checkout + - run: 'npm install' - run: 'bundle install' - run: name: Check Ruby