diff --git a/.eslintrc.yml b/.eslintrc.yml index 545c610..c5b772a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -18,6 +18,8 @@ extends: - plugin:import/errors - plugin:react/recommended +settings: + import/resolver: webpack # globals: # Promise: true diff --git a/package.json b/package.json index db8ae7b..a82ad8f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "css-loader": "^1.0.0", "cssnano": "^4.1.5", "eslint": "^5.7.0", + "eslint-import-resolver-webpack": "^0.10.1", "eslint-plugin-import": "2.14.0", "eslint-plugin-jest": "^21.25.1", "eslint-plugin-react": "7.11.1", diff --git a/src/api/configs.js b/src/api/configs.js index e3cbebc..0690221 100644 --- a/src/api/configs.js +++ b/src/api/configs.js @@ -1,5 +1,3 @@ -'use strict'; - import { getAPIConfig, genCommonHeaders, diff --git a/src/api/logs.js b/src/api/logs.js index f158830..0ef2a1e 100644 --- a/src/api/logs.js +++ b/src/api/logs.js @@ -1,5 +1,3 @@ -'use strict'; - const textDecoder = new TextDecoder('utf-8'); import { getAPIConfig, @@ -44,8 +42,6 @@ function pump(reader) { return; } const t = textDecoder.decode(value); - // console.log(t); - const l = t[t.length - 1]; let o; try { o = JSON.parse(t); diff --git a/src/api/proxies.js b/src/api/proxies.js index 60a8f7f..592a38b 100644 --- a/src/api/proxies.js +++ b/src/api/proxies.js @@ -1,5 +1,3 @@ -'use strict'; - import { getAPIConfig, genCommonHeaders, @@ -53,7 +51,7 @@ async function requestToSwitchProxy(name1, name2) { async function requestDelayForProxy(name) { const { url, init } = getURLAndInit(); - const qs = `timeout=5000&url=http://www.google.com/generate_204`; + const qs = 'timeout=5000&url=http://www.google.com/generate_204'; const fullURL = `${url}/${name}/delay?${qs}`; return await fetch(fullURL, init); } diff --git a/src/api/traffic.js b/src/api/traffic.js index 2eca663..7bedf1b 100644 --- a/src/api/traffic.js +++ b/src/api/traffic.js @@ -1,5 +1,3 @@ -'use strict'; - const textDecoder = new TextDecoder('utf-8'); import { getAPIConfig, diff --git a/src/components/APIConfig.js b/src/components/APIConfig.js index a8275ff..ce2b7fe 100644 --- a/src/components/APIConfig.js +++ b/src/components/APIConfig.js @@ -46,7 +46,7 @@ class APIConfig extends Component { this.setState({ [name]: value }); }; - handleConfirmOnClick = e => { + handleConfirmOnClick = () => { const { hostname, port, secret } = this.state; this.props.updateClashAPIConfig({ hostname, port, secret }); }; diff --git a/src/components/APIDiscovery.js b/src/components/APIDiscovery.js index 4aa5fae..dc92976 100644 --- a/src/components/APIDiscovery.js +++ b/src/components/APIDiscovery.js @@ -22,10 +22,11 @@ const mapDispatchToProps = dispatch => { }; class APIDiscovery extends Component { - // static propTypes = { - // isOpen: PropTypes.bool.isRequired, - // onRequestClose: PropTypes.func.isRequired - // }; + static propTypes = { + closeModal: PropTypes.func, + fetchConfigs: PropTypes.func, + modals: PropTypes.object + }; componentDidMount() { this.props.fetchConfigs(); diff --git a/src/components/Proxy.js b/src/components/Proxy.js index a39da57..b3d071b 100644 --- a/src/components/Proxy.js +++ b/src/components/Proxy.js @@ -36,14 +36,14 @@ class Proxy extends Component { delay: PropTypes.object }; - handleRadioOnChange = ev => { + handleRadioOnChange = () => { const { name, parentName, checked, switchProxy } = this.props; if (checked) return; switchProxy(parentName, name); }; render() { - const { name, parentName, checked, switchProxy, delay } = this.props; + const { name, parentName, checked, delay } = this.props; const id = parentName + ':' + name; const latency = delay[name] || 0; return ( diff --git a/src/components/Root.js b/src/components/Root.js index 3946381..90144ff 100644 --- a/src/components/Root.js +++ b/src/components/Root.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; import { ConnectedRouter } from 'react-router-redux'; -import { Route, Link } from 'react-router-dom'; +import { Route } from 'react-router-dom'; import { hot } from 'react-hot-loader'; import SideBar from 'c/SideBar'; diff --git a/src/components/StyleGuide.js b/src/components/StyleGuide.js index f631d7d..3fe142d 100644 --- a/src/components/StyleGuide.js +++ b/src/components/StyleGuide.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; import ToggleSwitch from 'c/ToggleSwitch'; import Input from 'c/Input'; @@ -27,6 +28,9 @@ const optionsRule = [ ]; const Pane = ({ children }) =>
{children}
; +Pane.propTypes = { + children: PropTypes.element +}; class StyleGuide extends PureComponent { render() { diff --git a/src/ducks/app.js b/src/ducks/app.js index 5e7f4e6..1086413 100644 --- a/src/ducks/app.js +++ b/src/ducks/app.js @@ -11,7 +11,7 @@ export const getClashAPIConfig = s => s.app.clashAPIConfig; // TODO to support secret export function updateClashAPIConfig({ hostname: iHostname, port, secret }) { return async (dispatch, getState) => { - const hostname = iHostname.trim().replace(/^http(s)\:\/\//, ''); + const hostname = iHostname.trim().replace(/^http(s):\/\//, ''); dispatch({ type: UpdateClashAPIConfig, payload: { hostname, port, secret } diff --git a/src/ducks/configs.js b/src/ducks/configs.js index 2e7ca82..d8e0be1 100644 --- a/src/ducks/configs.js +++ b/src/ducks/configs.js @@ -1,5 +1,3 @@ -'use strict'; - import * as configsAPI from 'a/configs'; import { openModal } from 'd/modals'; import * as trafficAPI from 'a/traffic'; @@ -14,7 +12,7 @@ export const getConfigs = s => s.configs; // of code, I'm going to leave it here let successfullyFetchedConfigsBefore = false; export function fetchConfigs() { - return async (dispatch, getState) => { + return async dispatch => { let res; try { res = await configsAPI.fetchConfigs(); diff --git a/src/ducks/proxies.js b/src/ducks/proxies.js index a82fec2..dc38e73 100644 --- a/src/ducks/proxies.js +++ b/src/ducks/proxies.js @@ -1,5 +1,3 @@ -'use strict'; - import { createSelector } from 'reselect'; import * as proxiesAPI from 'a/proxies'; diff --git a/src/misc/pretty-bytes.js b/src/misc/pretty-bytes.js index 8df6517..e33b34e 100644 --- a/src/misc/pretty-bytes.js +++ b/src/misc/pretty-bytes.js @@ -1,4 +1,3 @@ -'use strict'; // steal from https://github.com/sindresorhus/pretty-bytes/blob/master/index.js const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; diff --git a/src/misc/request-helper.js b/src/misc/request-helper.js index e9c658a..7cc17bf 100644 --- a/src/misc/request-helper.js +++ b/src/misc/request-helper.js @@ -1,5 +1,3 @@ -'use strict'; - import { store } from '../store/configureStore'; import { getClashAPIConfig } from 'd/app'; diff --git a/yarn.lock b/yarn.lock index 5655f9c..8ba9931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1193,6 +1193,11 @@ array-find-index@^1.0.1: resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= +array-find@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-find/-/array-find-1.0.0.tgz#6c8e286d11ed768327f8e62ecee87353ca3e78b8" + integrity sha1-bI4obRHtdoMn+OYuzuhzU8o+eLg= + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -2804,6 +2809,15 @@ enhanced-resolve@^4.1.0: memory-fs "^0.4.0" tapable "^1.0.0" +enhanced-resolve@~0.9.0: + version "0.9.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" + integrity sha1-TW5omzcl+GCQknzMhs2fFjW4ni4= + dependencies: + graceful-fs "^4.1.2" + memory-fs "^0.2.0" + tapable "^0.1.8" + entities@^1.1.1, entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -2861,6 +2875,22 @@ eslint-import-resolver-node@^0.3.1: debug "^2.6.9" resolve "^1.5.0" +eslint-import-resolver-webpack@^0.10.1: + version "0.10.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.10.1.tgz#4cbceed2c0c43e488a74775c30861e58e00fb290" + integrity sha512-RN49nnyQpBCP3TqVhct+duJjH8kaVg08fFevWvA+4Cr1xeN7OFQRse4wMvzBto9/4VmOJWvqPfdmNTEG3jc8SQ== + dependencies: + array-find "^1.0.0" + debug "^2.6.8" + enhanced-resolve "~0.9.0" + find-root "^1.1.0" + has "^1.0.1" + interpret "^1.0.0" + lodash "^4.17.4" + node-libs-browser "^1.0.0 || ^2.0.0" + resolve "^1.4.0" + semver "^5.3.0" + eslint-module-utils@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746" @@ -3303,6 +3333,11 @@ find-parent-dir@^0.3.0: resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54" integrity sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ= +find-root@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" + integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng== + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -4019,7 +4054,7 @@ inquirer@^6.1.0: strip-ansi "^4.0.0" through "^2.3.6" -interpret@^1.1.0: +interpret@^1.0.0, interpret@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" integrity sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ= @@ -4881,6 +4916,11 @@ mem@^4.0.0: mimic-fn "^1.0.0" p-is-promise "^1.1.0" +memory-fs@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" + integrity sha1-8rslNovBIeORwlIN6Slpyu4KApA= + memory-fs@^0.4.0, memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -5281,7 +5321,7 @@ node-gyp@^3.8.0: tar "^2.0.0" which "1" -node-libs-browser@^2.0.0: +"node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.1.0.tgz#5f94263d404f6e44767d726901fff05478d600df" integrity sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg== @@ -6984,7 +7024,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.3.2, resolve@^1.5.0, resolve@^1.6.0: +resolve@^1.3.2, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.6.0: version "1.8.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" integrity sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA== @@ -7762,6 +7802,11 @@ table@^5.0.2: slice-ansi "1.0.0" string-width "^2.1.1" +tapable@^0.1.8: + version "0.1.10" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" + integrity sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q= + tapable@^1.0.0, tapable@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.0.tgz#0d076a172e3d9ba088fd2272b2668fb8d194b78c"