From 3a08a00f29af47c05e88c68bee2ed81170b834fa Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 29 Aug 2018 18:21:50 +0800 Subject: [PATCH] Add eslint-plugin-compat --- .babelrc.js | 21 --------------------- .eslintrc.js | 5 ++--- package.json | 3 +-- src/components/Authorized/Authorized.js | 12 ++++-------- src/pages/Exception/403.js | 25 +++++++++++-------------- src/pages/Exception/404.js | 25 +++++++++++-------------- src/pages/Exception/500.js | 25 +++++++++++-------------- 7 files changed, 40 insertions(+), 76 deletions(-) delete mode 100644 .babelrc.js diff --git a/.babelrc.js b/.babelrc.js deleted file mode 100644 index 20a0892b..00000000 --- a/.babelrc.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require('path'); - -module.exports = { - plugins: [ - [ - 'module-resolver', - { - alias: { - components: path.join(__dirname, './src/components'), - }, - }, - ], - [ - 'import', - { - libraryName: 'antd', - style: true, // or 'css' - }, - ], - ], -}; diff --git a/.eslintrc.js b/.eslintrc.js index 292b7e06..faa6a366 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { parser: 'babel-eslint', - extends: ['airbnb', 'prettier'], + extends: ['airbnb', 'prettier', 'plugin:compat/recommended'], env: { browser: true, node: true, @@ -13,7 +13,6 @@ module.exports = { 'react/jsx-filename-extension': [1, { extensions: ['.js'] }], 'react/jsx-wrap-multilines': 0, 'react/prop-types': 0, - 'react/prefer-stateless-function': 0, 'react/forbid-prop-types': 0, 'react/jsx-one-expression-per-line': 0, 'import/no-unresolved': 0, @@ -24,6 +23,6 @@ module.exports = { 'jsx-a11y/anchor-is-valid': 0, }, settings: { - polyfills: ['fetch', 'promises'], + polyfills: ['fetch', 'promises', 'url'], }, }; diff --git a/package.json b/package.json index 1ae0411f..83d09997 100755 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/react-dom": "^16.0.6", "antd-pro-merge-less": "^0.0.9", "antd-pro-theme-webpack-plugin": "^1.1.8", - "babel-eslint": "^9.0.0", + "babel-eslint": "^8.2.6", "cross-env": "^5.1.1", "cross-port-killer": "^1.0.1", "enzyme": "^3.4.4", @@ -59,7 +59,6 @@ "eslint-config-prettier": "^3.0.1", "eslint-plugin-babel": "^5.1.0", "eslint-plugin-compat": "^2.5.1", - "eslint-plugin-flowtype": "2.50.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-markdown": "^1.0.0-beta.6", diff --git a/src/components/Authorized/Authorized.js b/src/components/Authorized/Authorized.js index 8e7aacb2..75d57b88 100644 --- a/src/components/Authorized/Authorized.js +++ b/src/components/Authorized/Authorized.js @@ -1,12 +1,8 @@ -import React from 'react'; import CheckPermissions from './CheckPermissions'; -class Authorized extends React.Component { - render() { - const { children, authority, noMatch = null } = this.props; - const childrenRender = typeof children === 'undefined' ? null : children; - return CheckPermissions(authority, childrenRender, noMatch); - } -} +const Authorized = ({ children, authority, noMatch = null }) => { + const childrenRender = typeof children === 'undefined' ? null : children; + return CheckPermissions(authority, childrenRender, noMatch); +}; export default Authorized; diff --git a/src/pages/Exception/403.js b/src/pages/Exception/403.js index addd50eb..ab0341aa 100644 --- a/src/pages/Exception/403.js +++ b/src/pages/Exception/403.js @@ -1,19 +1,16 @@ -import React, { Component } from 'react'; +import React from 'react'; import { formatMessage } from 'umi/locale'; import Link from 'umi/link'; import Exception from '@/components/Exception'; -class Exception403 extends Component { - render() { - return ( - - ); - } -} +const Exception403 = () => ( + +); + export default Exception403; diff --git a/src/pages/Exception/404.js b/src/pages/Exception/404.js index 813632c9..50d5bd9b 100644 --- a/src/pages/Exception/404.js +++ b/src/pages/Exception/404.js @@ -1,19 +1,16 @@ -import React, { Component } from 'react'; +import React from 'react'; import { formatMessage } from 'umi/locale'; import Link from 'umi/link'; import Exception from '@/components/Exception'; -class Exception404 extends Component { - render() { - return ( - - ); - } -} +const Exception404 = () => ( + +); + export default Exception404; diff --git a/src/pages/Exception/500.js b/src/pages/Exception/500.js index 72d3679d..640f7a93 100644 --- a/src/pages/Exception/500.js +++ b/src/pages/Exception/500.js @@ -1,19 +1,16 @@ -import React, { Component } from 'react'; +import React from 'react'; import { formatMessage } from 'umi/locale'; import Link from 'umi/link'; import Exception from '@/components/Exception'; -class Exception500 extends Component { - render() { - return ( - - ); - } -} +const Exception500 = () => ( + +); + export default Exception500; -- GitLab