From 82f8a56cba9cfd2ba078cdd9fd95400cd38eb08a Mon Sep 17 00:00:00 2001
From: Mark Florian <mflorian@gitlab.com>
Date: Mon, 25 Nov 2024 15:35:02 +0000
Subject: [PATCH] Allow import extensions in scripts

Rather than repeatedly disabling it, just allow it in scripts and
configuration files.
---
 config/helpers/vite_plugin_style.mjs   | 2 --
 eslint.config.mjs                      | 1 +
 scripts/frontend/build_css.mjs         | 2 --
 scripts/frontend/lib/compile_css.mjs   | 2 --
 scripts/frontend/tailwindcss.mjs       | 1 -
 scripts/frontend/webpack_dev_server.js | 4 ++--
 vite.config.js                         | 2 --
 7 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/config/helpers/vite_plugin_style.mjs b/config/helpers/vite_plugin_style.mjs
index b8eb8946bbaf..3df6294c72fa 100644
--- a/config/helpers/vite_plugin_style.mjs
+++ b/config/helpers/vite_plugin_style.mjs
@@ -1,11 +1,9 @@
 import path from 'node:path';
 import { fileURLToPath } from 'node:url';
-/* eslint-disable import/extensions */
 import {
   resolveCompilationTargetsForVite,
   resolveLoadPaths,
 } from '../../scripts/frontend/lib/compile_css.mjs';
-/* eslint-enable import/extensions */
 
 const ROOT_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../');
 
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 8b2a368cb687..a0117e19e67c 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -545,6 +545,7 @@ export default [
 
     rules: {
       '@gitlab/require-i18n-strings': 'off',
+      'import/extensions': 'off',
       'import/no-extraneous-dependencies': 'off',
       'import/no-commonjs': 'off',
       'import/no-nodejs-modules': 'off',
diff --git a/scripts/frontend/build_css.mjs b/scripts/frontend/build_css.mjs
index bc07362c3f95..9e786146f2c6 100755
--- a/scripts/frontend/build_css.mjs
+++ b/scripts/frontend/build_css.mjs
@@ -1,9 +1,7 @@
 #!/usr/bin/env node
 
 import process from 'node:process';
-/* eslint-disable import/extensions */
 import { compileAllStyles } from './lib/compile_css.mjs';
-/* eslint-enable import/extensions */
 
 const fileWatcher = await compileAllStyles({ shouldWatch: process.argv?.includes('--watch') });
 
diff --git a/scripts/frontend/lib/compile_css.mjs b/scripts/frontend/lib/compile_css.mjs
index 092bd2a3ba6a..021cc072bb34 100644
--- a/scripts/frontend/lib/compile_css.mjs
+++ b/scripts/frontend/lib/compile_css.mjs
@@ -7,13 +7,11 @@ import postcssCustomProperties from 'postcss-custom-properties';
 import postcssGlobalData from '@csstools/postcss-global-data';
 import { compile, Logger } from 'sass';
 import glob from 'glob';
-/* eslint-disable import/extensions */
 import tailwindcss from 'tailwindcss/lib/plugin.js';
 import tailwindConfig from '../../../config/tailwind.config.js';
 import IS_EE from '../../../config/helpers/is_ee_env.js';
 import IS_JH from '../../../config/helpers/is_jh_env.js';
 import { postCssColorToHex } from './postcss_color_to_hex.js';
-/* eslint-enable import/extensions */
 
 // Note, in node > 21.2 we could replace the below with import.meta.dirname
 const ROOT_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../');
diff --git a/scripts/frontend/tailwindcss.mjs b/scripts/frontend/tailwindcss.mjs
index 2ce7e43d5ffa..0d59d5e33d4d 100644
--- a/scripts/frontend/tailwindcss.mjs
+++ b/scripts/frontend/tailwindcss.mjs
@@ -1,4 +1,3 @@
-/* eslint-disable import/extensions */
 import path from 'node:path';
 import { fileURLToPath } from 'node:url';
 import { createProcessor } from 'tailwindcss/lib/cli/build/plugin.js';
diff --git a/scripts/frontend/webpack_dev_server.js b/scripts/frontend/webpack_dev_server.js
index fffae83b3083..d94de795caac 100755
--- a/scripts/frontend/webpack_dev_server.js
+++ b/scripts/frontend/webpack_dev_server.js
@@ -58,7 +58,7 @@ nodemon
       console.log('The JavaScript assets are recompiled only if they change');
       console.log('If you change them often, you might want to unset DEV_SERVER_STATIC');
     }
-    /* eslint-disable import/extensions, promise/catch-or-return */
+    /* eslint-disable promise/catch-or-return */
     import('./lib/compile_css.mjs').then(({ simplePluginForNodemon }) => {
       plugin = simplePluginForNodemon({ shouldWatch: !STATIC_MODE });
       return plugin?.start();
@@ -67,7 +67,7 @@ nodemon
       plugin = webpackTailwindCompilerPlugin({ shouldWatch: !STATIC_MODE });
       return plugin?.start();
     });
-    /* eslint-enable import/extensions, promise/catch-or-return */
+    /* eslint-enable promise/catch-or-return */
   })
   .on('quit', () => {
     console.log('Shutting down CSS compilation process');
diff --git a/vite.config.js b/vite.config.js
index ceb475eccc38..4ec0bcf09e7a 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -20,7 +20,6 @@ import {
   PDF_JS_CMAPS_V4_PUBLIC_PATH,
 } from './config/pdfjs.constants';
 
-/* eslint-disable import/extensions */
 import { viteTailwindCompilerPlugin } from './scripts/frontend/tailwindcss.mjs';
 import { CopyPlugin } from './config/helpers/vite_plugin_copy.mjs';
 import { AutoStopPlugin } from './config/helpers/vite_plugin_auto_stop.mjs';
@@ -29,7 +28,6 @@ import { FixedRubyPlugin } from './config/helpers/vite_plugin_ruby_fixed.mjs';
 import { StylePlugin } from './config/helpers/vite_plugin_style.mjs';
 import { IconsPlugin } from './config/helpers/vite_plugin_icons.mjs';
 import { ImagesPlugin } from './config/helpers/vite_plugin_images.mjs';
-/* eslint-enable import/extensions */
 
 let viteGDKConfig;
 try {
-- 
GitLab