From 3c055142e56278e056d54d25d25af3cce0865378 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 1 Apr 2022 18:05:11 +0200 Subject: [PATCH 01/14] Add babel preset --- packages/js/.babelrc | 25 ---------- packages/js/babel.config.js | 10 ++++ packages/js/jest.config.js | 28 +++++++++++ packages/js/package.json | 31 +++--------- packages/js/tests/indexation.test.js | 72 +++++++++++++--------------- yarn.lock | 15 +++++- 6 files changed, 89 insertions(+), 92 deletions(-) delete mode 100644 packages/js/.babelrc create mode 100644 packages/js/babel.config.js create mode 100644 packages/js/jest.config.js diff --git a/packages/js/.babelrc b/packages/js/.babelrc deleted file mode 100644 index 3db4d48dd5e..00000000000 --- a/packages/js/.babelrc +++ /dev/null @@ -1,25 +0,0 @@ -{ - "presets": [ - [ - "env", - { - "targets": { - "browsers": [ - "extends @yoast/browserslist-config" - ] - } - } - ], - "react" - ], - "plugins": [ - "transform-object-rest-spread" - ], - "env": { - "test": { - "plugins": [ - "babel-plugin-styled-components" - ] - } - } -} diff --git a/packages/js/babel.config.js b/packages/js/babel.config.js new file mode 100644 index 00000000000..86367449f94 --- /dev/null +++ b/packages/js/babel.config.js @@ -0,0 +1,10 @@ +module.exports = { + presets: [ "@yoast/babel-preset" ], + env: { + test: { + plugins: [ + "babel-plugin-styled-components", + ], + }, + }, +}; diff --git a/packages/js/jest.config.js b/packages/js/jest.config.js new file mode 100644 index 00000000000..19f9418e23f --- /dev/null +++ b/packages/js/jest.config.js @@ -0,0 +1,28 @@ +module.exports = { + preset: "@yoast/jest-preset", + setupFilesAfterEnv: [ "/tests/setupTests.js" ], + testPathIgnorePatterns: [ + "/tests/edit.test.js", + "/tests/__mocks__/", + "/tests/containers/mockSelectors.js", + "/tests/helpers/factory.js", + "/tests/setupTests.js", + "/tests/decorator/__mocks__/@wordpress/rich-text/index.js", + ], + + moduleNameMapper: { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/tests/__mocks__/fileMock.js", + "\\.(css|less)$": "/tests/__mocks__/styleMock.js", + "find-with-regex": "/node_modules/find-with-regex/lib/index.js", + "^lodash-es$": "lodash", + "^lodash-es/(.*)$": "lodash/$1", + }, + moduleDirectories: [ + "/node_modules", + "node_modules", + ], + snapshotSerializers: [ + "enzyme-to-json/serializer", + ], + testURL: "http://localhost/", +}; diff --git a/packages/js/package.json b/packages/js/package.json index 810aa64017e..bc25fad9026 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -5,30 +5,6 @@ "test": "jest -u", "lint": "eslint src tests --max-warnings=152" }, - "jest": { - "setupTestFrameworkScriptFile": "/tests/setupTests.js", - "transformIgnorePatterns": [ - "[/\\\\]node_modules[/\\\\](?!yoast-components|yoastseo|lodash-es|lodash|@yoast).+\\.js$" - ], - "testPathIgnorePatterns": [ - "/tests/edit.test.js" - ], - "moduleNameMapper": { - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/tests/__mocks__/fileMock.js", - "\\.(css|less)$": "/tests/__mocks__/styleMock.js", - "find-with-regex": "/node_modules/find-with-regex/lib/index.js", - "^lodash-es$": "lodash", - "^lodash-es/(.*)$": "lodash/$1" - }, - "moduleDirectories": [ - "/node_modules", - "node_modules" - ], - "snapshotSerializers": [ - "enzyme-to-json/serializer" - ], - "testURL": "http://localhost/" - }, "dependencies": { "@draft-js-plugins/mention": "^5.0.0", "@wordpress/blocks": "^11.1.2", @@ -66,8 +42,13 @@ "yoastseo": "^1.91.0" }, "devDependencies": { + "@babel/core": "^7.15.5", "@wordpress/dependency-extraction-webpack-plugin": "^2.8.0", - "case-sensitive-paths-webpack-plugin": "^2.1.2" + "@yoast/babel-preset": "^1.0.0", + "@yoast/jest-preset": "^1.0.0", + "babel-plugin-styled-components": "^2.0.6", + "case-sensitive-paths-webpack-plugin": "^2.1.2", + "jest": "^27.5.1" }, "peerDependencies": { "react": "16.14.0", diff --git a/packages/js/tests/indexation.test.js b/packages/js/tests/indexation.test.js index 29781d40f4f..cc8085fb59a 100644 --- a/packages/js/tests/indexation.test.js +++ b/packages/js/tests/indexation.test.js @@ -1,5 +1,6 @@ -import Indexation from "../src/components/Indexation"; import { mount } from "enzyme"; +import { act } from "react-dom/test-utils"; +import Indexation from "../src/components/Indexation"; /** * Fetch mock response. @@ -30,7 +31,7 @@ describe( "Indexation", () => { expect( alert.text() ).toEqual( "SEO data optimization is disabled for non-production environments." ); } ); - it( "will show you when the indexation is complete", ( done ) => { + it( "will show you when the indexation is complete", async() => { global.yoastIndexingData = { amount: 5, restApi: { @@ -65,26 +66,25 @@ describe( "Indexation", () => { expect( progressBar.prop( "value" ) ).toEqual( 0 ); expect( progressBar.prop( "max" ) ).toEqual( 5 ); - // Allow callbacks to be executed first. - setTimeout( () => { + await act( async() => { component.update(); + } ); - expect( global.fetch ).toHaveBeenCalledWith( "https://example.com/indexing-endpoint", { - headers: { - "X-WP-Nonce": "nonsense", - }, - method: "POST", - } ); - - const alert = component.find( "Alert" ); - expect( alert.text() ).toEqual( "SEO data optimization complete" ); - expect( alert.prop( "type" ) ).toEqual( "success" ); + component.update(); - done(); + expect( global.fetch ).toHaveBeenCalledWith( "https://example.com/indexing-endpoint", { + headers: { + "X-WP-Nonce": "nonsense", + }, + method: "POST", } ); + + const alert = await component.find( "Alert" ); + expect( alert.text() ).toEqual( "SEO data optimization complete" ); + expect( alert.prop( "type" ) ).toEqual( "success" ); } ); - it( "shows an error when something goes wrong", ( done ) => { + it( "shows an error when something goes wrong", async() => { global.yoastIndexingData = { amount: 5, restApi: { @@ -98,27 +98,24 @@ describe( "Indexation", () => { errorMessage: "An error message.", }; - global.fetch = jest.fn(); - global.fetch.mockImplementation( () => { - return Promise.reject( new Error( "Request failed!" ) ); - } ); + global.fetch = jest.fn( () => ( + Promise.reject( new Error( "Request failed!" ) ) ) + ); const component = mount( ); - component.find( "button" ).simulate( "click" ); - - setTimeout( () => { - component.update(); + await act( async() => { + component.find( "button" ).simulate( "click" ); + } ); - const alert = component.find( "Alert" ); + component.update(); - expect( alert.prop( "type" ) ).toEqual( "error" ); + const alert = component.find( "Alert" ); - done(); - } ); + expect( alert.prop( "type" ) ).toEqual( "error" ); } ); - it( "executes registered pre- and postindexing actions", async function( done ) { + it( "executes registered pre- and postindexing actions", async() => { global.yoastIndexingData = { amount: 5, restApi: { @@ -159,17 +156,12 @@ describe( "Indexation", () => { component.update(); - // Allow setState to mutate the sate. - setTimeout( () => { - const settings = global.yoastIndexingData; - - expect( preIndexingAction ).toHaveBeenCalledWith( settings ); - expect( postIndexingAction ).toHaveBeenCalledWith( [ - // Response.objects - {}, {}, {}, {}, {}, - ], settings ); + const settings = global.yoastIndexingData; - done(); - }, 5 ); + expect( preIndexingAction ).toHaveBeenCalledWith( settings ); + expect( postIndexingAction ).toHaveBeenCalledWith( [ + // Response.objects + {}, {}, {}, {}, {}, + ], settings ); } ); } ); diff --git a/yarn.lock b/yarn.lock index bb520b4edf2..4c8b7fd6358 100644 --- a/yarn.lock +++ b/yarn.lock @@ -259,7 +259,7 @@ dependencies: "@babel/types" "^7.12.13" -"@babel/helper-annotate-as-pure@^7.16.7": +"@babel/helper-annotate-as-pure@^7.16.0", "@babel/helper-annotate-as-pure@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== @@ -460,7 +460,7 @@ dependencies: "@babel/types" "^7.12.13" -"@babel/helper-module-imports@^7.16.7": +"@babel/helper-module-imports@^7.16.0", "@babel/helper-module-imports@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== @@ -8190,6 +8190,17 @@ babel-plugin-react-docgen@^4.2.1: babel-plugin-syntax-jsx "^6.18.0" lodash "^4.17.11" +babel-plugin-styled-components@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.6.tgz#6f76c7f7224b7af7edc24a4910351948c691fc90" + integrity sha512-Sk+7o/oa2HfHv3Eh8sxoz75/fFvEdHsXV4grdeHufX0nauCmymlnN0rGhIvfpMQSJMvGutJ85gvCGea4iqmDpg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.16.0" + "@babel/helper-module-imports" "^7.16.0" + babel-plugin-syntax-jsx "^6.18.0" + lodash "^4.17.11" + picomatch "^2.3.0" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" From 239cb0883312e905d73b14d51b56540702e9aac6 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 6 Apr 2022 13:36:52 +0200 Subject: [PATCH 02/14] Fix lint warnings --- packages/js/package.json | 2 +- packages/js/tests/indexation.test.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index bc25fad9026..a3df8e91b73 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "scripts": { "test": "jest -u", - "lint": "eslint src tests --max-warnings=152" + "lint": "eslint src tests --max-warnings=149" }, "dependencies": { "@draft-js-plugins/mention": "^5.0.0", diff --git a/packages/js/tests/indexation.test.js b/packages/js/tests/indexation.test.js index cc8085fb59a..9362dce4751 100644 --- a/packages/js/tests/indexation.test.js +++ b/packages/js/tests/indexation.test.js @@ -9,7 +9,7 @@ import Indexation from "../src/components/Indexation"; * * @returns {Promise} The promise. */ -const fetchReponse = ( data ) => { +const fetchResponse = ( data ) => { return Promise.resolve( { text: () => Promise.resolve( JSON.stringify( data ) ), ok: true } ); }; @@ -36,6 +36,7 @@ describe( "Indexation", () => { amount: 5, restApi: { root: "https://example.com/", + // eslint-disable-next-line camelcase indexing_endpoints: { prepare: "indexing-endpoint", }, @@ -43,10 +44,9 @@ describe( "Indexation", () => { }, }; - global.fetch = jest.fn(); - global.fetch.mockImplementation( ( url ) => { + global.fetch = jest.fn().mockImplementation( ( url ) => { if ( url === "https://example.com/indexing-endpoint" ) { - return fetchReponse( { + return fetchResponse( { objects: [ {}, {}, {}, {}, {}, ], @@ -89,6 +89,7 @@ describe( "Indexation", () => { amount: 5, restApi: { root: "https://example.com/", + // eslint-disable-next-line camelcase indexing_endpoints: { prepare: "indexing-endpoint", }, @@ -120,6 +121,7 @@ describe( "Indexation", () => { amount: 5, restApi: { root: "https://example.com/", + // eslint-disable-next-line camelcase indexing_endpoints: { indexation: "indexing-endpoint", }, @@ -127,10 +129,9 @@ describe( "Indexation", () => { }, }; - global.fetch = jest.fn(); - global.fetch.mockImplementation( ( url ) => { + global.fetch = jest.fn().mockImplementation( ( url ) => { if ( url === "https://example.com/indexing-endpoint" ) { - return fetchReponse( { + return fetchResponse( { objects: [ {}, {}, {}, {}, {}, ], From 81ac612d4c9b543bbd4e0a6160738f273099cbb4 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 7 Apr 2022 11:15:36 +0200 Subject: [PATCH 03/14] Implement EsLint --- .eslintrc | 31 -------------- packages/js/.eslintrc.js | 83 +++++++++++++++++++++++++++++++++++++ packages/js/.gitignore | 7 ++++ packages/js/tests/.eslintrc | 6 --- 4 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 packages/js/.eslintrc.js create mode 100644 packages/js/.gitignore delete mode 100644 packages/js/tests/.eslintrc diff --git a/.eslintrc b/.eslintrc index 9f3fa887afd..a0fe42f751b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -28,37 +28,6 @@ overrides: jest: true rules: no-restricted-imports: "off" - - files: - - "packages/js/**/*.js" - rules: - # Custom rules: only for temporary exceptions that should be removed over time - camelcase: 1 - complexity: [ 1, 6 ] - brace-style: 1 - max-statements: 1 - no-shadow: 1 - require-jsdoc: 1 - react/jsx-no-bind: 1 - react/jsx-no-target-blank: 1 - react/no-access-state-in-setstate: 1 - react/no-deprecated: 1 - react/no-unused-prop-types: 1 - react/prop-types: 1 - react/require-default-props: 1 - no-restricted-imports: - - error - - name: react - message: Please use @wordpress/element instead. No need to import just for JSX. - - name: react-dom - message: Please use @wordpress/element instead. - - # Disabled rules - # In the editor, we're using the pragma `wp.element.createElement` - react/react-in-jsx-scope: 0 - - files: - - "packages/js/tests/**/*.js" - rules: - no-restricted-imports: 0 - files: - "packages/schema-blocks/src/**" env: diff --git a/packages/js/.eslintrc.js b/packages/js/.eslintrc.js new file mode 100644 index 00000000000..3b2bccccf09 --- /dev/null +++ b/packages/js/.eslintrc.js @@ -0,0 +1,83 @@ +module.exports = { + root: true, + "extends": [ + "yoast", + ], + settings: { + react: { + version: "detect", + }, + }, + parser: "@babel/eslint-parser", + parserOptions: { + ecmaVersion: 2019, + sourceType: "module", + }, + plugins: [ + "@babel", + "jest", + ], + env: { + "jest/globals": true, + }, + rules: { + "no-prototype-builtins": 0, + "comma-dangle": [ + "error", + { + arrays: "always-multiline", + objects: "always-multiline", + imports: "always-multiline", + exports: "always-multiline", + functions: "never", + }, + ], + }, + overrides: [ + { + files: [ "**/*.js" ], + rules: { + // Custom rules: only for temporary exceptions that should be removed over time + camelcase: 1, + complexity: [ 1, 6 ], + "brace-style": 1, + "max-statements": 1, + "no-shadow": 1, + "require-jsdoc": 1, + "react/jsx-no-bind": 1, + "react/jsx-no-target-blank": 1, + "react/no-access-state-in-setstate": 1, + "react/no-deprecated": 1, + "react/no-unused-prop-types": 1, + "react/prop-types": 1, + "react/require-default-props": 1, + "no-restricted-imports": [ + "error", + { + name: "react", + message: "Please use @wordpress/element instead. No need to import just for JSX.", + + }, + { + name: "react-dom", + message: "Please use @wordpress/element instead.", + }, + + ], + + // Disabled rules + // In the editor, we're using the pragma `wp.element.createElement` + "react/react-in-jsx-scope": 0, + }, + + }, + { + files: [ "tests/**/*.js" ], + rules: { + "no-restricted-imports": 0, + "no-undefined": 0, + "react/display-name": 0, + }, + }, + ], +}; diff --git a/packages/js/.gitignore b/packages/js/.gitignore new file mode 100644 index 00000000000..44a3cfc3a71 --- /dev/null +++ b/packages/js/.gitignore @@ -0,0 +1,7 @@ +# Editor +.vscode +.idea +# Dependencies +node_modules +# Artifacts +build diff --git a/packages/js/tests/.eslintrc b/packages/js/tests/.eslintrc deleted file mode 100644 index 7ff572ff746..00000000000 --- a/packages/js/tests/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -env: - jest: true - -rules: - react/display-name: 0 - no-undefined: 0 From 8005f946e2fff19b88ec0d341c77290584b50329 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 7 Apr 2022 11:17:09 +0200 Subject: [PATCH 04/14] Place browserlist in .rc file --- packages/js/.browserslistrc | 1 + packages/js/package.json | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 packages/js/.browserslistrc diff --git a/packages/js/.browserslistrc b/packages/js/.browserslistrc new file mode 100644 index 00000000000..f5e7f33bd6d --- /dev/null +++ b/packages/js/.browserslistrc @@ -0,0 +1 @@ +extends @yoast/browserslist-config diff --git a/packages/js/package.json b/packages/js/package.json index a3df8e91b73..10903abb981 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -53,8 +53,5 @@ "peerDependencies": { "react": "16.14.0", "react-dom": "16.14.0" - }, - "browserslist": [ - "extends @yoast/browserslist-config" - ] + } } From fd4e66bd3876c150ec57cd522eb7abcb8d750a6b Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 7 Apr 2022 11:19:56 +0200 Subject: [PATCH 05/14] Add devDependencies --- packages/js/package.json | 11 ++- packages/js/tests/indexation.test.js | 2 +- yarn.lock | 107 ++++++++++++++++++++++++++- 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index 10903abb981..5663f2c51e7 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,9 +1,13 @@ { "name": "@yoast/wordpress-seo", "version": "1.0.0", + "license": "GPL-3.0", "scripts": { "test": "jest -u", - "lint": "eslint src tests --max-warnings=149" + "lint": "eslint src tests --max-warnings=149", + "clean": "rm -rf build", + "build": "yarn clean && yarn build:js", + "build:js": "babel src --out-dir build" }, "dependencies": { "@draft-js-plugins/mention": "^5.0.0", @@ -43,11 +47,16 @@ }, "devDependencies": { "@babel/core": "^7.15.5", + "@babel/eslint-parser": "^7.17.0", + "@babel/eslint-plugin": "^7.17.7", "@wordpress/dependency-extraction-webpack-plugin": "^2.8.0", "@yoast/babel-preset": "^1.0.0", "@yoast/jest-preset": "^1.0.0", "babel-plugin-styled-components": "^2.0.6", "case-sensitive-paths-webpack-plugin": "^2.1.2", + "eslint": "^7.32.0", + "eslint-config-yoast": "^5.0.17", + "eslint-plugin-jest": "^26.1.3", "jest": "^27.5.1" }, "peerDependencies": { diff --git a/packages/js/tests/indexation.test.js b/packages/js/tests/indexation.test.js index 9362dce4751..cb79f9add71 100644 --- a/packages/js/tests/indexation.test.js +++ b/packages/js/tests/indexation.test.js @@ -79,7 +79,7 @@ describe( "Indexation", () => { method: "POST", } ); - const alert = await component.find( "Alert" ); + const alert = component.find( "Alert" ); expect( alert.text() ).toEqual( "SEO data optimization complete" ); expect( alert.prop( "type" ) ).toEqual( "success" ); } ); diff --git a/yarn.lock b/yarn.lock index 4c8b7fd6358..5c272c8733a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -225,6 +225,13 @@ dependencies: eslint-rule-composer "^0.3.0" +"@babel/eslint-plugin@^7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/eslint-plugin/-/eslint-plugin-7.17.7.tgz#4ee1d5b29b79130f3bb5a933358376bcbee172b8" + integrity sha512-JATUoJJXSgwI0T8juxWYtK1JSgoLpIGUsCHIv+NMXcUDA2vIe6nvAHR9vnuJgs/P1hOFw7vPwibixzfqBBLIVw== + dependencies: + eslint-rule-composer "^0.3.0" + "@babel/generator@^7.12.11", "@babel/generator@^7.12.5", "@babel/generator@^7.7.2": version "7.17.3" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.3.tgz#a2c30b0c4f89858cb87050c3ffdfd36bdf443200" @@ -4725,6 +4732,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== +"@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + "@types/json5@^0.0.29": version "0.0.29" resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" @@ -5178,6 +5190,14 @@ "@typescript-eslint/types" "4.24.0" "@typescript-eslint/visitor-keys" "4.24.0" +"@typescript-eslint/scope-manager@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.18.0.tgz#a7d7b49b973ba8cebf2a3710eefd457ef2fb5505" + integrity sha512-C0CZML6NyRDj+ZbMqh9FnPscg2PrzSaVQg3IpTmpe0NURMVBXlghGZgMYqBw07YW73i0MCqSDqv2SbywnCS8jQ== + dependencies: + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" + "@typescript-eslint/types@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.18.0.tgz#bebe323f81f2a7e2e320fac9415e60856267584a" @@ -5188,6 +5208,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.24.0.tgz#6d0cca2048cbda4e265e0c4db9c2a62aaad8228c" integrity sha512-tkZUBgDQKdvfs8L47LaqxojKDE+mIUmOzdz7r+u+U54l3GDkTpEbQ1Jp3cNqqAU9vMUCBA1fitsIhm7yN0vx9Q== +"@typescript-eslint/types@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.18.0.tgz#4f0425d85fdb863071680983853c59a62ce9566e" + integrity sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw== + "@typescript-eslint/typescript-estree@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.18.0.tgz#756d3e61da8c16ab99185532c44872f4cd5538cb" @@ -5214,6 +5239,31 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.18.0.tgz#6498e5ee69a32e82b6e18689e2f72e4060986474" + integrity sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ== + dependencies: + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" + debug "^4.3.2" + globby "^11.0.4" + is-glob "^4.0.3" + semver "^7.3.5" + tsutils "^3.21.0" + +"@typescript-eslint/utils@^5.10.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.18.0.tgz#27fc84cf95c1a96def0aae31684cb43a37e76855" + integrity sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA== + dependencies: + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/typescript-estree" "5.18.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + "@typescript-eslint/visitor-keys@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.18.0.tgz#4e6fe2a175ee33418318a029610845a81e2ff7b6" @@ -5230,6 +5280,14 @@ "@typescript-eslint/types" "4.24.0" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.18.0.tgz#c7c07709823804171d569017f3b031ced7253e60" + integrity sha512-Hf+t+dJsjAKpKSkg3EHvbtEpFFb/1CiOHnvI8bjHgOD4/wAw3gKrA0i94LrbekypiZVanJu3McWJg7rWDMzRTg== + dependencies: + "@typescript-eslint/types" "5.18.0" + eslint-visitor-keys "^3.0.0" + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" @@ -11421,6 +11479,13 @@ debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.6: dependencies: ms "^2.1.1" +debug@^4.3.2: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" @@ -12689,6 +12754,13 @@ eslint-plugin-jest@^24.1.3: dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" +eslint-plugin-jest@^26.1.3: + version "26.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.1.3.tgz#e722e5efeea18aa9dec7c7349987b641db19feb7" + integrity sha512-Pju+T7MFpo5VFhFlwrkK/9jRUu18r2iugvgyrWOnnGRaVTFFmFXp+xFJpHyqmjjLmGJPKLeEFLVTAxezkApcpQ== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-jsdoc@^30.7.13: version "30.7.13" resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.7.13.tgz#52e5c74fb806d3bbeb51d04a0c829508c3c6b563" @@ -12853,6 +12925,13 @@ eslint-utils@^2.0.0, eslint-utils@^2.1.0: dependencies: eslint-visitor-keys "^1.1.0" +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== + dependencies: + eslint-visitor-keys "^2.0.0" + eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" @@ -12868,6 +12947,11 @@ eslint-visitor-keys@^2.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== +eslint-visitor-keys@^3.0.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + eslint@^5.16.0: version "5.16.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" @@ -13482,7 +13566,7 @@ fast-glob@^3.1.1, fast-glob@^3.2.5: micromatch "^4.0.2" picomatch "^2.2.1" -fast-glob@^3.2.11: +fast-glob@^3.2.11, fast-glob@^3.2.9: version "3.2.11" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== @@ -14744,6 +14828,18 @@ globby@^11.0.0, globby@^11.0.1, globby@^11.0.2: merge2 "^1.3.0" slash "^3.0.0" +globby@^11.0.4: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -15880,6 +15976,11 @@ ignore@^5.1.4, ignore@^5.1.8, ignore@~5.1.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== + iltorb@^2.4.3: version "2.4.5" resolved "https://registry.yarnpkg.com/iltorb/-/iltorb-2.4.5.tgz#d64434b527099125c6839ed48b666247a172ef87" @@ -19950,7 +20051,7 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.2.3, merge2@^1.3.0: +merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== @@ -27603,7 +27704,7 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== -tsutils@^3.17.1: +tsutils@^3.17.1, tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== From 9ca4848a1063dcc2ef39fc042dab029a728907e2 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 7 Apr 2022 16:51:00 +0200 Subject: [PATCH 06/14] Make webpack pickup the transpiled code --- config/grunt/task-config/aliases.yaml | 2 + config/grunt/task-config/shell.js | 5 +++ config/webpack/paths.js | 64 +++++++++++++-------------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/config/grunt/task-config/aliases.yaml b/config/grunt/task-config/aliases.yaml index 0bf0677c992..db92f5c5f1a 100644 --- a/config/grunt/task-config/aliases.yaml +++ b/config/grunt/task-config/aliases.yaml @@ -27,6 +27,7 @@ 'build:js': - 'clean:build-assets-js' - 'copy:js-dependencies' + - 'shell:build-packages' - 'shell:webpack' # Build CSS for development @@ -110,6 +111,7 @@ release: - 'shell:install-schema-blocks' 'release:js': - 'copy:js-dependencies' + - 'shell:build-packages' - 'shell:webpack-prod' # Build CSS for production diff --git a/config/grunt/task-config/shell.js b/config/grunt/task-config/shell.js index 6228f0f46f7..323f5e19730 100644 --- a/config/grunt/task-config/shell.js +++ b/config/grunt/task-config/shell.js @@ -79,12 +79,17 @@ module.exports = function( grunt ) { callback: throwUncommittedChangesError, }, }, + "readme-reset-txt": { command: "git checkout readme.txt", options: { failOnError: false, }, }, + + "build-packages": { + command: "cd packages/js && yarn build", + }, }; /* eslint-enable require-jsdoc */ }; diff --git a/config/webpack/paths.js b/config/webpack/paths.js index 51b4236082d..bc30588ede6 100644 --- a/config/webpack/paths.js +++ b/config/webpack/paths.js @@ -6,38 +6,38 @@ const cssDistPath = path.resolve( "css", "dist" ); // Output filename: Entry file (relative to jsSrcPath) const entry = { - "addon-installation": "./packages/js/src/addon-installation.js", - "admin-global": "./packages/js/src/admin-global.js", - "admin-modules": "./packages/js/src/admin-modules.js", - "analysis-worker": "./packages/js/src/analysis-worker.js", - "api-client": "./packages/js/src/api-client.js", - "block-editor": "./packages/js/src/block-editor.js", - "bulk-editor": "./packages/js/src/bulk-editor.js", - "schema-blocks": "./packages/js/src/schema-blocks.js", - "classic-editor": "./packages/js/src/classic-editor.js", - "dashboard-widget": "./packages/js/src/dashboard-widget.js", - "dynamic-blocks": "./packages/js/src/dynamic-blocks.js", - "edit-page": "./packages/js/src/edit-page.js", - "editor-modules": "./packages/js/src/editor-modules.js", - elementor: "./packages/js/src/elementor.js", - "externals-components": "./packages/js/src/externals/components.js", - "externals-contexts": "./packages/js/src/externals/contexts.js", - "externals-redux": "./packages/js/src/externals/redux.js", - "filter-explanation": "./packages/js/src/filter-explanation.js", - "help-scout-beacon": "./packages/js/src/help-scout-beacon.js", - "import": "./packages/js/src/import.js", - indexation: "./packages/js/src/indexation.js", - "installation-success": "./packages/js/src/installation-success.js", - "network-admin": "./packages/js/src/network-admin.js", - "post-edit": "./packages/js/src/post-edit.js", - "quick-edit-handler": "./packages/js/src/quick-edit-handler.js", - "reindex-links": "./packages/js/src/reindex-links.js", - settings: "./packages/js/src/settings.js", - "structured-data-blocks": "./packages/js/src/structured-data-blocks.js", - "term-edit": "./packages/js/src/term-edit.js", - "used-keywords-assessment": "./packages/js/src/used-keywords-assessment.js", - "react-select": "./packages/js/src/externals/react-select.js", - workouts: "./packages/js/src/workouts.js", + "addon-installation": "./packages/js/build/addon-installation.js", + "admin-global": "./packages/js/build/admin-global.js", + "admin-modules": "./packages/js/build/admin-modules.js", + "analysis-worker": "./packages/js/build/analysis-worker.js", + "api-client": "./packages/js/build/api-client.js", + "block-editor": "./packages/js/build/block-editor.js", + "bulk-editor": "./packages/js/build/bulk-editor.js", + "schema-blocks": "./packages/js/build/schema-blocks.js", + "classic-editor": "./packages/js/build/classic-editor.js", + "dashboard-widget": "./packages/js/build/dashboard-widget.js", + "dynamic-blocks": "./packages/js/build/dynamic-blocks.js", + "edit-page": "./packages/js/build/edit-page.js", + "editor-modules": "./packages/js/build/editor-modules.js", + elementor: "./packages/js/build/elementor.js", + "externals-components": "./packages/js/build/externals/components.js", + "externals-contexts": "./packages/js/build/externals/contexts.js", + "externals-redux": "./packages/js/build/externals/redux.js", + "filter-explanation": "./packages/js/build/filter-explanation.js", + "help-scout-beacon": "./packages/js/build/help-scout-beacon.js", + "import": "./packages/js/build/import.js", + indexation: "./packages/js/build/indexation.js", + "installation-success": "./packages/js/build/installation-success.js", + "network-admin": "./packages/js/build/network-admin.js", + "post-edit": "./packages/js/build/post-edit.js", + "quick-edit-handler": "./packages/js/build/quick-edit-handler.js", + "reindex-links": "./packages/js/build/reindex-links.js", + settings: "./packages/js/build/settings.js", + "structured-data-blocks": "./packages/js/build/structured-data-blocks.js", + "term-edit": "./packages/js/build/term-edit.js", + "used-keywords-assessment": "./packages/js/build/used-keywords-assessment.js", + "react-select": "./packages/js/build/externals/react-select.js", + workouts: "./packages/js/build/workouts.js", }; /** From 366b31f5e9582421f1e1d85c2d92c183c49e952f Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Apr 2022 11:50:18 +0200 Subject: [PATCH 07/14] Uses build files only on production mode Removes unused exported variables --- config/grunt/task-config/aliases.yaml | 1 - config/webpack/paths.js | 84 ++++++++++++++------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/config/grunt/task-config/aliases.yaml b/config/grunt/task-config/aliases.yaml index db92f5c5f1a..5e38792b3c9 100644 --- a/config/grunt/task-config/aliases.yaml +++ b/config/grunt/task-config/aliases.yaml @@ -27,7 +27,6 @@ 'build:js': - 'clean:build-assets-js' - 'copy:js-dependencies' - - 'shell:build-packages' - 'shell:webpack' # Build CSS for development diff --git a/config/webpack/paths.js b/config/webpack/paths.js index bc30588ede6..42a9ac11cfe 100644 --- a/config/webpack/paths.js +++ b/config/webpack/paths.js @@ -1,43 +1,51 @@ const path = require( "path" ); const jsDistPath = path.resolve( "js", "dist" ); -const jsSrcPath = path.resolve( "packages", "js", "src" ); -const cssDistPath = path.resolve( "css", "dist" ); -// Output filename: Entry file (relative to jsSrcPath) -const entry = { - "addon-installation": "./packages/js/build/addon-installation.js", - "admin-global": "./packages/js/build/admin-global.js", - "admin-modules": "./packages/js/build/admin-modules.js", - "analysis-worker": "./packages/js/build/analysis-worker.js", - "api-client": "./packages/js/build/api-client.js", - "block-editor": "./packages/js/build/block-editor.js", - "bulk-editor": "./packages/js/build/bulk-editor.js", - "schema-blocks": "./packages/js/build/schema-blocks.js", - "classic-editor": "./packages/js/build/classic-editor.js", - "dashboard-widget": "./packages/js/build/dashboard-widget.js", - "dynamic-blocks": "./packages/js/build/dynamic-blocks.js", - "edit-page": "./packages/js/build/edit-page.js", - "editor-modules": "./packages/js/build/editor-modules.js", - elementor: "./packages/js/build/elementor.js", - "externals-components": "./packages/js/build/externals/components.js", - "externals-contexts": "./packages/js/build/externals/contexts.js", - "externals-redux": "./packages/js/build/externals/redux.js", - "filter-explanation": "./packages/js/build/filter-explanation.js", - "help-scout-beacon": "./packages/js/build/help-scout-beacon.js", - "import": "./packages/js/build/import.js", - indexation: "./packages/js/build/indexation.js", - "installation-success": "./packages/js/build/installation-success.js", - "network-admin": "./packages/js/build/network-admin.js", - "post-edit": "./packages/js/build/post-edit.js", - "quick-edit-handler": "./packages/js/build/quick-edit-handler.js", - "reindex-links": "./packages/js/build/reindex-links.js", - settings: "./packages/js/build/settings.js", - "structured-data-blocks": "./packages/js/build/structured-data-blocks.js", - "term-edit": "./packages/js/build/term-edit.js", - "used-keywords-assessment": "./packages/js/build/used-keywords-assessment.js", - "react-select": "./packages/js/build/externals/react-select.js", - workouts: "./packages/js/build/workouts.js", +/** + * Composes a list of entries based on the current NODE_ENV mode. + * + * @returns {object} A list of entries. + */ +const getEntries = () => { + const relevantDirectory = process.env.NODE_ENV === "production" ? "build" : "src"; + + const sourceDirectory = `./packages/js/${ relevantDirectory }`; + + return { + "addon-installation": sourceDirectory + "/addon-installation.js", + "admin-global": sourceDirectory + "/admin-global.js", + "admin-modules": sourceDirectory + "/admin-modules.js", + "analysis-worker": sourceDirectory + "/analysis-worker.js", + "api-client": sourceDirectory + "/api-client.js", + "block-editor": sourceDirectory + "/block-editor.js", + "bulk-editor": sourceDirectory + "/bulk-editor.js", + "schema-blocks": sourceDirectory + "/schema-blocks.js", + "classic-editor": sourceDirectory + "/classic-editor.js", + "dashboard-widget": sourceDirectory + "/dashboard-widget.js", + "dynamic-blocks": sourceDirectory + "/dynamic-blocks.js", + "edit-page": sourceDirectory + "/edit-page.js", + "editor-modules": sourceDirectory + "/editor-modules.js", + elementor: sourceDirectory + "/elementor.js", + "externals-components": sourceDirectory + "/externals/components.js", + "externals-contexts": sourceDirectory + "/externals/contexts.js", + "externals-redux": sourceDirectory + "/externals/redux.js", + "filter-explanation": sourceDirectory + "/filter-explanation.js", + "help-scout-beacon": sourceDirectory + "/help-scout-beacon.js", + "import": sourceDirectory + "/import.js", + indexation: sourceDirectory + "/indexation.js", + "installation-success": sourceDirectory + "/installation-success.js", + "network-admin": sourceDirectory + "/network-admin.js", + "post-edit": sourceDirectory + "/post-edit.js", + "quick-edit-handler": sourceDirectory + "/quick-edit-handler.js", + "reindex-links": sourceDirectory + "/reindex-links.js", + settings: sourceDirectory + "/settings.js", + "structured-data-blocks": sourceDirectory + "/structured-data-blocks.js", + "term-edit": sourceDirectory + "/term-edit.js", + "used-keywords-assessment": sourceDirectory + "/used-keywords-assessment.js", + "react-select": sourceDirectory + "/externals/react-select.js", + workouts: sourceDirectory + "/workouts.js", + }; }; /** @@ -57,10 +65,8 @@ function flattenVersionForFile( version ) { } module.exports = { - entry, + entry: getEntries(), jsDist: jsDistPath, - jsSrc: jsSrcPath, - cssDist: cssDistPath, select2: path.resolve( "node_modules", "select2", "dist" ), flattenVersionForFile, }; From c3e3a01c6c749d5985d1e12dca0590b7dc127016 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Apr 2022 12:30:24 +0200 Subject: [PATCH 08/14] Updates @babel/core to latest version --- packages/js/package.json | 2 +- yarn.lock | 105 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 99 insertions(+), 8 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index 5663f2c51e7..8ae827efeb2 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -46,7 +46,7 @@ "yoastseo": "^1.91.0" }, "devDependencies": { - "@babel/core": "^7.15.5", + "@babel/core": "^7.17.9", "@babel/eslint-parser": "^7.17.0", "@babel/eslint-plugin": "^7.17.7", "@wordpress/dependency-extraction-webpack-plugin": "^2.8.0", diff --git a/yarn.lock b/yarn.lock index 5c272c8733a..6b3d22182c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -188,6 +188,27 @@ json5 "^2.1.2" semver "^6.3.0" +"@babel/core@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.9.tgz#6bae81a06d95f4d0dec5bb9d74bbc1f58babdcfe" + integrity sha512-5ug+SfZCpDAkVp9SFIZAzlW18rlzsOcJGaetCjkySnrXXDUw9AR8cDUm1iByTmdWM6yxX6/zycaV76w3YTF2gw== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.17.9" + "@babel/helper-compilation-targets" "^7.17.7" + "@babel/helper-module-transforms" "^7.17.7" + "@babel/helpers" "^7.17.9" + "@babel/parser" "^7.17.9" + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.17.9" + "@babel/types" "^7.17.0" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" + "@babel/core@^7.7.2", "@babel/core@^7.8.0": version "7.17.5" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.5.tgz#6cd2e836058c28f06a4ca8ee7ed955bbf37c8225" @@ -259,6 +280,15 @@ jsesc "^2.5.1" source-map "^0.5.0" +"@babel/generator@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.9.tgz#f4af9fd38fa8de143c29fce3f71852406fc1e2fc" + integrity sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ== + dependencies: + "@babel/types" "^7.17.0" + jsesc "^2.5.1" + source-map "^0.5.0" + "@babel/helper-annotate-as-pure@^7.0.0", "@babel/helper-annotate-as-pure@^7.10.4", "@babel/helper-annotate-as-pure@^7.12.13": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.12.13.tgz#0f58e86dfc4bb3b1fcd7db806570e177d439b6ab" @@ -301,7 +331,7 @@ browserslist "^4.14.5" semver "^6.3.0" -"@babel/helper-compilation-targets@^7.16.7": +"@babel/helper-compilation-targets@^7.16.7", "@babel/helper-compilation-targets@^7.17.7": version "7.17.7" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz#a3c2924f5e5f0379b356d4cfb313d1414dc30e46" integrity sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w== @@ -411,6 +441,14 @@ "@babel/template" "^7.16.7" "@babel/types" "^7.16.7" +"@babel/helper-function-name@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz#136fcd54bc1da82fcb47565cf16fd8e444b1ff12" + integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== + dependencies: + "@babel/template" "^7.16.7" + "@babel/types" "^7.17.0" + "@babel/helper-get-function-arity@^7.12.13": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.13.tgz#bc63451d403a3b3082b97e1d8b3fe5bd4091e583" @@ -620,16 +658,16 @@ dependencies: "@babel/types" "^7.16.7" +"@babel/helper-validator-identifier@^7.10.4", "@babel/helper-validator-identifier@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" + integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== + "@babel/helper-validator-identifier@^7.12.11": version "7.12.11" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - "@babel/helper-validator-option@^7.12.17": version "7.12.17" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.17.tgz#d1fbf012e1a79b7eebbfdc6d270baaf8d9eb9831" @@ -668,6 +706,15 @@ "@babel/traverse" "^7.13.0" "@babel/types" "^7.13.0" +"@babel/helpers@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.17.9.tgz#b2af120821bfbe44f9907b1826e168e819375a1a" + integrity sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q== + dependencies: + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.17.9" + "@babel/types" "^7.17.0" + "@babel/highlight@^7.10.4", "@babel/highlight@^7.12.13": version "7.13.10" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.13.10.tgz#a8b2a66148f5b27d666b15d81774347a731d52d1" @@ -711,6 +758,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.0.tgz#f0ac33eddbe214e4105363bb17c3341c5ffcc43c" integrity sha512-VKXSCQx5D8S04ej+Dqsr1CzYvvWgf20jIw2D+YhQCrIlr2UZGaDds23Y0xg75/skOxpLCRpUZvk/1EAVkGoDOw== +"@babel/parser@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.9.tgz#9c94189a6062f0291418ca021077983058e171ef" + integrity sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg== + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050" @@ -1688,7 +1740,32 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.12.11", "@babel/types@^7.12.13", "@babel/types@^7.12.17", "@babel/types@^7.12.6", "@babel/types@^7.12.7", "@babel/types@^7.13.0", "@babel/types@^7.13.12", "@babel/types@^7.13.14", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.2.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.0": +"@babel/traverse@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" + integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.17.9" + "@babel/helper-environment-visitor" "^7.16.7" + "@babel/helper-function-name" "^7.17.9" + "@babel/helper-hoist-variables" "^7.16.7" + "@babel/helper-split-export-declaration" "^7.16.7" + "@babel/parser" "^7.17.9" + "@babel/types" "^7.17.0" + debug "^4.1.0" + globals "^11.1.0" + +"@babel/types@^7.0.0", "@babel/types@^7.3.0": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.4.tgz#bf482eaeaffb367a28abbf9357a94963235d90ed" + integrity sha512-WEkp8MsLftM7O/ty580wAmZzN1nDmCACc5+jFzUt+GUFNNIi3LdRlueYz0YIlmJhlZx1QYDMZL5vdWCL0fNjFQ== + dependencies: + esutils "^2.0.2" + lodash "^4.17.11" + to-fast-properties "^2.0.0" + +"@babel/types@^7.12.11", "@babel/types@^7.12.13", "@babel/types@^7.12.17", "@babel/types@^7.12.6", "@babel/types@^7.13.0", "@babel/types@^7.13.12", "@babel/types@^7.13.14", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.2.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b" integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw== @@ -1696,6 +1773,15 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" +"@babel/types@^7.12.7", "@babel/types@^7.3.3": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13" + integrity sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ== + dependencies: + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" + to-fast-properties "^2.0.0" + "@base2/pretty-print-object@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.1.tgz#371ba8be66d556812dc7fb169ebc3c08378f69d4" @@ -18797,6 +18883,11 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +json5@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" + integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + json@^11.0.0: version "11.0.0" resolved "https://registry.yarnpkg.com/json/-/json-11.0.0.tgz#2e84493134e2f42c131165aa22a124df38b3a3ee" From 0ec594e8c32b99f78a83605e1f7644d0b2812482 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Apr 2022 12:41:39 +0200 Subject: [PATCH 09/14] Adds peer dependencies from eslint-config-yoast --- packages/js/package.json | 4 +- yarn.lock | 125 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 119 insertions(+), 10 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index 8ae827efeb2..5b704f72499 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -4,7 +4,7 @@ "license": "GPL-3.0", "scripts": { "test": "jest -u", - "lint": "eslint src tests --max-warnings=149", + "lint": "eslint src tests --max-warnings=141", "clean": "rm -rf build", "build": "yarn clean && yarn build:js", "build:js": "babel src --out-dir build" @@ -57,6 +57,8 @@ "eslint": "^7.32.0", "eslint-config-yoast": "^5.0.17", "eslint-plugin-jest": "^26.1.3", + "eslint-plugin-jsx-a11y": "^6.5.1", + "eslint-plugin-react": "^7.29.4", "jest": "^27.5.1" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 6b3d22182c0..23f015eafb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1692,13 +1692,69 @@ dependencies: regenerator-runtime "^0.13.4" -"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.16.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" + integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g== + dependencies: + regenerator-runtime "^0.12.0" + +"@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" + integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== + dependencies: + regenerator-runtime "^0.13.4" + +"@babel/runtime@^7.11.2", "@babel/runtime@^7.13.10", "@babel/runtime@^7.8.4": + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d" + integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw== + dependencies: + regenerator-runtime "^0.13.4" + +"@babel/runtime@^7.16.0", "@babel/runtime@^7.9.2": version "7.17.8" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.8.tgz#3e56e4aff81befa55ac3ac6a0967349fd1c5bca2" integrity sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA== dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.16.3": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.9.tgz#d19fbf802d01a8cb6cf053a64e472d42c434ba72" + integrity sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg== + dependencies: + regenerator-runtime "^0.13.4" + +"@babel/runtime@^7.4.2": + version "7.4.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.2.tgz#f5ab6897320f16decd855eed70b705908a313fe8" + integrity sha512-7Bl2rALb7HpvXFL7TETNzKSAeBVCPHELzc0C//9FCxN8nsiueWSJBqaF+2oIJScyILStASR/Cx5WMkXGYTiJFA== + dependencies: + regenerator-runtime "^0.13.2" + +"@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.8.3.tgz#0811944f73a6c926bb2ad35e918dcc1bfab279f1" + integrity sha512-fVHx1rzEmwB130VTkLnxR+HmxcTjGzH12LYQcFFoBwakMd3aOMD4OsRN7tGG/UOYE2ektgFrS8uACAoRk1CY0w== + dependencies: + regenerator-runtime "^0.13.2" + +"@babel/runtime@^7.8.3": + version "7.14.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.0.tgz#46794bc20b612c5f75e62dd071e24dfd95f1cbe6" + integrity sha512-JELkvo/DlpNdJ7dlyw/eY7E0suy5i5GQH+Vlxaq1nsNJ+H7f4Vtv3jMeCEgRhZZQFXTjldYfQgv2qmM6M1v5wA== + dependencies: + regenerator-runtime "^0.13.4" + +"@babel/runtime@^7.8.7": + version "7.11.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736" + integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.12.13", "@babel/template@^7.12.7", "@babel/template@^7.16.7", "@babel/template@^7.3.3": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155" @@ -7783,7 +7839,7 @@ axe-core@^4.0.2: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.1.3.tgz#64a4c85509e0991f5168340edc4bedd1ceea6966" integrity sha512-vwPpH4Aj4122EW38mxO/fxhGKtwWTMLDIJfZ1He0Edbtjcfna/R3YB67yVhezUMzqc3Jr3+Ii50KRntlENL4xQ== -axe-core@^4.2.0, axe-core@^4.4.1: +axe-core@^4.2.0, axe-core@^4.3.5, axe-core@^4.4.1: version "4.4.1" resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413" integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw== @@ -11473,6 +11529,11 @@ damerau-levenshtein@^1.0.6: resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.6.tgz#143c1641cb3d85c60c32329e26899adea8701791" integrity sha512-JVrozIeElnj3QzfUIt8tB8YMluBJom4Vw9qTPpjGYQ9fYlB3D/rb6OordUxf3xeFB35LKWs0xqcO5U6ySvBtug== +damerau-levenshtein@^1.0.7: + version "1.0.8" + resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" + integrity sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA== + dargs@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-5.1.0.tgz#ec7ea50c78564cd36c9d5ec18f66329fade27829" @@ -12422,7 +12483,7 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emoji-regex@^9.0.0: +emoji-regex@^9.0.0, emoji-regex@^9.2.2: version "9.2.2" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== @@ -12877,6 +12938,24 @@ eslint-plugin-jsx-a11y@^6.1.1, eslint-plugin-jsx-a11y@^6.4.1: jsx-ast-utils "^3.1.0" language-tags "^1.0.5" +eslint-plugin-jsx-a11y@^6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.5.1.tgz#cdbf2df901040ca140b6ec14715c988889c2a6d8" + integrity sha512-sVCFKX9fllURnXT2JwLN5Qgo24Ug5NF6dxhkmxsMEUZhXRcGg+X3e1JbJ84YePQKBl5E0ZjAH5Q4rkdcGY99+g== + dependencies: + "@babel/runtime" "^7.16.3" + aria-query "^4.2.2" + array-includes "^3.1.4" + ast-types-flow "^0.0.7" + axe-core "^4.3.5" + axobject-query "^2.2.0" + damerau-levenshtein "^1.0.7" + emoji-regex "^9.2.2" + has "^1.0.3" + jsx-ast-utils "^3.2.1" + language-tags "^1.0.5" + minimatch "^3.0.4" + eslint-plugin-markdown@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.2.tgz#79274bf17ce3ead48e4a55cbcb6d7ce735754280" @@ -12953,6 +13032,26 @@ eslint-plugin-react@^7.26.0: semver "^6.3.0" string.prototype.matchall "^4.0.6" +eslint-plugin-react@^7.29.4: + version "7.29.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz#4717de5227f55f3801a5fd51a16a4fa22b5914d2" + integrity sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ== + dependencies: + array-includes "^3.1.4" + array.prototype.flatmap "^1.2.5" + doctrine "^2.1.0" + estraverse "^5.3.0" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.1.2" + object.entries "^1.1.5" + object.fromentries "^2.0.5" + object.hasown "^1.1.0" + object.values "^1.1.5" + prop-types "^15.8.1" + resolve "^2.0.0-next.3" + semver "^6.3.0" + string.prototype.matchall "^4.0.6" + eslint-plugin-yoast@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-yoast/-/eslint-plugin-yoast-1.0.1.tgz#86d4856149dc47d4cd85b750b91ec8f14124526a" @@ -18947,6 +19046,14 @@ jstimezonedetect@1.0.5: array-includes "^3.1.2" object.assign "^4.1.2" +jsx-ast-utils@^3.2.1: + version "3.2.2" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.2.tgz#6ab1e52c71dfc0c0707008a91729a9491fe9f76c" + integrity sha512-HDAyJ4MNQBboGpUnHAVUNJs6X0lh058s6FuixsFGP7MgJYpD6Vasd6nzSG5iIfXu1zAYlHJ/zsOKNlrenTUBnw== + dependencies: + array-includes "^3.1.4" + object.assign "^4.1.2" + junk@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/junk/-/junk-3.1.0.tgz#31499098d902b7e98c5d9b9c80f43457a88abfa1" @@ -20330,7 +20437,7 @@ minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" -minimatch@^3.0.2: +minimatch@^3.0.2, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -24846,16 +24953,16 @@ regenerator-runtime@^0.12.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== +regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.7: + version "0.13.9" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" + integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== + regenerator-runtime@^0.13.4: version "0.13.7" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== -regenerator-runtime@^0.13.7: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - regenerator-transform@^0.10.0: version "0.10.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" From 33c8035b7f5c258bda4c1c460288b67c31475016 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Apr 2022 12:49:17 +0200 Subject: [PATCH 10/14] Adds @yoast/browserslist-config as a dev dependency --- packages/js/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/js/package.json b/packages/js/package.json index 5b704f72499..fadae7c4e0e 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -51,6 +51,7 @@ "@babel/eslint-plugin": "^7.17.7", "@wordpress/dependency-extraction-webpack-plugin": "^2.8.0", "@yoast/babel-preset": "^1.0.0", + "@yoast/browserslist-config": "^1.2.2", "@yoast/jest-preset": "^1.0.0", "babel-plugin-styled-components": "^2.0.6", "case-sensitive-paths-webpack-plugin": "^2.1.2", From 628b117793e9e491d89f085e4cca57c88e8617af Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:36:01 +0200 Subject: [PATCH 11/14] Remove unused test --- packages/js/jest.config.js | 1 - packages/js/tests/edit.test.js | 74 ---------------------------------- 2 files changed, 75 deletions(-) delete mode 100644 packages/js/tests/edit.test.js diff --git a/packages/js/jest.config.js b/packages/js/jest.config.js index 19f9418e23f..e7c752949f9 100644 --- a/packages/js/jest.config.js +++ b/packages/js/jest.config.js @@ -2,7 +2,6 @@ module.exports = { preset: "@yoast/jest-preset", setupFilesAfterEnv: [ "/tests/setupTests.js" ], testPathIgnorePatterns: [ - "/tests/edit.test.js", "/tests/__mocks__/", "/tests/containers/mockSelectors.js", "/tests/helpers/factory.js", diff --git a/packages/js/tests/edit.test.js b/packages/js/tests/edit.test.js deleted file mode 100644 index 1a1f0d2ad20..00000000000 --- a/packages/js/tests/edit.test.js +++ /dev/null @@ -1,74 +0,0 @@ -import { initializeData } from "../src/initializers/edit.js"; -import ClassicEditorData from "../src/analysis/classicEditorData.js"; -import BlockEditorData from "../src/analysis/blockEditorData.js"; -import isBlockEditor from "../src/helpers/isBlockEditor"; - -jest.mock( "react-dom" ); -jest.mock( "../src/analysis/classicEditorData.js", () => { - return jest.fn().mockImplementation( () => { - return { - initialize: () => {}, - }; - } ); -} ); - -jest.mock( "../src/analysis/data.js", () => { - return jest.fn().mockImplementation( () => { - return { - initialize: () => {}, - }; - } ); -} ); - -jest.mock( "../src/helpers/isBlockEditor", () => { - return jest.fn(); -} ); - -describe( "initializeData", () => { - it( "initializes an instance of the Data class if Gutenberg data is available", () => { - window.wpseoScriptData.metabox = { - intl: { - locale: "en_EN", - }, - }; - isBlockEditor.mockImplementation( () => { - return true; - } ); - initializeData( {}, {}, {} ); - expect( BlockEditorData ).toHaveBeenCalledTimes( 1 ); - } ); -} ); - -describe( "initialize", () => { - it( "initializes all functionality on the edit screen", () => { - const combineReducers = jest.fn( ()=> { - return {}; - } ); - - const registerStore = jest.fn( () => { - return {}; - } ); - - window.yoast = { - _wp: { - data: { - combineReducers: combineReducers, - registerStore: registerStore, - }, - }, - }; - } ); - - it( "initializes an instance of the ClassicEditorData class if Gutenberg data is not available", () => { - window.wpseoScriptData.metabox = { - intl: { - locale: "en_EN", - }, - }; - isBlockEditor.mockImplementation( () => { - return false; - } ); - initializeData( {}, {}, {} ); - expect( ClassicEditorData ).toHaveBeenCalledTimes( 1 ); - } ); -} ); From 100bf1ebec25c90c280ce0e455b0ac575774f564 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:46:45 +0200 Subject: [PATCH 12/14] Change babel config in the root to to be our preset --- babel.config.js | 10 ++-------- package.json | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/babel.config.js b/babel.config.js index 15b942b4ae3..cdd562b0647 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,9 +1,3 @@ -module.exports = ( api ) => { - api.cache( true ); - - return { - presets: [ "@wordpress/babel-preset-default" ], - plugins: [ "@babel/plugin-transform-runtime" ], - sourceType: "unambiguous", - }; +module.exports = { + presets: [ "@yoast/babel-preset" ], }; diff --git a/package.json b/package.json index 810a698faf1..002bf85116e 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ }, "dependencies": {}, "devDependencies": { - "@babel/plugin-transform-runtime": "^7.13.10", "@lodder/grunt-postcss": "^3.1.1", "@slack/webhook": "^5.0.2", "@typescript-eslint/eslint-plugin": "^4.24.0", @@ -43,6 +42,7 @@ "@wordpress/dependency-extraction-webpack-plugin": "^3.1.0", "@wordpress/scripts": "^14.1.1", "@yoast/browserslist-config": "file:packages/browserslist-config", + "@yoast/babel-preset": "^1.0.0", "@yoast/grunt-plugin-tasks": "^2.3", "babel-plugin-dynamic-import-webpack": "^1.1.0", "colors": "1.4.0", From 3bdf460098e37ef5ba0a7e8311caa9fea69c2a0c Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:48:56 +0200 Subject: [PATCH 13/14] Use versions instead of file in our root File copies over at the time of install. Using a version makes it a symlink because of the workspace. That seems preferable, and a must if we work on the packages. --- package.json | 4 ++-- yarn.lock | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 002bf85116e..f93c0ca6182 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "@typescript-eslint/parser": "^4.24.0", "@wordpress/dependency-extraction-webpack-plugin": "^3.1.0", "@wordpress/scripts": "^14.1.1", - "@yoast/browserslist-config": "file:packages/browserslist-config", "@yoast/babel-preset": "^1.0.0", + "@yoast/browserslist-config": "^1.2.2", "@yoast/grunt-plugin-tasks": "^2.3", "babel-plugin-dynamic-import-webpack": "^1.1.0", "colors": "1.4.0", @@ -53,7 +53,7 @@ "enzyme-adapter-react-16": "^1.15.6", "enzyme-to-json": "^3.6.1", "eslint": "^7.32.0", - "eslint-config-yoast": "file:packages/eslint", + "eslint-config-yoast": "^5.0.17", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.22.0", "grunt-git": "^1.0.14", diff --git a/yarn.lock b/yarn.lock index 23f015eafb6..9c009719256 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6943,9 +6943,6 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== -"@yoast/browserslist-config@file:packages/browserslist-config": - version "1.2.2" - "@yoast/grunt-plugin-tasks@^2.3": version "2.3.0" resolved "https://registry.yarnpkg.com/@yoast/grunt-plugin-tasks/-/grunt-plugin-tasks-2.3.0.tgz#9dcefbd64fd3a301fbb9ab55307e1b48f232bbd9" @@ -12854,11 +12851,6 @@ eslint-config-prettier@^7.1.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-7.2.0.tgz#f4a4bd2832e810e8cc7c1411ec85b3e85c0c53f9" integrity sha512-rV4Qu0C3nfJKPOAhFujFxB7RMP+URFyQqqOZW9DMRD7ZDTFyjaIlETU3xzHELt++4ugC0+Jm084HQYkkJe+Ivg== -"eslint-config-yoast@file:packages/eslint": - version "5.0.17" - dependencies: - js-yaml "^3.6.0" - eslint-import-resolver-node@^0.3.4: version "0.3.4" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" From 607ac76c7af042a83ad5a86c08dfa8283c598a17 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:51:41 +0200 Subject: [PATCH 14/14] Undo standalone babel build of JS package After some discussion: no need to build this package by itself. We can rely on the root webpack build for production too. --- config/grunt/task-config/aliases.yaml | 1 - config/grunt/task-config/shell.js | 4 -- config/webpack/paths.js | 76 +++++++++++++-------------- packages/js/.gitignore | 3 +- packages/js/package.json | 6 +-- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/config/grunt/task-config/aliases.yaml b/config/grunt/task-config/aliases.yaml index 5e38792b3c9..0bf0677c992 100644 --- a/config/grunt/task-config/aliases.yaml +++ b/config/grunt/task-config/aliases.yaml @@ -110,7 +110,6 @@ release: - 'shell:install-schema-blocks' 'release:js': - 'copy:js-dependencies' - - 'shell:build-packages' - 'shell:webpack-prod' # Build CSS for production diff --git a/config/grunt/task-config/shell.js b/config/grunt/task-config/shell.js index 323f5e19730..3c4d5b51700 100644 --- a/config/grunt/task-config/shell.js +++ b/config/grunt/task-config/shell.js @@ -86,10 +86,6 @@ module.exports = function( grunt ) { failOnError: false, }, }, - - "build-packages": { - command: "cd packages/js && yarn build", - }, }; /* eslint-enable require-jsdoc */ }; diff --git a/config/webpack/paths.js b/config/webpack/paths.js index 42a9ac11cfe..231ca4ffe00 100644 --- a/config/webpack/paths.js +++ b/config/webpack/paths.js @@ -5,48 +5,44 @@ const jsDistPath = path.resolve( "js", "dist" ); /** * Composes a list of entries based on the current NODE_ENV mode. * + * @param {string} sourceDirectory The source path. + * * @returns {object} A list of entries. */ -const getEntries = () => { - const relevantDirectory = process.env.NODE_ENV === "production" ? "build" : "src"; - - const sourceDirectory = `./packages/js/${ relevantDirectory }`; - - return { - "addon-installation": sourceDirectory + "/addon-installation.js", - "admin-global": sourceDirectory + "/admin-global.js", - "admin-modules": sourceDirectory + "/admin-modules.js", - "analysis-worker": sourceDirectory + "/analysis-worker.js", - "api-client": sourceDirectory + "/api-client.js", - "block-editor": sourceDirectory + "/block-editor.js", - "bulk-editor": sourceDirectory + "/bulk-editor.js", - "schema-blocks": sourceDirectory + "/schema-blocks.js", - "classic-editor": sourceDirectory + "/classic-editor.js", - "dashboard-widget": sourceDirectory + "/dashboard-widget.js", - "dynamic-blocks": sourceDirectory + "/dynamic-blocks.js", - "edit-page": sourceDirectory + "/edit-page.js", - "editor-modules": sourceDirectory + "/editor-modules.js", - elementor: sourceDirectory + "/elementor.js", - "externals-components": sourceDirectory + "/externals/components.js", - "externals-contexts": sourceDirectory + "/externals/contexts.js", - "externals-redux": sourceDirectory + "/externals/redux.js", - "filter-explanation": sourceDirectory + "/filter-explanation.js", - "help-scout-beacon": sourceDirectory + "/help-scout-beacon.js", - "import": sourceDirectory + "/import.js", - indexation: sourceDirectory + "/indexation.js", - "installation-success": sourceDirectory + "/installation-success.js", - "network-admin": sourceDirectory + "/network-admin.js", - "post-edit": sourceDirectory + "/post-edit.js", - "quick-edit-handler": sourceDirectory + "/quick-edit-handler.js", - "reindex-links": sourceDirectory + "/reindex-links.js", - settings: sourceDirectory + "/settings.js", - "structured-data-blocks": sourceDirectory + "/structured-data-blocks.js", - "term-edit": sourceDirectory + "/term-edit.js", - "used-keywords-assessment": sourceDirectory + "/used-keywords-assessment.js", - "react-select": sourceDirectory + "/externals/react-select.js", - workouts: sourceDirectory + "/workouts.js", - }; -}; +const getEntries = ( sourceDirectory = "./packages/js/src" ) => ( { + "addon-installation": `${ sourceDirectory }/addon-installation.js`, + "admin-global": `${ sourceDirectory }/admin-global.js`, + "admin-modules": `${ sourceDirectory }/admin-modules.js`, + "analysis-worker": `${ sourceDirectory }/analysis-worker.js`, + "api-client": `${ sourceDirectory }/api-client.js`, + "block-editor": `${ sourceDirectory }/block-editor.js`, + "bulk-editor": `${ sourceDirectory }/bulk-editor.js`, + "schema-blocks": `${ sourceDirectory }/schema-blocks.js`, + "classic-editor": `${ sourceDirectory }/classic-editor.js`, + "dashboard-widget": `${ sourceDirectory }/dashboard-widget.js`, + "dynamic-blocks": `${ sourceDirectory }/dynamic-blocks.js`, + "edit-page": `${ sourceDirectory }/edit-page.js`, + "editor-modules": `${ sourceDirectory }/editor-modules.js`, + elementor: `${ sourceDirectory }/elementor.js`, + "externals-components": `${ sourceDirectory }/externals/components.js`, + "externals-contexts": `${ sourceDirectory }/externals/contexts.js`, + "externals-redux": `${ sourceDirectory }/externals/redux.js`, + "filter-explanation": `${ sourceDirectory }/filter-explanation.js`, + "help-scout-beacon": `${ sourceDirectory }/help-scout-beacon.js`, + "import": `${ sourceDirectory }/import.js`, + indexation: `${ sourceDirectory }/indexation.js`, + "installation-success": `${ sourceDirectory }/installation-success.js`, + "network-admin": `${ sourceDirectory }/network-admin.js`, + "post-edit": `${ sourceDirectory }/post-edit.js`, + "quick-edit-handler": `${ sourceDirectory }/quick-edit-handler.js`, + "reindex-links": `${ sourceDirectory }/reindex-links.js`, + settings: `${ sourceDirectory }/settings.js`, + "structured-data-blocks": `${ sourceDirectory }/structured-data-blocks.js`, + "term-edit": `${ sourceDirectory }/term-edit.js`, + "used-keywords-assessment": `${ sourceDirectory }/used-keywords-assessment.js`, + "react-select": `${ sourceDirectory }/externals/react-select.js`, + workouts: `${ sourceDirectory }/workouts.js`, +} ); /** * Flattens a version for usage in a filename. diff --git a/packages/js/.gitignore b/packages/js/.gitignore index 44a3cfc3a71..7fe84dd56d2 100644 --- a/packages/js/.gitignore +++ b/packages/js/.gitignore @@ -3,5 +3,4 @@ .idea # Dependencies node_modules -# Artifacts -build + diff --git a/packages/js/package.json b/packages/js/package.json index fadae7c4e0e..178daee9feb 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -2,12 +2,10 @@ "name": "@yoast/wordpress-seo", "version": "1.0.0", "license": "GPL-3.0", + "private": true, "scripts": { "test": "jest -u", - "lint": "eslint src tests --max-warnings=141", - "clean": "rm -rf build", - "build": "yarn clean && yarn build:js", - "build:js": "babel src --out-dir build" + "lint": "eslint src tests --max-warnings=141" }, "dependencies": { "@draft-js-plugins/mention": "^5.0.0",