Skip to content

Commit 517fd0a

Browse files
committed
fix: restore npm run dev
Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
1 parent c9c60db commit 517fd0a

File tree

6 files changed

+116
-77
lines changed

6 files changed

+116
-77
lines changed

eslint.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const pluginReact = require('eslint-plugin-react');
2+
const pluginJsxA11y = require('eslint-plugin-jsx-a11y');
3+
const pluginReactHooks = require('eslint-plugin-react-hooks');
4+
const globals = require('globals');
5+
6+
module.exports = [
7+
{
8+
files: ['src/**/*.{js,jsx}'],
9+
languageOptions: {
10+
ecmaVersion: 2020,
11+
sourceType: 'module',
12+
parserOptions: {
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
globals: {
18+
...globals.browser,
19+
...globals.node,
20+
...globals.mocha,
21+
...globals.es2020,
22+
},
23+
},
24+
settings: {
25+
react: {
26+
version: 'detect',
27+
},
28+
},
29+
plugins: {
30+
react: pluginReact,
31+
'jsx-a11y': pluginJsxA11y,
32+
'react-hooks': pluginReactHooks,
33+
},
34+
rules: {
35+
...pluginJsxA11y.configs.recommended.rules,
36+
'no-console': 'off',
37+
semi: 2,
38+
'no-undef': 2,
39+
'no-undef-init': 2,
40+
'no-tabs': 2,
41+
'react/self-closing-comp': 2,
42+
'react/no-typos': 2,
43+
'react/jsx-no-duplicate-props': 'warn',
44+
'react-hooks/rules-of-hooks': 'error',
45+
'react-hooks/exhaustive-deps': 'warn',
46+
'jsx-a11y/no-autofocus': [
47+
2,
48+
{
49+
ignoreNonDOM: true,
50+
},
51+
],
52+
},
53+
},
54+
];

examples/Router/index.js

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { createRoot } from 'react-dom/client';
3-
import { HashRouter as Router, Route, Switch, withRouter } from 'react-router-dom';
3+
import { HashRouter as Router, Route, Routes, useNavigate, useLocation } from 'react-router-dom';
44
import { withStyles } from 'tss-react/mui';
55
import ExamplesGrid from './ExamplesGrid';
66
import examples from '../examples';
@@ -17,58 +17,52 @@ const styles = {
1717
},
1818
};
1919

20-
class Examples extends React.Component {
21-
returnHome = () => {
22-
this.props.history.push('/');
23-
};
20+
function Examples({ classes }) {
21+
const navigate = useNavigate();
22+
const location = useLocation();
2423

25-
render() {
26-
const { classes } = this.props;
24+
const defaultTheme = createTheme();
25+
const returnHomeStyle = { padding: '0px', margin: '20px 0 20px 0' };
2726

28-
var returnHomeStyle = { padding: '0px', margin: '20px 0 20px 0' };
29-
30-
const defaultTheme = createTheme();
31-
32-
return (
33-
<ThemeProvider theme={defaultTheme}>
34-
<main className={classes.root}>
35-
<div className={classes.contentWrapper}>
36-
<Switch>
37-
<Route path="/" exact render={() => <ExamplesGrid examples={examples} />} />
38-
{Object.keys(examples).map((label, index) => (
39-
<Route
40-
key={index}
41-
path={`/${label.replace(/\s+/g, '-').toLowerCase()}`}
42-
exact
43-
component={examples[label]}
44-
/>
45-
))}
46-
</Switch>
47-
<div>
48-
{this.props.location.pathname !== '/' && (
49-
<div style={returnHomeStyle}>
50-
<Button color="primary" onClick={this.returnHome}>
51-
Back to Example Index
52-
</Button>
53-
</div>
54-
)}
55-
</div>
27+
return (
28+
<ThemeProvider theme={defaultTheme}>
29+
<main className={classes.root}>
30+
<div className={classes.contentWrapper}>
31+
<Routes>
32+
<Route path="/" element={<ExamplesGrid examples={examples} />} />
33+
{Object.keys(examples).map((label, index) => (
34+
<Route
35+
key={index}
36+
path={`/${label.replace(/\s+/g, '-').toLowerCase()}`}
37+
element={React.createElement(examples[label])}
38+
/>
39+
))}
40+
</Routes>
41+
<div>
42+
{location.pathname !== '/' && (
43+
<div style={returnHomeStyle}>
44+
<Button color="primary" onClick={() => navigate('/')}>
45+
Back to Example Index
46+
</Button>
47+
</div>
48+
)}
5649
</div>
57-
</main>
58-
</ThemeProvider>
59-
);
60-
}
50+
</div>
51+
</main>
52+
</ThemeProvider>
53+
);
6154
}
6255

63-
const StyledExamples = withRouter(withStyles(Examples, styles));
56+
const StyledExamples = withStyles(Examples, styles);
6457

6558
function App() {
6659
return (
67-
<Router hashType="noslash">
60+
<Router>
6861
<StyledExamples />
6962
</Router>
7063
);
7164
}
65+
7266
const container = document.getElementById('app-root');
7367
const root = createRoot(container);
7468
root.render(<App />);

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@
99
<div id="app-root">
1010
</div>
1111
</body>
12-
<script src="/bundle.js"></script>
1312
</html>
1413

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dist"
88
],
99
"scripts": {
10-
"dev": "cross-env NODE_ENV=development webpack-dev-server -d --progress --colors",
10+
"dev": "cross-env NODE_ENV=development webpack-dev-server --progress --color",
1111
"test": "cross-env NODE_ENV=test mocha --require ./test/babel-register.js --extensions js,jsx test/**/*.test.js",
1212
"docs:dev": "next docs",
1313
"docs:build": "cross-env NODE_ENV=production next build docs",
@@ -38,12 +38,13 @@
3838
"homepage": "https://github.com/layer5io/mui-datatables#readme",
3939
"devDependencies": {
4040
"@babel/core": "^7.29.0",
41+
"@babel/eslint-parser": "^7.27.1",
4142
"@babel/plugin-external-helpers": "^7.27.1",
43+
"@babel/plugin-transform-async-to-generator": "^7.28.6",
4244
"@babel/plugin-transform-class-properties": "^7.25.9",
4345
"@babel/plugin-transform-nullish-coalescing-operator": "^7.26.6",
4446
"@babel/plugin-transform-object-rest-spread": "^7.25.9",
4547
"@babel/plugin-transform-optional-chaining": "^7.25.9",
46-
"@babel/plugin-transform-async-to-generator": "^7.28.6",
4748
"@babel/plugin-transform-runtime": "^7.29.0",
4849
"@babel/preset-env": "^7.29.2",
4950
"@babel/preset-react": "^7.28.5",
@@ -58,7 +59,6 @@
5859
"@rollup/plugin-commonjs": "^29.0.2",
5960
"@rollup/plugin-node-resolve": "^16.0.3",
6061
"@rollup/plugin-replace": "^6.0.3",
61-
"@babel/eslint-parser": "^7.27.1",
6262
"babel-loader": "^10.1.1",
6363
"babel-plugin-istanbul": "^7.0.1",
6464
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
@@ -68,12 +68,13 @@
6868
"css-loader": "^7.1.4",
6969
"enzyme": "^3.11.0",
7070
"eslint": "^10.1.0",
71-
"eslint-webpack-plugin": "^5.0.3",
7271
"eslint-plugin-filenames": "^1.3.2",
7372
"eslint-plugin-import": "^2.32.0",
7473
"eslint-plugin-jsx-a11y": "^6.10.2",
7574
"eslint-plugin-react": "^7.37.5",
7675
"eslint-plugin-react-hooks": "^7.0.1",
76+
"eslint-webpack-plugin": "^5.0.3",
77+
"globals": "^17.4.0",
7778
"html-webpack-plugin": "^5.6.6",
7879
"ignore-styles": "^5.0.1",
7980
"jsdom": "^29.0.1",

webpack.config.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
const path = require('path');
22
const webpack = require('webpack');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
4-
const ESLintPlugin = require('eslint-webpack-plugin');
54

65
module.exports = {
6+
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
77
entry: {
88
app: ['core-js/stable', 'regenerator-runtime/runtime', './examples/Router/index.js'],
99
},
10-
stats: 'verbose',
10+
stats: 'errors-warnings',
1111
context: __dirname,
1212
output: {
1313
filename: 'bundle.js',
1414
},
1515
devtool: 'source-map',
16-
resolve: {
17-
mainFields: ['browser', 'module', 'main'],
18-
},
1916
devServer: {
20-
disableHostCheck: true,
17+
allowedHosts: 'all',
2118
host: 'localhost',
2219
hot: true,
23-
inline: true,
2420
port: process.env.PORT || 5050,
25-
stats: 'errors-warnings',
2621
},
2722
module: {
2823
rules: [
@@ -31,37 +26,19 @@ module.exports = {
3126
exclude: /node_modules/,
3227
use: ['babel-loader'],
3328
},
34-
{
35-
test: /\.(js|jsx)$/,
36-
include: /node_modules\/(@mui|@emotion)\//,
37-
use: {
38-
loader: 'babel-loader',
39-
options: {
40-
presets: [
41-
['@babel/preset-env', { modules: 'commonjs' }],
42-
'@babel/preset-react',
43-
],
44-
plugins: [
45-
'@babel/plugin-transform-optional-chaining',
46-
'@babel/plugin-transform-nullish-coalescing-operator',
47-
],
48-
},
49-
},
50-
},
5129
{
5230
test: /\.css$/i,
5331
use: ['style-loader', 'css-loader'],
5432
},
5533
],
5634
},
5735
plugins: [
58-
new ESLintPlugin({ extensions: ['js', 'jsx'] }),
59-
new webpack.HotModuleReplacementPlugin(),
60-
new webpack.NamedModulesPlugin(),
36+
new HtmlWebpackPlugin({
37+
template: './index.html',
38+
inject: true,
39+
}),
6140
new webpack.DefinePlugin({
62-
'process.env': {
63-
NODE_ENV: JSON.stringify('development'),
64-
},
41+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
6542
}),
6643
],
6744
};

0 commit comments

Comments
 (0)