diff --git a/config/webpack.config.js b/config/webpack.config.js index c4597031cd51422feaffbca4a7bfac4e3c8ce7c0..056b3a4d9d4518360430254a76ef85eee28ed444 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -744,6 +744,15 @@ module.exports = { 'app/assets/javascripts/vue_shared/components/empty_component.js', ); }), + !IS_EE && + !IS_JH && + new webpack.NormalModuleReplacementPlugin(/^jh_else_ee\/(.*)\.vue/, (resource) => { + // eslint-disable-next-line no-param-reassign + resource.request = path.join( + ROOT_PATH, + 'app/assets/javascripts/vue_shared/components/empty_component.js', + ); + }), new CopyWebpackPlugin({ patterns: copyFilesPatterns, diff --git a/eslint.config.mjs b/eslint.config.mjs index 21bc504e2644c583c8531ebbbfced54133f832db..f05f86f4b2c6bce416957af428e533cc9726a517 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,6 +1,7 @@ /* eslint-disable import/no-default-export */ import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { existsSync } from 'node:fs'; import localRules from 'eslint-plugin-local-rules'; import js from '@eslint/js'; import { FlatCompat } from '@eslint/eslintrc'; @@ -13,6 +14,23 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); +const extendConfigs = [ + 'plugin:@gitlab/default', + 'plugin:@gitlab/i18n', + 'plugin:no-jquery/slim', + 'plugin:no-jquery/deprecated-3.4', + 'plugin:no-unsanitized/recommended-legacy', + './tooling/eslint-config/conditionally_ignore.js', + 'plugin:@gitlab/jest', +]; + +// Allowing JiHu to add rules on their side since the update from +// eslintrc.yml to eslint.config.mjs is not allowing subdirectory +// rewrite. +if (existsSync(path.resolve(dirname, 'jh'))) { + extendConfigs.push('./jh/eslint.config.js'); +} + const jestConfig = { files: ['{,ee/}spec/frontend/**/*.js'], @@ -65,15 +83,7 @@ export default [ 'spec/fixtures/**/*.graphql', ], }, - ...compat.extends( - 'plugin:@gitlab/default', - 'plugin:@gitlab/i18n', - 'plugin:no-jquery/slim', - 'plugin:no-jquery/deprecated-3.4', - 'plugin:no-unsanitized/recommended-legacy', - './tooling/eslint-config/conditionally_ignore.js', - 'plugin:@gitlab/jest', - ), + ...compat.extends(...extendConfigs), ...compat.plugins('no-jquery', '@graphql-eslint'), { files: ['**/*.{js,vue}'], @@ -114,7 +124,7 @@ export default [ 'import/no-unresolved': [ 'error', { - ignore: ['^(ee|jh)_component/'], + ignore: ['^(ee|jh)_component/', '^jh_else_ee/'], }, ], diff --git a/jest.config.base.js b/jest.config.base.js index 7df9ce9d68e82cd9896fc360d462c3cc2ee2d09b..05e4d60f263b52116c64eec2be8f4bca8215e032 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -116,6 +116,8 @@ module.exports = (path, options = {}) => { '^shared_queries(/.*)$': '<rootDir>/app/graphql/queries$1', '^ee_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1', '^jh_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1', + '^jh_else_ee(/.*)$': + '<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js', '^any_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1', '^helpers(/.*)$': '<rootDir>/spec/frontend/__helpers__$1', '^vendor(/.*)$': '<rootDir>/vendor/assets/javascripts$1', diff --git a/storybook/config/webpack.config.js b/storybook/config/webpack.config.js index 31e40ac11357cda546299443d99f8d99339ce24c..8f8334503d2a120520cf52cb472299b1a475c081 100644 --- a/storybook/config/webpack.config.js +++ b/storybook/config/webpack.config.js @@ -199,6 +199,14 @@ module.exports = function storybookWebpackConfig({ config }) { ); } + if (!IS_EE && !IS_JH) { + config.plugins.push( + new webpack.NormalModuleReplacementPlugin(/^jh_else_ee\/(.*)\.vue/, (resource) => { + resource.request = EMPTY_VUE_COMPONENT_PATH; + }), + ); + } + const baseIntegrationTestHelpersPath = 'spec/frontend_integration/test_helpers'; // Add any missing aliases from the main GitLab webpack config diff --git a/vite.config.js b/vite.config.js index 3eaf09e24e15c668b68c57a6f7d8af00eb215a20..e71bf1ddb618ee303bfaf142599e367eebf5d0f7 100644 --- a/vite.config.js +++ b/vite.config.js @@ -59,6 +59,13 @@ const JH_ALIAS_FALLBACK = [ }, ]; +const JH_ELSE_EE_ALIAS_FALLBACK = [ + { + find: /^jh_else_ee\/(.*)\.vue/, + replacement: emptyComponent, + }, +]; + export default defineConfig({ cacheDir: path.resolve(__dirname, 'tmp/cache/vite'), resolve: { @@ -66,6 +73,7 @@ export default defineConfig({ ...aliasArr, ...(IS_EE ? [] : EE_ALIAS_FALLBACK), ...(IS_JH ? [] : JH_ALIAS_FALLBACK), + ...(!IS_EE && !IS_JH ? JH_ELSE_EE_ALIAS_FALLBACK : []), { find: '~/', replacement: javascriptsPath,