Skip to content

Commit

Permalink
style(clipper): lint file by new elint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Mar 14, 2019
1 parent a05418a commit 3df8eb1
Show file tree
Hide file tree
Showing 41 changed files with 442 additions and 442 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy'
'\\.(css|scss)$': 'identity-obj-proxy',
},
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverage: true,
testEnvironment: 'node',
verbose: true
verbose: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"typescript-fsa": "^3.0.0-beta-2"
},
"devDependencies": {
"@diamondyuan/eslint-config-react-typescript": "^2.0.3",
"@diamondyuan/eslint-config-react-typescript": "^3.0.0",
"@types/blueimp-md5": "^2.7.0",
"@types/chrome": "^0.0.72",
"@types/enzyme": "^3.1.14",
Expand Down
18 changes: 9 additions & 9 deletions src/const/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export const backendServices: {
[key: string]: {
icon: string;
home: string;
api: string;
name: string;
};
[key: string]: {
icon: string;
home: string;
api: string;
name: string;
};
} = {
yuque: {
icon: 'yuque',
home: 'https://www.yuque.com',
api: 'https://www.yuque.com/api/v2/',
name: '语雀'
name: '语雀',
},
github: {
icon: 'github',
home: 'https://www.github.com',
api: 'https://api.github.com/',
name: 'Github'
}
name: 'Github',
},
};

export function pluginRouterCreator(id: string) {
Expand Down
10 changes: 5 additions & 5 deletions src/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import TurndownService from 'turndown';
import { AnyAction, isType } from 'typescript-fsa';
import {
asyncHideTool,
asyncRemoveTool
asyncRemoveTool,
} from '../store/actions/userPreference';
import {
asyncRunPlugin,
asyncTakeScreenshot,
asyncRunToolPlugin
asyncRunToolPlugin,
} from '../store/actions/clipper';
import { clickIcon, doYouAliveNow } from '../store/actions/browser';

Expand All @@ -24,7 +24,7 @@ turndownService.addRule('lazyLoadImage', {
return `![](${dataSrc})`;
}
return `![](${node.getAttribute('src')})`;
}
},
});

chrome.runtime.onMessage.addListener((action: AnyAction, _, sendResponse) => {
Expand Down Expand Up @@ -64,7 +64,7 @@ chrome.runtime.onMessage.addListener((action: AnyAction, _, sendResponse) => {
Highlighter,
toggleClipper,
Readability,
document
document,
};
(async () => {
// eslint-disable-next-line
Expand Down Expand Up @@ -120,7 +120,7 @@ chrome.runtime.onMessage.addListener((action: AnyAction, _, sendResponse) => {
Highlighter,
toggleClipper,
Readability,
document
document,
};
(async () => {
// eslint-disable-next-line
Expand Down
8 changes: 4 additions & 4 deletions src/pages/complete/complete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import { asyncRemoveTool } from '../../store/actions/userPreference';
import { QuickResponseCode } from './quickResponseCode';

const useActions = {
asyncRemoveTool: asyncRemoveTool.started
asyncRemoveTool: asyncRemoveTool.started,
};

const mapStateToProps = ({
clipper: { completeStatus, currentAccountId },
userPreference: { accounts, showQuickResponseCode }
userPreference: { accounts, showQuickResponseCode },
}: GlobalStore) => {
const currentAccount = accounts.find(o => o.id === currentAccountId);
return {
currentAccount,
completeStatus,
showQuickResponseCode
showQuickResponseCode,
};
};
type PageState = {};
Expand All @@ -40,7 +40,7 @@ class Page extends React.Component<PageProps, PageState> {
const {
completeStatus,
currentAccount,
showQuickResponseCode
showQuickResponseCode,
} = this.props;
if (!completeStatus || !currentAccount) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/complete/quickResponseCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class QuickResponseCode extends React.Component<PageProps, PageState> {
super(props);
this.state = {
includeToken: false,
quickResponseCodeData: null
quickResponseCodeData: null,
};
}

Expand Down Expand Up @@ -53,7 +53,7 @@ export class QuickResponseCode extends React.Component<PageProps, PageState> {
console.log(err);
}
this.setState({
quickResponseCodeData
quickResponseCodeData,
});
}
);
Expand Down
20 changes: 10 additions & 10 deletions src/pages/plugin/Plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ import { connect } from 'react-redux';
import * as HyperMD from 'hypermd';
import {
updateTextClipperData,
asyncRunPlugin
asyncRunPlugin,
} from '../../store/actions/clipper';
import { EditorContainer } from '../../components/container';
import { pluginRouterCreator } from '../../const';

const useActions = {
asyncRunPlugin: asyncRunPlugin.started,
updateTextClipperData
updateTextClipperData,
};

const mapStateToProps = ({
router: {
location: { pathname }
location: { pathname },
},
clipper,
userPreference: { liveRendering, showLineNumber, plugins }
userPreference: { liveRendering, showLineNumber, plugins },
}: GlobalStore) => {
return {
clipper,
liveRendering,
showLineNumber,
clipperData: clipper.clipperData,
pathname,
plugins
plugins,
};
};
type PageState = {};
type PageOwnProps = {};
type PageProps = ReturnType<typeof mapStateToProps> &
typeof useActions &
PageOwnProps;
PageOwnProps;

const editorId = 'DiamondYuan_Love_LJ';

Expand All @@ -59,7 +59,7 @@ class ClipperPluginPage extends React.Component<PageProps, PageState> {
let myTextarea = document.getElementById(editorId) as HTMLTextAreaElement;
this.myCodeMirror = HyperMD.fromTextArea(myTextarea, {
lineNumbers: !!this.props.showLineNumber,
hmdModeLoader: false
hmdModeLoader: false,
});

const plugin = plugins.find(
Expand All @@ -69,7 +69,7 @@ class ClipperPluginPage extends React.Component<PageProps, PageState> {
if (!clipperData[pathname]) {
this.props.asyncRunPlugin({
pathname,
plugin
plugin,
});
}
const data: TextClipperData = (clipperData[
Expand All @@ -81,8 +81,8 @@ class ClipperPluginPage extends React.Component<PageProps, PageState> {
path: pathname,
data: {
type: 'text',
data: editor.getValue()
}
data: editor.getValue(),
},
});
});
this.myCodeMirror.setSize(800, 621);
Expand Down
12 changes: 6 additions & 6 deletions src/pages/plugin/imagePlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ import { connect } from 'react-redux';
import {
updateTextClipperData,
asyncRunPlugin,
asyncTakeScreenshot
asyncTakeScreenshot,
} from '../../store/actions/clipper';
import { EditorContainer } from '../../components/container';
import * as styles from './index.scss';

const useActions = {
asyncRunPlugin: asyncRunPlugin.started,
asyncTakeScreenshot: asyncTakeScreenshot.started,
updateTextClipperData
updateTextClipperData,
};

const mapStateToProps = ({
router,
clipper,
userPreference: { liveRendering, showLineNumber }
userPreference: { liveRendering, showLineNumber },
}: GlobalStore) => {
return {
router,
clipper,
liveRendering,
showLineNumber,
clipperData: clipper.clipperData,
pathname: router.location.pathname
pathname: router.location.pathname,
};
};
type PageState = {};
type PageOwnProps = {};
type PageProps = ReturnType<typeof mapStateToProps> &
typeof useActions &
PageOwnProps;
PageOwnProps;

class ImagePluginPage extends React.Component<PageProps, PageState> {
componentDidMount = () => {
this.props.asyncTakeScreenshot({
pathname: this.props.pathname
pathname: this.props.pathname,
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/plugin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { pluginRouterCreator } from '../../const';

const mapStateToProps = ({ userPreference: { plugins }}: GlobalStore) => {
return {
idList: plugins.filter(o => o.type === 'clipper').map(o => o.id)
idList: plugins.filter(o => o.type === 'clipper').map(o => o.id),
};
};

Expand Down
26 changes: 13 additions & 13 deletions src/pages/preference/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
asyncSetEditorLiveRendering,
asyncSetShowLineNumber,
asyncSetShowQuickResponseCode,
asyncSetDefaultPluginId
asyncSetDefaultPluginId,
} from '../../store/actions/userPreference';
import { bindActionCreators, Dispatch } from 'redux';
import { CenterContainer } from '../../components/container';
Expand All @@ -19,7 +19,7 @@ const useActions = {
asyncSetEditorLiveRendering: asyncSetEditorLiveRendering.started,
asyncSetShowLineNumber: asyncSetShowLineNumber.started,
asyncSetShowQuickResponseCode: asyncSetShowQuickResponseCode.started,
asyncSetDefaultPluginId: asyncSetDefaultPluginId.started
asyncSetDefaultPluginId: asyncSetDefaultPluginId.started,
};

const mapStateToProps = ({
Expand All @@ -29,8 +29,8 @@ const mapStateToProps = ({
showLineNumber,
showQuickResponseCode,
defaultPluginId,
plugins
}
plugins,
},
}: GlobalStore) => {
return {
showLineNumber,
Expand All @@ -41,7 +41,7 @@ const mapStateToProps = ({
liveRendering,
QRCodeContent: '',
accounts,
plugins: plugins.filter(o => o.type === 'clipper')
plugins: plugins.filter(o => o.type === 'clipper'),
};
};
type PageState = {};
Expand Down Expand Up @@ -85,10 +85,10 @@ class Page extends React.Component<PageProps, PageState> {
key='qrcode'
onChange={() => {
this.props.asyncSetShowQuickResponseCode({
value: this.props.showQuickResponseCode
value: this.props.showQuickResponseCode,
});
}}
/>
/>,
]}
>
<List.Item.Meta
Expand All @@ -109,15 +109,15 @@ class Page extends React.Component<PageProps, PageState> {
selectValue = value;
}
this.props.asyncSetDefaultPluginId({
pluginId: selectValue
pluginId: selectValue,
});
}}
>
<Select.Option value={-1}></Select.Option>
{plugins.map(o => (
<Select.Option key={o.id}>{o.name}</Select.Option>
))}
</Select>
</Select>,
]}
>
<List.Item.Meta
Expand All @@ -133,11 +133,11 @@ class Page extends React.Component<PageProps, PageState> {
checked={this.props.showLineNumber}
onChange={() => {
this.props.asyncSetShowLineNumber({
value: this.props.showLineNumber
value: this.props.showLineNumber,
});
}}
key='showLineNumber'
/>
/>,
]}
>
<List.Item.Meta
Expand All @@ -152,10 +152,10 @@ class Page extends React.Component<PageProps, PageState> {
checked={this.props.liveRendering}
onChange={() => {
this.props.asyncSetEditorLiveRendering({
value: this.props.liveRendering
value: this.props.liveRendering,
});
}}
/>
/>,
]}
>
<List.Item.Meta
Expand Down
Loading

0 comments on commit 3df8eb1

Please sign in to comment.