From ab7708dc5155875453dc1a1f1893ca7c23438523 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 08:53:08 -0600 Subject: [PATCH 01/16] chore(packages): added eslint and scripts --- web-embeds/package.json | 15 ++++++- web-embeds/yarn.lock | 99 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 111 insertions(+), 3 deletions(-) diff --git a/web-embeds/package.json b/web-embeds/package.json index c3ec9623..2cc0d161 100644 --- a/web-embeds/package.json +++ b/web-embeds/package.json @@ -3,6 +3,10 @@ "description": "Apollos React embed widgets", "version": "0.1.24", "license": "MIT", + "eslintIgnore": [ + "/node_modules", + "/build" + ], "dependencies": { "@algolia/autocomplete-js": "^1.9.2", "@algolia/autocomplete-plugin-query-suggestions": "^1.9.2", @@ -28,6 +32,7 @@ "color": "^4.2.3", "date-fns": "^2.29.3", "dompurify": "^2.4.3", + "eslint-plugin-prettier": "^5.1.3", "graphql": "^16.6.0", "lodash": "^4.17.21", "moment": "^2.29.1", @@ -55,7 +60,9 @@ "dev": "craco start", "build": "node scripts/build.js", "test": "craco test", - "bump": "npm version patch && yarn build && git add . && git commit -m 'version bump' && git push && git push --tags && npm publish" + "bump": "npm version patch && yarn build && git add . && git commit -m 'version bump' && git push && git push --tags && npm publish", + "format": "prettier --write .", + "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint ." }, "eslintConfig": { "extends": [ @@ -80,7 +87,11 @@ "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/runtime": "^7.22.5", "babel-plugin-module-resolver": "^5.0.0", - "babel-plugin-styled-components": "^2.1.4" + "babel-plugin-styled-components": "^2.1.4", + "eslint": "^8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-simple-import-sort": "^10.0.0", + "prettier": "^3.0.0" }, "targets": { "global": { diff --git a/web-embeds/yarn.lock b/web-embeds/yarn.lock index cd4b4670..26755cde 100644 --- a/web-embeds/yarn.lock +++ b/web-embeds/yarn.lock @@ -1595,6 +1595,11 @@ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.55.0.tgz#b721d52060f369aa259cf97392403cb9ce892ec6" integrity sha512-qQfo2mxH5yVom1kacMtZZJFVdW+E70mqHMJvVg6WTLo+VBuQJ4TojZlfWBjK0ve5BdEeNAVxOsl/nvNMpJOaJA== +"@eslint/js@8.56.0": + version "8.56.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b" + integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A== + "@graphql-typed-document-node/core@^3.1.1": version "3.2.0" resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" @@ -1975,6 +1980,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + "@pmmmwh/react-refresh-webpack-plugin@^0.5.3": version "0.5.11" resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.11.tgz#7c2268cedaa0644d677e8c4f377bc8fb304f714a" @@ -5817,6 +5827,11 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@^8.8.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz#3a06a662130807e2502fc3ff8b4143d8a0658e11" + integrity sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg== + eslint-config-react-app@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4" @@ -5913,6 +5928,14 @@ eslint-plugin-jsx-a11y@^6.5.1: object.entries "^1.1.7" object.fromentries "^2.0.7" +eslint-plugin-prettier@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz#17cfade9e732cef32b5f5be53bd4e07afd8e67e1" + integrity sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.8.6" + eslint-plugin-react-hooks@^4.3.0: version "4.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" @@ -5940,6 +5963,11 @@ eslint-plugin-react@^7.27.1: semver "^6.3.1" string.prototype.matchall "^4.0.8" +eslint-plugin-simple-import-sort@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-10.0.0.tgz#cc4ceaa81ba73252427062705b64321946f61351" + integrity sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw== + eslint-plugin-testing-library@^5.0.1: version "5.11.1" resolved "https://registry.yarnpkg.com/eslint-plugin-testing-library/-/eslint-plugin-testing-library-5.11.1.tgz#5b46cdae96d4a78918711c0b4792f90088e62d20" @@ -6028,6 +6056,50 @@ eslint@^8.3.0: strip-ansi "^6.0.1" text-table "^0.2.0" +eslint@^8.45.0: + version "8.56.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.56.0.tgz#4957ce8da409dc0809f99ab07a1b94832ab74b15" + integrity sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.4" + "@eslint/js" "8.56.0" + "@humanwhocodes/config-array" "^0.11.13" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + "@ungap/structured-clone" "^1.2.0" + ajv "^6.12.4" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" + esquery "^1.4.2" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.3" + strip-ansi "^6.0.1" + text-table "^0.2.0" + espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" @@ -6184,6 +6256,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + fast-glob@^3.2.9, fast-glob@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -9393,6 +9470,18 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@^3.0.0: + version "3.2.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz#4723cadeac2ce7c9227de758e5ff9b14e075f283" + integrity sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ== + pretty-bytes@^5.3.0, pretty-bytes@^5.4.1: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" @@ -10754,6 +10843,14 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== +synckit@^0.8.6: + version "0.8.8" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.8.tgz#fe7fe446518e3d3d49f5e429f443cf08b6edfcd7" + integrity sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + tailwindcss@^3.0.2: version "3.3.6" resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.3.6.tgz#4dd7986bf4902ad385d90d45fd4b2fa5fab26d5f" @@ -10993,7 +11090,7 @@ tslib@^1.8.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.1: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.1, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== From 336ec4ea12159a00cc772a309e65e858b348c36e Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:02:16 -0600 Subject: [PATCH 02/16] chore(linter): brought over several files from Admin --- .prettierrc.js | 10 ---------- web-embeds/package.json | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 .prettierrc.js diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index e82993a2..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - arrowParens: 'always', // custom for Apollos, RN defaults to 'avoid' - bracketSameLine: false, // custom for Apollos, RN defaults to 'true' - bracketSpacing: true, // custom for Apollos, RN defaults to 'false' - singleQuote: true, - trailingComma: 'es5', // custom for Apollos, RN defaults to 'all' - tabWidth: 2, - proseWrap: 'preserve', - printWidth: 100, -}; diff --git a/web-embeds/package.json b/web-embeds/package.json index 2cc0d161..e9a3cdad 100644 --- a/web-embeds/package.json +++ b/web-embeds/package.json @@ -90,6 +90,7 @@ "babel-plugin-styled-components": "^2.1.4", "eslint": "^8.45.0", "eslint-config-prettier": "^8.8.0", + "eslint-config-react-app": "^7.0.1", "eslint-plugin-simple-import-sort": "^10.0.0", "prettier": "^3.0.0" }, From 47738a238008e1e36b24313939ebc70c294e270c Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:03:20 -0600 Subject: [PATCH 03/16] chore(linter): brought over several files from Admin --- web-embeds/.eslintignore | 2 + web-embeds/.eslintrc.js | 75 ++++++++++++++++++++++++++++++++++++++ web-embeds/.prettierignore | 11 ++++++ web-embeds/.prettierrc | 5 +++ 4 files changed, 93 insertions(+) create mode 100644 web-embeds/.eslintignore create mode 100644 web-embeds/.eslintrc.js create mode 100644 web-embeds/.prettierignore create mode 100644 web-embeds/.prettierrc diff --git a/web-embeds/.eslintignore b/web-embeds/.eslintignore new file mode 100644 index 00000000..b38db2f2 --- /dev/null +++ b/web-embeds/.eslintignore @@ -0,0 +1,2 @@ +node_modules/ +build/ diff --git a/web-embeds/.eslintrc.js b/web-embeds/.eslintrc.js new file mode 100644 index 00000000..fc671e60 --- /dev/null +++ b/web-embeds/.eslintrc.js @@ -0,0 +1,75 @@ +module.exports = { + extends: [ + "@remix-run/eslint-config", + "@remix-run/eslint-config/node", + "@remix-run/eslint-config/jest-testing-library", + "plugin:prettier/recommended", + ], + settings: { + jest: { + version: 28, + }, + }, + plugins: ["simple-import-sort", "import"], + rules: { + "simple-import-sort/imports": "error", + "simple-import-sort/exports": "error", + "import/first": "error", + "import/newline-after-import": "error", + "import/no-duplicates": "error", + "import/order": [ + "error", + { + groups: [ + "builtin", + "external", + "internal", + "unknown", + "parent", + "sibling", + "index", + "object", + "type", + ], + pathGroups: [ + { + pattern: "@remix-run/**", + group: "external", + }, + { + pattern: "~/**", + group: "internal", + }, + { + pattern: "../**", + group: "parent", + position: "before", + }, + { + pattern: "./**", + group: "sibling", + position: "after", + }, + ], + pathGroupsExcludedImportTypes: ["builtin"], + "newlines-between": "always", + alphabetize: { + order: "asc", + caseInsensitive: true, + }, + }, + ], + "lines-around-comment": [ + "error", + { + allowArrayStart: true, + allowBlockStart: true, + allowClassStart: true, + allowObjectStart: true, + beforeBlockComment: true, + beforeLineComment: true, + }, + ], + "spaced-comment": ["error", "always"], + }, +}; diff --git a/web-embeds/.prettierignore b/web-embeds/.prettierignore new file mode 100644 index 00000000..72bfc1fa --- /dev/null +++ b/web-embeds/.prettierignore @@ -0,0 +1,11 @@ +node_modules + +/build +/public/build +.env + +/cypress/screenshots +/cypress/videos +/postgres-data + +/app/styles/tailwind.css diff --git a/web-embeds/.prettierrc b/web-embeds/.prettierrc new file mode 100644 index 00000000..63c660cd --- /dev/null +++ b/web-embeds/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": true, + "singleQuote": false, + "trailingComma": "es5" +} From f0f2afe0225848a226d2149c467d7fec4bba0d60 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:13:33 -0600 Subject: [PATCH 04/16] chore(linter): more config --- package.json | 2 +- web-embeds/.eslintignore | 2 ++ web-embeds/.eslintrc.js | 30 +++++++++++------------------- web-embeds/.prettierignore | 7 +------ web-embeds/craco.config.js | 16 ++++++++-------- web-embeds/tailwind.config.js | 2 +- 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 485c628e..ca826392 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,6 @@ "packages": [ "packages/*" ], - "nohoist": [] + "nohoist": [ ] } } diff --git a/web-embeds/.eslintignore b/web-embeds/.eslintignore index b38db2f2..824d3f24 100644 --- a/web-embeds/.eslintignore +++ b/web-embeds/.eslintignore @@ -1,2 +1,4 @@ node_modules/ build/ + +widget/ diff --git a/web-embeds/.eslintrc.js b/web-embeds/.eslintrc.js index fc671e60..f655513e 100644 --- a/web-embeds/.eslintrc.js +++ b/web-embeds/.eslintrc.js @@ -1,15 +1,5 @@ module.exports = { - extends: [ - "@remix-run/eslint-config", - "@remix-run/eslint-config/node", - "@remix-run/eslint-config/jest-testing-library", - "plugin:prettier/recommended", - ], - settings: { - jest: { - version: 28, - }, - }, + extends: ["react-app", "plugin:prettier/recommended"], plugins: ["simple-import-sort", "import"], rules: { "simple-import-sort/imports": "error", @@ -33,23 +23,25 @@ module.exports = { ], pathGroups: [ { - pattern: "@remix-run/**", + pattern: "react", group: "external", + position: "before", }, { - pattern: "~/**", - group: "internal", - }, - { - pattern: "../**", - group: "parent", - position: "before", + pattern: "**", + group: "external", + position: "after", }, { pattern: "./**", group: "sibling", position: "after", }, + { + pattern: "../**", + group: "parent", + position: "before", + }, ], pathGroupsExcludedImportTypes: ["builtin"], "newlines-between": "always", diff --git a/web-embeds/.prettierignore b/web-embeds/.prettierignore index 72bfc1fa..ae59894a 100644 --- a/web-embeds/.prettierignore +++ b/web-embeds/.prettierignore @@ -1,11 +1,6 @@ node_modules /build -/public/build .env -/cypress/screenshots -/cypress/videos -/postgres-data - -/app/styles/tailwind.css +widget \ No newline at end of file diff --git a/web-embeds/craco.config.js b/web-embeds/craco.config.js index ce0753ee..dcc14469 100644 --- a/web-embeds/craco.config.js +++ b/web-embeds/craco.config.js @@ -3,15 +3,15 @@ module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { // Override JavaScript file names - webpackConfig.output.filename = 'static/js/index.js'; - webpackConfig.output.chunkFilename = 'static/js/[name].chunk.js'; + webpackConfig.output.filename = "static/js/index.js"; + webpackConfig.output.chunkFilename = "static/js/[name].chunk.js"; // Override CSS file names in production - if (env === 'production') { + if (env === "production") { webpackConfig.plugins.forEach((plugin) => { - if (plugin.constructor.name === 'MiniCssExtractPlugin') { - plugin.options.filename = 'static/css/index.css'; - plugin.options.chunkFilename = 'static/css/[name].chunk.css'; + if (plugin.constructor.name === "MiniCssExtractPlugin") { + plugin.options.filename = "static/css/index.css"; + plugin.options.chunkFilename = "static/css/[name].chunk.css"; } }); } @@ -21,10 +21,10 @@ module.exports = { }, style: { postcss: { - plugins: [require('autoprefixer')], + plugins: [require("autoprefixer")], }, }, babel: { - presets: ['@babel/preset-react'], + presets: ["@babel/preset-react"], }, }; diff --git a/web-embeds/tailwind.config.js b/web-embeds/tailwind.config.js index 664d9719..10970dae 100644 --- a/web-embeds/tailwind.config.js +++ b/web-embeds/tailwind.config.js @@ -1,5 +1,5 @@ module.exports = { - purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], + purge: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"], darkMode: false, // or 'media' or 'class' theme: { extend: {}, From 9da4265bd413ae7a62a98019c3b640a7e0bd0740 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:14:59 -0600 Subject: [PATCH 05/16] chore(linter): prettier run --- web-embeds/README.md | 1 - web-embeds/jsconfig.json | 4 +- web-embeds/public/index.html | 82 ++++++++++++++++++------------- web-embeds/scripts/build.js | 22 +++++---- web-embeds/src/App.js | 28 ++++++----- web-embeds/src/App.test.js | 7 +-- web-embeds/src/error-page.jsx | 2 +- web-embeds/src/index.css | 18 +++++-- web-embeds/src/index.js | 19 +++---- web-embeds/src/reportWebVitals.js | 4 +- web-embeds/src/setupTests.js | 2 +- 11 files changed, 111 insertions(+), 78 deletions(-) diff --git a/web-embeds/README.md b/web-embeds/README.md index e463e219..db482887 100644 --- a/web-embeds/README.md +++ b/web-embeds/README.md @@ -13,7 +13,6 @@ Follow the steps below to deploy your apollos-embeds: `https://cdn.jsdelivr.net/npm/@apollosproject/apollos-embeds@latest/widget/index.js, https://cdn.jsdelivr.net/npm/@apollosproject/apollos-embeds@latest/widget/index.css, https://cdn.jsdelivr.net/npm/@apollosproject/apollos-embeds` - ## Manual 1. Update the package version in the `package.json` file. diff --git a/web-embeds/jsconfig.json b/web-embeds/jsconfig.json index 36aa1a4d..89283cc7 100644 --- a/web-embeds/jsconfig.json +++ b/web-embeds/jsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { - "baseUrl": "." - } + "baseUrl": ".", + }, } diff --git a/web-embeds/public/index.html b/web-embeds/public/index.html index f231eb63..94a2e7ba 100644 --- a/web-embeds/public/index.html +++ b/web-embeds/public/index.html @@ -1,19 +1,21 @@ - + - - - - - - - - - - - - Apollos Web Embeds - - + Apollos Web Embeds + + - - - - + - - -
- - - - \ No newline at end of file + + diff --git a/web-embeds/scripts/build.js b/web-embeds/scripts/build.js index c829ebb2..3747dea2 100644 --- a/web-embeds/scripts/build.js +++ b/web-embeds/scripts/build.js @@ -1,6 +1,8 @@ -const fs = require('fs-extra'); -const path = require('path'); -const execSync = require('child_process').execSync; +const path = require("path"); + +const fs = require("fs-extra"); + +const execSync = require("child_process").execSync; function moveFile(source, destination) { fs.move(source, destination, { overwrite: true }, (err) => { @@ -11,15 +13,15 @@ function moveFile(source, destination) { function main() { // Run the CRA build script - execSync('craco build', { stdio: 'inherit' }); + execSync("craco build", { stdio: "inherit" }); // Define source and destination paths - const buildDir = path.join(__dirname, '..', 'build', 'static'); - const widgetDir = path.join(__dirname, '..', 'widget'); - const jsSource = path.join(buildDir, 'js', 'index.js'); - const cssSource = path.join(buildDir, 'css', 'index.css'); - const jsDestination = path.join(widgetDir, 'index.js'); - const cssDestination = path.join(widgetDir, 'index.css'); + const buildDir = path.join(__dirname, "..", "build", "static"); + const widgetDir = path.join(__dirname, "..", "widget"); + const jsSource = path.join(buildDir, "js", "index.js"); + const cssSource = path.join(buildDir, "css", "index.css"); + const jsDestination = path.join(widgetDir, "index.js"); + const cssDestination = path.join(widgetDir, "index.css"); // Ensure widget directory exists fs.ensureDirSync(widgetDir); diff --git a/web-embeds/src/App.js b/web-embeds/src/App.js index b2633030..d3461d39 100644 --- a/web-embeds/src/App.js +++ b/web-embeds/src/App.js @@ -1,35 +1,37 @@ -import React from 'react'; -import * as Sentry from '@sentry/react'; -import { Main } from '@apollosproject/web-shared/embeds'; -import { AppProvider } from '@apollosproject/web-shared/providers'; -import { createBrowserRouter, RouterProvider } from 'react-router-dom'; -import ErrorPage from './error-page'; +import React from "react"; +import { Main } from "@apollosproject/web-shared/embeds"; +import { AppProvider } from "@apollosproject/web-shared/providers"; +import * as Sentry from "@sentry/react"; +import { createBrowserRouter, RouterProvider } from "react-router-dom"; + +import ErrorPage from "./error-page"; Sentry.init({ dsn: process.env.REACT_APP_SENTRY_DSN, + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. tracesSampleRate: 1.0, }); function App() { - const searchElement = document.querySelector('[data-search-feed]'); - const churchElement = document.querySelector('[data-church]'); - const placeholderElement = document.querySelector('[data-placeholder]'); + const searchElement = document.querySelector("[data-search-feed]"); + const churchElement = document.querySelector("[data-church]"); + const placeholderElement = document.querySelector("[data-placeholder]"); const searchFeed = searchElement - ? searchElement.getAttribute('data-search-feed') + ? searchElement.getAttribute("data-search-feed") : null; const church = churchElement - ? churchElement.getAttribute('data-church') + ? churchElement.getAttribute("data-church") : null; const customPlaceholder = placeholderElement - ? placeholderElement.getAttribute('data-placeholder') + ? placeholderElement.getAttribute("data-placeholder") : null; const router = createBrowserRouter([ { - path: '*', + path: "*", element:
, errorElement: , }, diff --git a/web-embeds/src/App.test.js b/web-embeds/src/App.test.js index 1f03afee..8501e5cb 100644 --- a/web-embeds/src/App.test.js +++ b/web-embeds/src/App.test.js @@ -1,7 +1,8 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; +import { render, screen } from "@testing-library/react"; -test('renders learn react link', () => { +import App from "./App"; + +test("renders learn react link", () => { render(); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument(); diff --git a/web-embeds/src/error-page.jsx b/web-embeds/src/error-page.jsx index e98a3b4f..de477f3f 100644 --- a/web-embeds/src/error-page.jsx +++ b/web-embeds/src/error-page.jsx @@ -14,4 +14,4 @@ export default function ErrorPage() {

); -} \ No newline at end of file +} diff --git a/web-embeds/src/index.css b/web-embeds/src/index.css index 2dd59030..d9dd9236 100644 --- a/web-embeds/src/index.css +++ b/web-embeds/src/index.css @@ -1,10 +1,22 @@ -@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap'); +@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap"); .apollos-widget { font-size: 16px; height: 100%; - font-family: inherit, 'Inter', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, - Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; + font-family: + inherit, + "Inter", + -apple-system, + BlinkMacSystemFont, + Segoe UI, + Roboto, + Oxygen, + Ubuntu, + Cantarell, + Fira Sans, + Droid Sans, + Helvetica Neue, + sans-serif; } .apollos-widget ul { diff --git a/web-embeds/src/index.js b/web-embeds/src/index.js index 187fcfd4..859980b1 100644 --- a/web-embeds/src/index.js +++ b/web-embeds/src/index.js @@ -1,20 +1,21 @@ -import React from 'react'; -import ReactDOM from 'react-dom/client'; +import "./index.css"; +import "react-image-crop/dist/ReactCrop.css"; +import "react-multi-carousel/lib/styles.css"; -import './index.css'; -import 'react-image-crop/dist/ReactCrop.css'; -import 'react-multi-carousel/lib/styles.css'; +import React from "react"; -import App from './App'; -import reportWebVitals from './reportWebVitals'; +import ReactDOM from "react-dom/client"; + +import App from "./App"; +import reportWebVitals from "./reportWebVitals"; window.document.body.insertAdjacentHTML( - 'afterbegin', + "afterbegin", '
' ); const root = ReactDOM.createRoot( - document.getElementById('apollos-project-widget') + document.getElementById("apollos-project-widget") ); root.render( diff --git a/web-embeds/src/reportWebVitals.js b/web-embeds/src/reportWebVitals.js index 5253d3ad..9ecd33f9 100644 --- a/web-embeds/src/reportWebVitals.js +++ b/web-embeds/src/reportWebVitals.js @@ -1,6 +1,6 @@ -const reportWebVitals = onPerfEntry => { +const reportWebVitals = (onPerfEntry) => { if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); diff --git a/web-embeds/src/setupTests.js b/web-embeds/src/setupTests.js index 8f2609b7..1dd407a6 100644 --- a/web-embeds/src/setupTests.js +++ b/web-embeds/src/setupTests.js @@ -2,4 +2,4 @@ // allows you to do things like: // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom'; +import "@testing-library/jest-dom"; From 41a9b282484757bc8261e39288023be7624db96a Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:23:04 -0600 Subject: [PATCH 06/16] chore(vscode): add vscode folder and linter run --- web-embeds/.eslintrc.js | 2 -- web-embeds/scripts/build.js | 3 +-- web-embeds/src/App.js | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/web-embeds/.eslintrc.js b/web-embeds/.eslintrc.js index f655513e..53b61f94 100644 --- a/web-embeds/.eslintrc.js +++ b/web-embeds/.eslintrc.js @@ -2,8 +2,6 @@ module.exports = { extends: ["react-app", "plugin:prettier/recommended"], plugins: ["simple-import-sort", "import"], rules: { - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", "import/first": "error", "import/newline-after-import": "error", "import/no-duplicates": "error", diff --git a/web-embeds/scripts/build.js b/web-embeds/scripts/build.js index 3747dea2..604d0623 100644 --- a/web-embeds/scripts/build.js +++ b/web-embeds/scripts/build.js @@ -1,9 +1,8 @@ +const execSync = require("child_process").execSync; const path = require("path"); const fs = require("fs-extra"); -const execSync = require("child_process").execSync; - function moveFile(source, destination) { fs.move(source, destination, { overwrite: true }, (err) => { if (err) return console.error(err); diff --git a/web-embeds/src/App.js b/web-embeds/src/App.js index d3461d39..a4c6b2f4 100644 --- a/web-embeds/src/App.js +++ b/web-embeds/src/App.js @@ -1,4 +1,5 @@ import React from "react"; + import { Main } from "@apollosproject/web-shared/embeds"; import { AppProvider } from "@apollosproject/web-shared/providers"; import * as Sentry from "@sentry/react"; From eb5b35fd6b669cfe513b86cf9f2b4664fd17843c Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:23:55 -0600 Subject: [PATCH 07/16] chore(vscode): add the vscode folder --- .vscode/extensions.json | 10 ++++++++++ .vscode/launch.json | 15 +++++++++++++++ .vscode/settings.json | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..830095d6 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "bradlc.vscode-tailwindcss", + "dbaeumer.vscode-eslint", + "github.vscode-pull-request-github", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "meganrogge.template-string-converter" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..c6db4c64 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}/app" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f11fda63 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "prettier.trailingComma": "es5", + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.fixAll.prettier": "explicit" + }, + "prettier.requireConfig": true +} From 90dc80226a82fb6748f39df8711c81a6bf97ceb7 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:40:16 -0600 Subject: [PATCH 08/16] chore(linter): more setup --- .vscode/extensions.json | 1 - web-embeds/.eslintrc.js | 28 ++++++---------------------- web-embeds/scripts/build.js | 3 +-- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 830095d6..31935f95 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,5 @@ { "recommendations": [ - "bradlc.vscode-tailwindcss", "dbaeumer.vscode-eslint", "github.vscode-pull-request-github", "eamodio.gitlens", diff --git a/web-embeds/.eslintrc.js b/web-embeds/.eslintrc.js index 53b61f94..f0cc0776 100644 --- a/web-embeds/.eslintrc.js +++ b/web-embeds/.eslintrc.js @@ -9,39 +9,23 @@ module.exports = { "error", { groups: [ - "builtin", - "external", + ["external", "builtin"], "internal", - "unknown", - "parent", - "sibling", + ["sibling", "parent"], "index", - "object", - "type", ], pathGroups: [ { - pattern: "react", + pattern: "@(react|react-native)", group: "external", position: "before", }, { - pattern: "**", - group: "external", - position: "after", - }, - { - pattern: "./**", - group: "sibling", - position: "after", - }, - { - pattern: "../**", - group: "parent", - position: "before", + pattern: "@src/**", + group: "internal", }, ], - pathGroupsExcludedImportTypes: ["builtin"], + pathGroupsExcludedImportTypes: ["internal", "react"], "newlines-between": "always", alphabetize: { order: "asc", diff --git a/web-embeds/scripts/build.js b/web-embeds/scripts/build.js index 604d0623..dd3807e7 100644 --- a/web-embeds/scripts/build.js +++ b/web-embeds/scripts/build.js @@ -1,7 +1,6 @@ const execSync = require("child_process").execSync; -const path = require("path"); - const fs = require("fs-extra"); +const path = require("path"); function moveFile(source, destination) { fs.move(source, destination, { overwrite: true }, (err) => { From 49d16b07646907d24f011726527b8dc93f5361df Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:51:00 -0600 Subject: [PATCH 09/16] fix: put back a file I deleted by accident --- .prettierrc.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .prettierrc.js diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..64a4871f --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,10 @@ +module.exports = { + arrowParens: 'always', // custom for Apollos, RN defaults to 'avoid' + bracketSameLine: false, // custom for Apollos, RN defaults to 'true' + bracketSpacing: true, // custom for Apollos, RN defaults to 'false' + singleQuote: true, + trailingComma: 'es5', // custom for Apollos, RN defaults to 'all' + tabWidth: 2, + proseWrap: 'preserve', + printWidth: 100, +}; \ No newline at end of file From fe38c4fd59981f48ddff77d0ef534080b33271b2 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 09:51:21 -0600 Subject: [PATCH 10/16] lint --- .prettierrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc.js b/.prettierrc.js index 64a4871f..e82993a2 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -7,4 +7,4 @@ module.exports = { tabWidth: 2, proseWrap: 'preserve', printWidth: 100, -}; \ No newline at end of file +}; From dd3fde91a9e063057aeb0285d53b8c1c441a7d8d Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 10:01:46 -0600 Subject: [PATCH 11/16] chore(gh workflow): add lint workflow --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..44021d87 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint Check + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: Install Dependencies + run: yarn install + + - name: Run Lint + run: yarn lint From ad109db74072a500f0b8325387a2d968ea751f4b Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 10:06:36 -0600 Subject: [PATCH 12/16] chore(gh): changes to lint ci --- .github/workflows/lint.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 44021d87..60585494 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,12 @@ -name: Lint Check +name: Lint Web Embeds -on: [push, pull_request] +on: + push: + paths: + - 'web-embeds/**' + pull_request: + paths: + - 'web-embeds/**' jobs: lint: @@ -8,13 +14,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js + + - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '14' # Specify your Node.js version - name: Install Dependencies - run: yarn install + run: cd web-embeds && yarn install - name: Run Lint - run: yarn lint + run: cd web-embeds && yarn lint From 3cedd2fab2b44862c6066fbcecc382e7616a296d Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 10:08:35 -0600 Subject: [PATCH 13/16] chore(gh): bump node version --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 60585494..2edc8b05 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: '14' # Specify your Node.js version + node-version: '16' - name: Install Dependencies run: cd web-embeds && yarn install From 2f89084b91c02d5442cda995bb7929f039ffe476 Mon Sep 17 00:00:00 2001 From: Vincent Wilson Date: Wed, 24 Jan 2024 14:28:01 -0500 Subject: [PATCH 14/16] Update web-embeds/jsconfig.json --- web-embeds/jsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-embeds/jsconfig.json b/web-embeds/jsconfig.json index 89283cc7..193942a1 100644 --- a/web-embeds/jsconfig.json +++ b/web-embeds/jsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { "baseUrl": ".", - }, + } } From f9ea6161cad890992933b4a93f23c2c622d58bde Mon Sep 17 00:00:00 2001 From: Vincent Wilson Date: Wed, 24 Jan 2024 14:28:09 -0500 Subject: [PATCH 15/16] Update web-embeds/jsconfig.json --- web-embeds/jsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-embeds/jsconfig.json b/web-embeds/jsconfig.json index 193942a1..36aa1a4d 100644 --- a/web-embeds/jsconfig.json +++ b/web-embeds/jsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { - "baseUrl": ".", + "baseUrl": "." } } From 58e56469a05f2f2530914a9bf6a7f0afe3c86e06 Mon Sep 17 00:00:00 2001 From: Nathan Lewis Date: Wed, 24 Jan 2024 13:58:23 -0600 Subject: [PATCH 16/16] lint --- web-embeds/src/error-page.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/web-embeds/src/error-page.jsx b/web-embeds/src/error-page.jsx index de477f3f..95ecb6bf 100644 --- a/web-embeds/src/error-page.jsx +++ b/web-embeds/src/error-page.jsx @@ -1,4 +1,5 @@ import React from "react"; + import { useRouteError } from "react-router-dom"; export default function ErrorPage() {