From a3ff60f6f64ffb9bd0ed340d2c5a154b2bf0e9fb Mon Sep 17 00:00:00 2001 From: Andrey Myssak Date: Mon, 29 May 2023 15:50:56 +0600 Subject: [PATCH] Remove import/no-unresolved from .eslintrc.js (#584) Co-authored-by: Sergey Myssak Signed-off-by: Andrey Myssak --- .eslintrc.js | 1 - src-docs/webpack.config.js | 223 ++++++++++++++++++------------------- 2 files changed, 107 insertions(+), 117 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b5a8302931..399cfdb234 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -108,7 +108,6 @@ module.exports = { plugins: ['jsx-a11y', 'prettier', 'local', 'react-hooks'], rules: { 'prefer-template': 'error', - 'import/no-unresolved': 'off', 'local/i18n': 'error', 'local/href-with-rel': 'error', 'local/forward-ref': 'error', diff --git a/src-docs/webpack.config.js b/src-docs/webpack.config.js index 6b54b6ff04..cd0ce58579 100644 --- a/src-docs/webpack.config.js +++ b/src-docs/webpack.config.js @@ -16,8 +16,6 @@ const babelConfig = require('./.babelrc.js'); // const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); -const getPort = require('get-port'); - const { NODE_ENV, CI, WEBPACK_SERVE } = process.env; const isDevelopment = WEBPACK_SERVE === 'true' && CI == null; @@ -40,133 +38,126 @@ function employCache(loaders) { return loaders; } -const webpackConfig = async () => { - const port = await getPort({ - port: getPort.makeRange(8030, 8130), - host: '0.0.0.0', - }); +const webpackConfig = { + mode: isProduction ? 'production' : 'development', - return { - mode: isProduction ? 'production' : 'development', + devtool: isProduction ? 'source-map' : 'cheap-module-source-map', - devtool: isProduction ? 'source-map' : 'cheap-module-source-map', + entry: { + bundle: './index.js', + }, - entry: { - bundle: './index.js', - }, + context: path.resolve(__dirname, 'src'), - context: path.resolve(__dirname, 'src'), + output: { + path: path.resolve(__dirname, '../docs'), + filename: `[name]${isProduction ? '.min' : ''}.js`, + }, - output: { - path: path.resolve(__dirname, '../docs'), - filename: `[name]${isProduction ? '.min' : ''}.js`, + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'], + fallback: { + fs: false, }, - - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - fallback: { - fs: false, - }, + }, + + resolveLoader: { + alias: { + 'prop-loader': path.resolve( + __dirname, + '../scripts/loaders/prop-loader.js' + ), }, + }, - resolveLoader: { - alias: { - 'prop-loader': path.resolve( - __dirname, - '../scripts/loaders/prop-loader.js' - ), + module: { + rules: [ + { + resourceQuery: /raw/, + type: 'asset/source', }, - }, - - module: { - rules: [ - { - resourceQuery: /raw/, - type: 'asset/source', - }, - { - test: /\.(js|tsx?)$/, - use: employCache([ - { - loader: 'babel-loader', - options: { babelrc: false, ...babelConfig }, - }, - ]), - exclude: [/node_modules/, /packages(\/|\\)react-datepicker/], - }, - { - test: /\.scss$/, - use: employCache([ - { - loader: 'style-loader', - options: { injectType: 'lazySingletonStyleTag' }, - }, - 'css-loader', - 'postcss-loader', - 'sass-loader', - ]), - exclude: /node_modules/, - }, - { - test: /\.css$/, - use: employCache(['style-loader', 'css-loader']), - exclude: /node_modules/, - }, - { - test: /\.(woff|woff2|ttf|eot|ico)(\?|$)/, - type: 'asset/resource', - }, - { - test: /\.(png|jp(e*)g|svg|gif)$/, - type: 'asset', - generator: { - filename: 'images/[contenthash]-[name].[ext]', + { + test: /\.(js|tsx?)$/, + use: employCache([ + { + loader: 'babel-loader', + options: { babelrc: false, ...babelConfig }, }, - parser: { - dataUrlCondition: { - maxSize: 8 * 1024, - }, + ]), + exclude: [/node_modules/, /packages(\/|\\)react-datepicker/], + }, + { + test: /\.scss$/, + use: employCache([ + { + loader: 'style-loader', + options: { injectType: 'lazySingletonStyleTag' }, }, - }, - ], - }, - - plugins: [ - new HtmlWebpackPlugin({ - template: 'index.html', - inject: 'body', - cache: true, - showErrors: true, - }), - - new CircularDependencyPlugin({ + 'css-loader', + 'postcss-loader', + 'sass-loader', + ]), exclude: /node_modules/, - failOnError: true, - }), - - new NodePolyfillPlugin(), - // run TypeScript during webpack build - // new ForkTsCheckerWebpackPlugin({ - // typescript: { configFile: path.resolve(__dirname, '..', 'tsconfig.json') }, - // async: false, // makes errors more visible, but potentially less performant - // }), - ], - - devServer: isDevelopment - ? { - static: { - directory: path.resolve(__dirname, 'build'), - // prevent file watching while running on CI - // /app/ represents the entire docker environment - watch: isPuppeteer ? { ignored: '**/*' } : undefined, + }, + { + test: /\.css$/, + use: employCache(['style-loader', 'css-loader']), + exclude: /node_modules/, + }, + { + test: /\.(woff|woff2|ttf|eot|ico)(\?|$)/, + type: 'asset/resource', + }, + { + test: /\.(png|jp(e*)g|svg|gif)$/, + type: 'asset', + generator: { + filename: 'images/[contenthash]-[name].[ext]', + }, + parser: { + dataUrlCondition: { + maxSize: 8 * 1024, }, - host: '0.0.0.0', - port, - allowedHosts: 'all', - historyApiFallback: true, - } - : undefined, - }; + }, + }, + ], + }, + + plugins: [ + new HtmlWebpackPlugin({ + template: 'index.html', + inject: 'body', + cache: true, + showErrors: true, + }), + + new CircularDependencyPlugin({ + exclude: /node_modules/, + failOnError: true, + }), + + new NodePolyfillPlugin(), + // run TypeScript during webpack build + // new ForkTsCheckerWebpackPlugin({ + // typescript: { configFile: path.resolve(__dirname, '..', 'tsconfig.json') }, + // async: false, // makes errors more visible, but potentially less performant + // }), + ], + + devServer: isDevelopment + ? { + static: { + directory: path.resolve(__dirname, 'build'), + // prevent file watching while running on CI + // /app/ represents the entire docker environment + watch: isPuppeteer ? { ignored: '**/*' } : undefined, + }, + host: '0.0.0.0', + port: 8030, + allowedHosts: 'all', + historyApiFallback: true, + } + : undefined, }; module.exports = webpackConfig;