From 2fb3e48f59dbdc3b388046b316d67067d3ec73dd Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Mon, 23 Aug 2021 12:11:37 -0400 Subject: [PATCH] build(dev,proxy): ent-3643 eslint webpack plugin (#761) --- .env.development | 3 --- config/build.plugins.js | 12 ++++++++++++ config/spandx.config.js | 2 +- package.json | 1 + yarn.lock | 13 ++++++++++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.env.development b/.env.development index 838cd0cd5..5d2cf16f3 100644 --- a/.env.development +++ b/.env.development @@ -3,9 +3,6 @@ DEV_BRANCH=ci-beta REACT_APP_ENV=development -REACT_APP_CONFIG_SERVICE_LOCALES=/locales/locales.json -REACT_APP_CONFIG_SERVICE_LOCALES_PATH=/locales/{{lng}}.json - REACT_APP_SERVICES_RHSM_VERSION=http://localhost:5000/api/rhsm-subscriptions/v1/version REACT_APP_SERVICES_RHSM_REPORT=http://localhost:5000/api/rhsm-subscriptions/v1/tally/products/ REACT_APP_SERVICES_RHSM_CAPACITY=http://localhost:5000/api/rhsm-subscriptions/v1/capacity/products/ diff --git a/config/build.plugins.js b/config/build.plugins.js index b2defe94b..1e2c7b7a5 100644 --- a/config/build.plugins.js +++ b/config/build.plugins.js @@ -1,6 +1,7 @@ const { join, resolve } = require('path'); const webpack = require('webpack'); const CopyPlugin = require('copy-webpack-plugin'); +const ESLintPlugin = require('eslint-webpack-plugin'); const fedModulePlugin = require('@redhat-cloud-services/frontend-components-config/federated-modules'); const { setupWebpackDotenvFilesForEnv } = require('./build.dotenv'); @@ -21,6 +22,7 @@ const setCommonPlugins = () => { const DIST_DIR = process.env._BUILD_DIST_DIR; const DOTENV_ENV = process.env.REACT_APP_ENV; const RELATIVE_DIRNAME = process.env._BUILD_RELATIVE_DIRNAME; + const SRC_DIR = process.env._BUILD_SRC_DIR; const STATIC_DIR = process.env._BUILD_STATIC_DIR; const plugins = [ @@ -31,6 +33,16 @@ const setCommonPlugins = () => { fedModulePlugin({ root: RELATIVE_DIRNAME }) ]; + // Development plugins + if (NODE_ENV === 'development' || NODE_ENV === 'review') { + plugins.push( + new ESLintPlugin({ + context: SRC_DIR, + failOnError: false + }) + ); + } + // Save 20kb of bundle size in prod if (NODE_ENV === 'production') { plugins.push(new webpack.NormalModuleReplacementPlugin(/redux-logger/, resolve(__dirname, './build.empty.js'))); diff --git a/config/spandx.config.js b/config/spandx.config.js index 9ee53488e..8b2c81554 100644 --- a/config/spandx.config.js +++ b/config/spandx.config.js @@ -6,7 +6,7 @@ * @param {string} params.BETA_PREFIX * @returns {object} */ -const setProxyRoutes = ({ DEV_PORT, BETA_PREFIX }) => ({ +const setProxyRoutes = ({ DEV_PORT, BETA_PREFIX = '' }) => ({ routes: { '/locales': { host: `https://localhost:${DEV_PORT}${BETA_PREFIX}/apps/subscriptions` diff --git a/package.json b/package.json index f3edca0c5..7f2ca66ed 100644 --- a/package.json +++ b/package.json @@ -139,6 +139,7 @@ "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.2.0", + "eslint-webpack-plugin": "^3.0.1", "express": "^4.17.1", "glob": "^7.1.7", "jest": "27.0.6", diff --git a/yarn.lock b/yarn.lock index c6495545e..1e548a252 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2080,7 +2080,7 @@ "@types/eslint" "*" "@types/estree" "*" -"@types/eslint@*": +"@types/eslint@*", "@types/eslint@^7.2.14": version "7.28.0" resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.28.0.tgz#7e41f2481d301c68e14f483fe10b017753ce8d5a" integrity sha512-07XlgzX0YJUn4iG1ocY4IX9DzKSmMGUs6ESKlxWhZRaa0fatIWaHWUVapcuGa8r5HFnTqzj+4OCjd5f7EZ/i/A== @@ -5188,6 +5188,17 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== +eslint-webpack-plugin@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-webpack-plugin/-/eslint-webpack-plugin-3.0.1.tgz#0990a80e9d5927e7e68365f93426cb340679e88c" + integrity sha512-PAHHDjCg2yWBNoiBPYLZWcv+M83urkslQKER7XvK84lo5YLcihJK6qwnCH2Fkt3eVdX+G1iyGZRlKsIhTiczHw== + dependencies: + "@types/eslint" "^7.2.14" + jest-worker "^27.0.6" + micromatch "^4.0.4" + normalize-path "^3.0.0" + schema-utils "^3.1.0" + eslint@7.32.0: version "7.32.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d"