From 9494c7b1cbd2e7578bf2e237944bbee9c1836317 Mon Sep 17 00:00:00 2001 From: YASHMAHAKAL Date: Fri, 10 Apr 2026 01:44:12 +0530 Subject: [PATCH] fix Signed-off-by: YASHMAHAKAL --- .eslintrc | 66 -------- eslint.config.js | 173 ++++++++++++++++++++ examples/Router/ExamplesGrid.js | 4 +- examples/column-options-update/index.js | 8 +- examples/customize-toolbar/CustomToolbar.js | 2 +- examples/data-as-objects/index.js | 4 +- examples/selectable-rows/index.js | 2 +- examples/serverside-filters/index.js | 2 +- package.json | 2 +- webpack.config.js | 25 +-- 10 files changed, 186 insertions(+), 102 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index fbbfab1..0000000 --- a/.eslintrc +++ /dev/null @@ -1,66 +0,0 @@ -{ - "parser": "@babel/eslint-parser", - "settings": { - "react": { - "version": "latest" - }, - "import/extensions": [ - ".js" - ], - "import/parser": "@babel/eslint-parser", - "import/resolver": { - "node": { - "extensions": [ - ".js" - ] - }, - "webpack": { - "config": "webpack.config.js" - } - } - }, - "parserOptions": { - "requireConfigFile": false, - "ecmaVersion": 6, - "sourceType": "module", - "allowImportExportEverywhere": true, - "ecmaFeatures": { - "jsx": true, - "experimentalObjectRestSpread": true - } - }, - "env": { - "es6": true, - "browser": true, - "mocha": true, - "node": true - }, - "extends": [ - "plugin:jsx-a11y/recommended" - ], - "rules": { - "no-console": "off", - "semi": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-tabs": 2, - "react/self-closing-comp": 2, - "react/no-typos": 2, - "react/jsx-no-duplicate-props": "warn", - "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "warn", - "jsx-a11y/no-autofocus": [ - 2, - { - "ignoreNonDOM": true - } - ] - }, - "plugins": [ - "import", - "react", - "jsx-a11y", - "filenames", - "react-hooks" - ] -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..6b7f20d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,173 @@ +const reactPlugin = require('eslint-plugin-react'); +const reactHooksPlugin = require('eslint-plugin-react-hooks'); +const jsxA11yPlugin = require('eslint-plugin-jsx-a11y'); +const importPlugin = require('eslint-plugin-import'); +const filenamesPlugin = require('eslint-plugin-filenames'); + +const browserGlobals = { + window: 'readonly', + document: 'readonly', + navigator: 'readonly', + location: 'readonly', + history: 'readonly', + self: 'readonly', + globalThis: 'readonly', + console: 'readonly', + alert: 'readonly', + confirm: 'readonly', + prompt: 'readonly', + setTimeout: 'readonly', + setInterval: 'readonly', + clearTimeout: 'readonly', + clearInterval: 'readonly', + requestAnimationFrame: 'readonly', + cancelAnimationFrame: 'readonly', + fetch: 'readonly', + XMLHttpRequest: 'readonly', + localStorage: 'readonly', + sessionStorage: 'readonly', + URL: 'readonly', + URLSearchParams: 'readonly', + Blob: 'readonly', + File: 'readonly', + FileReader: 'readonly', + FormData: 'readonly', + event: 'readonly', + Event: 'readonly', + EventTarget: 'readonly', + CustomEvent: 'readonly', + MouseEvent: 'readonly', + KeyboardEvent: 'readonly', + HTMLElement: 'readonly', + HTMLInputElement: 'readonly', + HTMLSelectElement: 'readonly', + Element: 'readonly', + Node: 'readonly', + MutationObserver: 'readonly', + IntersectionObserver: 'readonly', + ResizeObserver: 'readonly', + Worker: 'readonly', + CSS: 'readonly', + performance: 'readonly', + crypto: 'readonly', + atob: 'readonly', + btoa: 'readonly', + getComputedStyle: 'readonly', +}; + +const nodeGlobals = { + process: 'readonly', + require: 'readonly', + module: 'writable', + exports: 'writable', + __dirname: 'readonly', + __filename: 'readonly', + global: 'readonly', + Buffer: 'readonly', + setImmediate: 'readonly', + clearImmediate: 'readonly', + queueMicrotask: 'readonly', +}; + +const es6Globals = { + Promise: 'readonly', + Symbol: 'readonly', + Map: 'readonly', + Set: 'readonly', + WeakMap: 'readonly', + WeakSet: 'readonly', + WeakRef: 'readonly', + Proxy: 'readonly', + Reflect: 'readonly', + ArrayBuffer: 'readonly', + DataView: 'readonly', + SharedArrayBuffer: 'readonly', + Atomics: 'readonly', + BigInt: 'readonly', + Int8Array: 'readonly', + Uint8Array: 'readonly', + Uint8ClampedArray: 'readonly', + Int16Array: 'readonly', + Uint16Array: 'readonly', + Int32Array: 'readonly', + Uint32Array: 'readonly', + Float32Array: 'readonly', + Float64Array: 'readonly', + BigInt64Array: 'readonly', + BigUint64Array: 'readonly', +}; + +const mochaGlobals = { + describe: 'readonly', + it: 'readonly', + before: 'readonly', + after: 'readonly', + beforeEach: 'readonly', + afterEach: 'readonly', + context: 'readonly', + specify: 'readonly', + suite: 'readonly', + test: 'readonly', + suiteSetup: 'readonly', + suiteTeardown: 'readonly', + setup: 'readonly', + teardown: 'readonly', + run: 'readonly', + mocha: 'readonly', +}; + +module.exports = [ + { + files: ['**/*.js', '**/*.jsx'], + plugins: { + react: reactPlugin, + 'react-hooks': reactHooksPlugin, + 'jsx-a11y': jsxA11yPlugin, + import: importPlugin, + filenames: filenamesPlugin, + }, + languageOptions: { + ecmaVersion: 2022, + sourceType: 'module', + parserOptions: { + allowImportExportEverywhere: true, + ecmaFeatures: { + jsx: true, + }, + }, + globals: { + ...browserGlobals, + ...nodeGlobals, + ...es6Globals, + ...mochaGlobals, + }, + }, + settings: { + react: { + version: 'detect', + }, + 'import/extensions': ['.js'], + 'import/resolver': { + node: { + extensions: ['.js'], + }, + webpack: { + config: 'webpack.config.js', + }, + }, + }, + rules: { + ...jsxA11yPlugin.flatConfigs.recommended.rules, + 'jsx-a11y/no-autofocus': [2, { ignoreNonDOM: true }], + 'no-console': 'off', + semi: 2, + 'no-undef': 2, + 'no-undef-init': 2, + 'no-tabs': 2, + 'react/self-closing-comp': 2, + 'react/jsx-no-duplicate-props': 'warn', + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + }, + }, +]; diff --git a/examples/Router/ExamplesGrid.js b/examples/Router/ExamplesGrid.js index 440a824..4aa00f3 100644 --- a/examples/Router/ExamplesGrid.js +++ b/examples/Router/ExamplesGrid.js @@ -35,13 +35,13 @@ class ExamplesGrid extends React.Component { state = { searchVal: '' - } + }; setSearchVal = (val) => { this.setState({ searchVal: val }); - } + }; render() { const {classes} = this.props; diff --git a/examples/column-options-update/index.js b/examples/column-options-update/index.js index 14b0e78..dfaa5d8 100644 --- a/examples/column-options-update/index.js +++ b/examples/column-options-update/index.js @@ -46,22 +46,22 @@ class Example extends React.Component { ["Gabby Strickland", "Business Process Consultant", "Scottsdale", 26, 45000], ["Mason Ray", "Computer Scientist", "San Francisco", 39, 142000] ] - } + }; handleFilterNameChange = (event) => { let string = prompt("Write a semicolon-separated string to change filter names in the first column!"); if (string) this.setState({ filterOptions: string.split(';') }); - } + }; handleAddData = (event) => { const string = prompt("Write a semicolon-separated string with values for 'Name', 'Title', 'Location', 'Age' and 'Salary' to add a new row of data!"); if (string) this.setState({ data: [string.split(';'), ...this.state.data] }); - } + }; handleChangeDisplay = (event) => { const string = prompt("Write a semicolon-separated string of display options for each of the 5 columns. Options are either 'true', 'false', or 'excluded'"); if (string) this.setState({ display: string.split(';') }); - } + }; render() { const { data, filterList, filterOptions } = this.state; diff --git a/examples/customize-toolbar/CustomToolbar.js b/examples/customize-toolbar/CustomToolbar.js index 4db705c..c978357 100644 --- a/examples/customize-toolbar/CustomToolbar.js +++ b/examples/customize-toolbar/CustomToolbar.js @@ -11,7 +11,7 @@ class CustomToolbar extends React.Component { handleClick = () => { console.log("clicked on icon!"); - } + }; render() { const { classes } = this.props; diff --git a/examples/data-as-objects/index.js b/examples/data-as-objects/index.js index c94fe78..2b341ee 100644 --- a/examples/data-as-objects/index.js +++ b/examples/data-as-objects/index.js @@ -12,13 +12,13 @@ class Example extends React.Component { { name: "Jaden Collins", title: "Attorney", location: "Santa Ana", age: 27, salary: "$500,000", phone: { home: '867-5311', cell: '123-4569' } }, { name: "Franky Rees", title: "Business Analyst", location: "St. Petersburg", age: 22, salary: "$50,000", phone: { home: '867-5312', cell: '123-4569' } } ] - } + }; rerender = () => { this.setState((prevState, props) => ({ counter: prevState.counter + 1 })); - } + }; render() { diff --git a/examples/selectable-rows/index.js b/examples/selectable-rows/index.js index dfc271b..af45b17 100644 --- a/examples/selectable-rows/index.js +++ b/examples/selectable-rows/index.js @@ -46,7 +46,7 @@ class Example extends React.Component { this.setState({ selectableRowsHideCheckboxes: event.target.checked }); - } + }; render() { diff --git a/examples/serverside-filters/index.js b/examples/serverside-filters/index.js index 3e8e781..a30f0f0 100644 --- a/examples/serverside-filters/index.js +++ b/examples/serverside-filters/index.js @@ -77,7 +77,7 @@ class Example extends React.Component { 2000 ); }); - } + }; handleFilterSubmit = applyFilters => { let filterList = applyFilters(); diff --git a/package.json b/package.json index 09ea57a..4c87d59 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dist" ], "scripts": { - "dev": "cross-env NODE_ENV=development webpack-dev-server -d --progress --colors", + "dev": "cross-env NODE_ENV=development webpack-dev-server --progress --color", "test": "cross-env NODE_ENV=test mocha --require ./test/babel-register.js --extensions js,jsx test/**/*.test.js", "docs:dev": "next docs", "docs:build": "cross-env NODE_ENV=production next build docs", diff --git a/webpack.config.js b/webpack.config.js index fec9b0f..5cf87c9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,4 @@ -const path = require('path'); const webpack = require('webpack'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); const ESLintPlugin = require('eslint-webpack-plugin'); module.exports = { @@ -17,12 +15,10 @@ module.exports = { mainFields: ['browser', 'module', 'main'], }, devServer: { - disableHostCheck: true, + allowedHosts: 'all', host: 'localhost', hot: true, - inline: true, port: process.env.PORT || 5050, - stats: 'errors-warnings', }, module: { rules: [ @@ -31,23 +27,6 @@ module.exports = { exclude: /node_modules/, use: ['babel-loader'], }, - { - test: /\.(js|jsx)$/, - include: /node_modules\/(@mui|@emotion)\//, - use: { - loader: 'babel-loader', - options: { - presets: [ - ['@babel/preset-env', { modules: 'commonjs' }], - '@babel/preset-react', - ], - plugins: [ - '@babel/plugin-transform-optional-chaining', - '@babel/plugin-transform-nullish-coalescing-operator', - ], - }, - }, - }, { test: /\.css$/i, use: ['style-loader', 'css-loader'], @@ -56,8 +35,6 @@ module.exports = { }, plugins: [ new ESLintPlugin({ extensions: ['js', 'jsx'] }), - new webpack.HotModuleReplacementPlugin(), - new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('development'),