diff --git a/.babelrc b/.babelrc old mode 100644 new mode 100755 index 36c2acddf..9336f88bd --- a/.babelrc +++ b/.babelrc @@ -1,15 +1,15 @@ { "env": { "development": { - "presets" : ["env", "stage-1", "react"], - "plugins" : ["react-hot-loader/babel", ["transform-runtime", { "polyfill": false }]] + "presets" : ["@babel/preset-env", "@babel/preset-react", "@babel/preset-flow"], + "plugins" : ["@babel/plugin-transform-runtime", "@babel/plugin-transform-react-jsx"] }, "test": { - "presets" : ["env", "stage-1", "react"] + "presets" : ["@babel/preset-env", "@babel/preset-react", "@babel/preset-flow"] }, "production": { - "presets" : [["env", { "modules": false, "loose": true }], "stage-1", "react"], - "plugins" : [["transform-runtime", { "polyfill": false }]] + "presets" : ["@babel/preset-react", "@babel/preset-flow"], + "plugins" : ["@babel/plugin-transform-runtime", "@babel/plugin-transform-react-jsx"] } } } diff --git a/.eslintrc.json b/.eslintrc.json old mode 100644 new mode 100755 index ad8a97529..3af2caf78 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "root": true, - "parser": "babel-eslint", + "parser": "@babel/eslint-parser", "extends": [ "airbnb", "eslint:recommended", "plugin:flowtype/recommended" ], "plugins": [ "react", "jsx-a11y", "flowtype" ], "env": { @@ -40,6 +40,79 @@ "react/no-find-dom-node": 0, "react/no-unused-prop-types": 1, "react/forbid-prop-types": [1, { "forbid": ["array"] }], - "react/no-array-index-key": 0 + "react/no-array-index-key": 0, + "no-shadow": "off", + "consistent-return": "off", + "no-prototype-builtins": "off", + "prefer-const": "off", + "no-restricted-syntax": "off", + "prefer-destructuring": "off", + "no-mixed-operators": "off", + "arrow-parens": "off", + "array-callback-return": "off", + "max-classes-per-file": "off", + "no-use-before-define": "off", + "space-before-function-paren": "off", + "no-underscore-dangle": "off", + "no-plusplus": "off", + "default-param-last":"off", + "prefer-template": "off", + "no-param-reassign": "off", + "comma-dangle": "off", + "no-lonely-if": "off", + "no-else-return": "off", + "no-unused-expressions": "off", + "prefer-object-spread": "off", + "eol-last": "off", + "semi": "off", + "comma-spacing": "off", + "indent": "off", + "no-unreachable-loop": "off", + "no-trailing-spaces": "off", + "quotes": "off", + "no-return-assign": "off", + "max-len": "off", + "space-in-parens": "off", + "guard-for-in": "off", + "eqeqeq": "off", + "object-property-newline": "off", + "object-curly-newline": "off", + "vars-on-top": "off", + "no-var": "off", + "no-multiple-empty-lines":"off", + "template-curly-spacing":"off", + "object-curly-spacing":"off", + "operator-linebreak":"off", + "operator-assignment":"off", + "no-restricted-properties":"off", + "prefer-exponentiation-operator":"off", + "one-var-declaration-per-line":"off", + "curly":"off", + "nonblock-statement-body-position":"off", + "no-restricted-globals":"off", + "one-var": "off", + "spaced-comment": "off", + "react/static-property-placement": "off", + "space-before-blocks": "off", + "arrow-spacing": "off", + "no-multi-spaces": "off", + "quote-props": "off", + "key-spacing": "off", + "padded-blocks": "off", + "default-case": "off", + "no-confusing-arrow": "off", + "prefer-arrow-callback": "off", + "wrap-iife": "off", + "no-multi-assign": "off", + "camelcase": "off", + "space-infix-ops": "off", + "function-paren-newline": "off", + "no-bitwise": "off", + "no-tabs": "off", + "global-require": "off", + "react/no-unused-class-component-methods": "off", + "prefer-spread": "off", + "class-methods-use-this": "off", + "no-useless-constructor": "off" } } diff --git a/build/site/webpack.config.js b/build/site/webpack.config.js old mode 100644 new mode 100755 index cf2541cdd..98bca9135 --- a/build/site/webpack.config.js +++ b/build/site/webpack.config.js @@ -36,11 +36,13 @@ module.exports = { rules: [{ test: /\.jsx?$/, loader: 'babel-loader', + exclude: /node_modules/, include: [ path.join(basePath, 'site'), path.join(basePath, 'src'), path.join(basePath, 'libs') - ] + ], + options: { presets: ['@babel/preset-env','@babel/preset-react', '@babel/preset-flow'], plugins: ["@babel/plugin-transform-react-jsx"] } }, { test: /\.css$/, use: [MiniCssExtractPlugin.loader, "css-loader"] @@ -49,13 +51,13 @@ module.exports = { use: ['style-loader', 'css-loader', 'sass-loader'] }, { test: /\.(ttf|eot|svg|woff|woff2)(\?.+)?$/, - loader: 'file-loader?name=[hash:12].[ext]' + use: [{ loader: 'file-loader', options: { name:"[hash:12].[ext]" } }] }, { test: /\.(jpe?g|png|gif)(\?.+)?$/, - loader: 'url-loader?name=[hash:12].[ext]&limit=25000' + use: [{ loader: 'url-loader', options: { name: "[hash:12].[ext]", limit: 25000 } }] }, { test: /\.md$/, - loader: 'raw-loader' + use: [{ loader: 'raw-loader' }] }] }, mode: 'production' diff --git a/package.json b/package.json old mode 100644 new mode 100755 index d067a9f33..06f6ab3a7 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "jsnext:main": "next.js", "typings": "typings/index.d.ts", "scripts": { - "start": "cd site && node run.js", - "typescript-test": "tsc --lib es2015 --moduleResolution node --project typings/typing-tests", + "start": "cd site && webpack serve", + "typescript-test": "tsc --lib es2015,dom --moduleResolution node --project typings/typing-tests", "test": "flow check && BABEL_ENV=development jest", "jest": "jest", "lint": "eslint src libs site --quiet", @@ -32,57 +32,63 @@ }, "homepage": "https://github.com/ElemeFE/element-react", "devDependencies": { + "@babel/cli": "^7.20.7", + "@babel/core": "^7.20.12", + "@babel/plugin-transform-runtime": "^7.19.6", "@types/react": "^16.8.1", - "babel-cli": "^6.26.0", - "babel-core": "^6.26.3", - "babel-eslint": "^10.0.1", - "babel-jest": "^23.6.0", - "babel-loader": "^7.1.5", - "babel-plugin-transform-runtime": "^6.23.0", + "babel-jest": "^29.3.1", + "babel-loader": "^9.1.2", "babel-preset-env": "^1.7.0", "babel-preset-react": "^6.24.1", "babel-preset-stage-1": "^6.24.1", - "babel-runtime": "^6.26.0", "babel-standalone": "^6.26.0", "codemirror": "^5.43.0", "core-js": "^2.6.3", - "css-loader": "^2.1.0", + "css-loader": "^6.7.3", "element-theme-default": "^1.4.13", - "enzyme": "^3.8.0", - "enzyme-adapter-react-16": "^1.9.0", - "eslint": "^5.13.0", - "eslint-config-airbnb": "^17.1.0", - "eslint-plugin-flowtype": "^3.2.1", - "eslint-plugin-import": "^2.16.0", + "enzyme": "^3.11.0", + "enzyme-adapter-react-16": "^1.15.7", + "eslint": "^8.31.0", + "eslint-config-airbnb": "^19.0.4", + "eslint-plugin-flowtype": "^8.0.3", + "eslint-plugin-import": "^2.27.4", "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-react": "^7.12.4", - "file-loader": "^3.0.1", + "file-loader": "^6.2.0", "flow-bin": "^0.92.1", - "html-webpack-plugin": "^3.2.0", - "jest": "^23.6.0", + "html-webpack-plugin": "^5.5.0", + "jest": "^29.3.1", "marked": "^0.6.0", - "mini-css-extract-plugin": "^0.5.0", + "mini-css-extract-plugin": "^2.7.2", "mock-raf": "^1.0.1", - "node-sass": "^4.11.0", "prismjs": "^1.15.0", - "raw-loader": "^1.0.0", + "raw-loader": "^4.0.2", "react": "*", "react-dom": "*", - "react-hot-loader": "^4.6.5", + "react-hot-loader": "^4.13.1", "react-scroll-up": "^1.3.3", "regenerator-runtime": "^0.13.1", - "sass-loader": "^7.1.0", - "sinon": "^7.2.3", + "sass": "^1.22.10", + "sass-loader": "^13.2.0", + "sinon": "^15.0.1", "style-loader": "^0.23.1", - "typescript": "^3.3.1", - "url-loader": "^1.1.2", - "webpack": "^4.29.2", - "webpack-cli": "^3.2.3", - "webpack-dev-server": "^3.1.14" + "typescript": "^3.8.0", + "url-loader": "^4.1.1", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.1", + "webpack-dev-server": "^4.11.1" }, "dependencies": { + "@babel/eslint-parser": "^7.19.1", + "@babel/plugin-transform-react-jsx": "^7.20.7", + "@babel/preset-env": "^7.20.2", + "@babel/preset-flow": "^7.18.6", + "@babel/preset-react": "^7.18.6", + "@babel/preset-stage-1": "^7.8.3", + "@babel/runtime": "^7.20.7", "async-validator": "^1.10.1", "classnames": "^2.2.6", + "jest-environment-jsdom": "^29.3.1", "popper.js": "^1.14.7", "prop-types": "^15.6.2", "raf": "^3.4.1", @@ -95,6 +101,10 @@ "react-dom": "*" }, "jest": { + "testEnvironment": "jsdom", + "transform": { + "^.+\\.[t|j]sx?$": "babel-jest" + }, "testRegex": "(/jest/.+\\.(js|jsx)$)|_test.jsx?$", "testPathIgnorePatterns": [ "/tests", @@ -104,6 +114,8 @@ "\\.(png|eot|svg|ttf|woff|woff2)(\\?.+)?$": "/tests/jest/mock.js", "\\.(css|scss)$": "identity-obj-proxy" }, - "setupTestFrameworkScriptFile": "/tests/jest/config.js" + "setupFilesAfterEnv": [ + "/tests/jest/config.js" + ] } } diff --git a/site/pages/input/custom-item.jsx b/site/pages/input/custom-item.jsx old mode 100644 new mode 100755 index 436752e58..af096a5a9 --- a/site/pages/input/custom-item.jsx +++ b/site/pages/input/custom-item.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -class CustomItem extends React.Component { +export default class CustomItem extends React.Component { render() { return (
@@ -16,4 +16,4 @@ CustomItem.propTypes = { item: PropTypes.object }; -module.exports = CustomItem; + diff --git a/site/run.js b/site/webpack.config.js old mode 100644 new mode 100755 similarity index 52% rename from site/run.js rename to site/webpack.config.js index a8ac87278..7f9bd9d7c --- a/site/run.js +++ b/site/webpack.config.js @@ -1,23 +1,28 @@ /* eslint import/no-extraneous-dependencies: ["off"] */ const path = require('path'); -const webpack = require('webpack'); -const WebpackDevServer = require('webpack-dev-server'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); -new WebpackDevServer(webpack({ +module.exports = { devtool: 'eval', entry: [ - 'webpack-dev-server/client?http://localhost:3000', - 'webpack/hot/only-dev-server', - 'react-hot-loader/patch', './index' ], + devServer: { + port: 3000, + hot: 'only', + historyApiFallback: true, + }, output: { path: path.join(__dirname, 'dist'), - filename: 'bundle.js' + filename: 'bundle.js', + publicPath: "/" }, plugins: [ - new webpack.HotModuleReplacementPlugin() + new HtmlWebpackPlugin({ + template: './index.html', + favicon: path.join(__dirname, '/assets/favicon.ico') + }) ], resolve: { extensions: ['.js', '.jsx'] @@ -27,11 +32,16 @@ new WebpackDevServer(webpack({ { test: /\.jsx?$/, loader: 'babel-loader', + exclude: /node_modules/, include: [ path.join(__dirname, '../site'), path.join(__dirname, '../src'), path.join(__dirname, '../libs') - ] + ], + options: { + presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-flow'], + plugins: ["@babel/plugin-transform-runtime", "@babel/plugin-transform-react-jsx"] + } }, { test: /\.css$/, @@ -42,27 +52,18 @@ new WebpackDevServer(webpack({ use: ['style-loader', 'css-loader', 'sass-loader'] }, { - test: /\.(eot|svg|ttf|woff|woff2)(\?.+)?$/, - loader : 'file-loader' + test: /\.(ttf|eot|svg|woff|woff2)(\?.+)?$/, + use: [{ loader: 'file-loader' }] }, { test: /\.(jpe?g|png|gif)(\?.+)?$/, - loader : 'url-loader' + use: [{ loader: 'url-loader' }] }, { test: /\.md$/, - loader : 'raw-loader' + use: [{ loader: 'raw-loader' }] } ] }, mode: 'development' -}), { - publicPath: '/', - hot: true, - historyApiFallback: true, - stats: { colors: true } -}).listen(3000, 'localhost', error => { - if (error) { - throw error; - } -}); +}; diff --git a/typings/typing-tests/tsconfig.json b/typings/typing-tests/tsconfig.json old mode 100644 new mode 100755 index 0598d3e07..eaed9f59d --- a/typings/typing-tests/tsconfig.json +++ b/typings/typing-tests/tsconfig.json @@ -3,10 +3,18 @@ "compilerOptions": { "module": "es2015", "noEmit": true, - "jsx": "react" + "jsx": "react", + "types": [], + "lib":[] }, "include": [ "../index.d.ts", "." + ], + "exclude": [ + "node_modules", + "./node_modules", + "./node_modules/*", + "./node_modules/@types/node/index.d.ts", ] }