* UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
146 lines
4.2 KiB
JavaScript
146 lines
4.2 KiB
JavaScript
const path = require('path');
|
|
|
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
|
|
const MONACO_DIR = path.resolve(__dirname, './node_modules/monaco-editor');
|
|
|
|
Object.defineProperty(RegExp.prototype, 'toJSON', {
|
|
value: RegExp.prototype.toString,
|
|
});
|
|
|
|
module.exports.getWebpackConfig = (config, options) => {
|
|
const cssLoader = config.module.rules.find((rule) => rule.test.toString() === '/\\.css$/');
|
|
|
|
cssLoader.exclude.push(/\.module\.css$/, MONACO_DIR);
|
|
|
|
const grafanaRules = config.module.rules.filter((a) => a.test.toString() !== /\.s[ac]ss$/.toString());
|
|
|
|
const newConfig = {
|
|
...config,
|
|
module: {
|
|
...config.module,
|
|
rules: [
|
|
...grafanaRules,
|
|
|
|
{
|
|
test: /\.(ts|tsx)$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
{
|
|
loader: 'babel-loader',
|
|
options: {
|
|
cacheDirectory: true,
|
|
cacheCompression: false,
|
|
presets: [
|
|
[
|
|
'@babel/preset-env',
|
|
{
|
|
modules: false,
|
|
},
|
|
],
|
|
[
|
|
'@babel/preset-typescript',
|
|
{
|
|
allowNamespaces: true,
|
|
allowDeclareFields: true,
|
|
},
|
|
],
|
|
['@babel/preset-react'],
|
|
],
|
|
plugins: [
|
|
[
|
|
'@babel/plugin-transform-typescript',
|
|
{
|
|
allowNamespaces: true,
|
|
allowDeclareFields: true,
|
|
},
|
|
],
|
|
'@babel/plugin-proposal-class-properties',
|
|
[
|
|
'@babel/plugin-proposal-object-rest-spread',
|
|
{
|
|
loose: true,
|
|
},
|
|
],
|
|
[
|
|
'@babel/plugin-proposal-decorators',
|
|
{
|
|
legacy: true,
|
|
},
|
|
],
|
|
'@babel/plugin-transform-react-constant-elements',
|
|
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
'@babel/plugin-proposal-optional-chaining',
|
|
'@babel/plugin-syntax-dynamic-import',
|
|
],
|
|
},
|
|
},
|
|
'ts-loader',
|
|
],
|
|
},
|
|
|
|
{
|
|
test: /\.module\.css$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
sourceMap: true,
|
|
modules: {
|
|
localIdentName: options.production ? '[name]__[hash:base64]' : '[path][name]__[local]',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
test: /\.module\.scss$/i,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
sourceMap: true,
|
|
modules: {
|
|
localIdentName: options.production ? '[name]__[hash:base64]' : '[path][name]__[local]',
|
|
},
|
|
},
|
|
},
|
|
'postcss-loader',
|
|
'sass-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
plugins: [
|
|
...config.plugins,
|
|
new CircularDependencyPlugin({
|
|
// exclude detection of files based on a RegExp
|
|
exclude: /node_modules/,
|
|
// include specific files based on a RegExp
|
|
// add errors to webpack instead of warnings
|
|
failOnError: true,
|
|
// allow import cycles that include an asyncronous import,
|
|
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
|
allowAsyncCycles: false,
|
|
// set the current working directory for displaying module paths
|
|
cwd: process.cwd(),
|
|
}),
|
|
],
|
|
|
|
resolve: {
|
|
...config.resolve,
|
|
symlinks: false,
|
|
modules: [path.resolve(__dirname, './frontend_enterprise/src'), ...config.resolve.modules],
|
|
},
|
|
};
|
|
|
|
return newConfig;
|
|
};
|