Skip to content

Commit

Permalink
[chore] add simple-import-sort & update jsxSingleQuote rule (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrunlin authored May 11, 2023
1 parent e881704 commit 8d08a7e
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 70 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"extends": ["taro/react"],
"plugins": ["simple-import-sort"],
"rules": {
"@typescript-eslint/no-shadow": "off",
"import/first": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"react/sort-comp": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
Build-and-Deploy:
runs-on: ubuntu-latest
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
WMA_ID: ${{ secrets.WMA_ID }}
steps:
- uses: actions/checkout@v3
Expand All @@ -18,7 +21,9 @@ jobs:
node-version: 16
cache: pnpm
- name: Install Dependencies
run: pnpm i --frozen-lockfile
run: |
echo '${{ secrets.NPM_RC }}' >> .npmrc
pnpm i --frozen-lockfile
- name: Build HTML 5 version
if: ${{ !env.WMA_ID }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
cache: pnpm
- name: Install Dependencies
if: ${{ !env.VERCEL_TOKEN || !env.VERCEL_ORG_ID || !env.VERCEL_PROJECT_ID }}
run: pnpm i --frozen-lockfile
run: |
echo '${{ secrets.NPM_RC }}' > .npmrc
pnpm i --frozen-lockfile
- name: Build HTML 5 version
if: ${{ !env.VERCEL_TOKEN || !env.VERCEL_ORG_ID || !env.VERCEL_PROJECT_ID }}
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
Expand All @@ -83,11 +84,13 @@
"webpack": "~5.82.0"
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
"arrowParens": "avoid",
"singleQuote": true,
"jsxSingleQuote": true
},
"lint-staged": {
"*.{md,js,ts,tsx,json,yml}": "prettier --write"
"*.{md,js,ts,tsx,json,yml}": "prettier --write",
"*.{js,jsx,ts,tsx}": "eslint --fix"
}
}
19 changes: 15 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PropsWithChildren, PureComponent } from 'react';

import './app.less';

import { PropsWithChildren, PureComponent } from 'react';

export default class App extends PureComponent<PropsWithChildren> {
componentDidShow() {}

Expand Down
10 changes: 5 additions & 5 deletions src/components/AreaSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Area, FormItem, Popup } from '@antmjs/vantui';
import { AreaProps } from '@antmjs/vantui/types/area';
import { FormItemProps } from '@antmjs/vantui/types/form';
import { areaList } from '@vant/area-data';
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import { PureComponent } from 'react';
import { FormItem, Area, Popup } from '@antmjs/vantui';
import { FormItemProps } from '@antmjs/vantui/types/form';
import { AreaProps } from '@antmjs/vantui/types/area';
import { areaList } from '@vant/area-data';

export type Area = Record<'name' | 'code', string>;

Expand Down Expand Up @@ -68,7 +68,7 @@ export class AreaSelect extends PureComponent<AreaSelectProps> {

<Popup
show={show}
position="bottom"
position='bottom'
style={{ height: '50vh' }}
onClose={this.close}
>
Expand Down
8 changes: 4 additions & 4 deletions src/components/GitList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Cell,CellGroup } from '@antmjs/vantui';
import { observer } from 'mobx-react';
import { CellGroup, Cell } from '@antmjs/vantui';

import { ScrollListProps, ScrollList } from './ScrollList';
import { i18n } from '../store/Translation';
import repositoryStore, { Repository } from '../store/Repository';
import { i18n } from '../store/Translation';
import { ScrollList,ScrollListProps } from './ScrollList';

export type GitListProps = ScrollListProps<Repository>;

Expand All @@ -24,7 +24,7 @@ export class GitList extends ScrollList<GitListProps> {
return (
<CellGroup>
{allItems.map(({ full_name, description }) => (
<Cell title={full_name} label={description} />
<Cell key={full_name} title={full_name} label={description} />
))}
</CellGroup>
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/MainNav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import { redirectTo } from '@tarojs/taro';
import { Tabbar, TabbarItem } from '@antmjs/vantui';
import { redirectTo } from '@tarojs/taro';
import { FC } from 'react';

export interface MainNavProps {
path: string;
Expand All @@ -14,13 +14,13 @@ export const MainNav: FC<MainNavProps> = ({ path }) => (
active={path}
onChange={({ detail }) => redirectTo({ url: `/pages/${detail}` })}
>
<TabbarItem icon="points" name="home">
<TabbarItem icon='points' name='home'>
MobX
</TabbarItem>
<TabbarItem icon="cluster-o" name="component">
<TabbarItem icon='cluster-o' name='component'>
组件
</TabbarItem>
<TabbarItem icon="exchange" name="interface">
<TabbarItem icon='exchange' name='interface'>
接口
</TabbarItem>
</Tabbar>
Expand Down
6 changes: 3 additions & 3 deletions src/components/RangeField.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC } from 'react';
import { Row, Col, FormItem, Slider } from '@antmjs/vantui';
import { Col, FormItem, Row, Slider } from '@antmjs/vantui';
import { FormItemProps } from '@antmjs/vantui/types/form';
import { SliderProps } from '@antmjs/vantui/types/slider';
import { FC } from 'react';

export interface RangeFieldProps
extends Pick<FormItemProps, 'name' | 'required' | 'rules'>,
Expand All @@ -27,7 +27,7 @@ export const RangeField: FC<RangeFieldProps> = ({
</FormItem>

<Row>
<Col span="14" offset="8" className="py-3">
<Col span='14' offset='8' className='py-3'>
<Slider range value={value} {...rest} />
</Col>
</Row>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ScrollList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ScrollView, ScrollViewProps } from '@tarojs/components';
import debounce from 'lodash.debounce';
import { TranslationModel } from 'mobx-i18n';
import { DataObject, NewData, ListModel, Stream } from 'mobx-restful';
import { DataObject, ListModel, NewData, Stream } from 'mobx-restful';
import { Component, ReactNode } from 'react';
import { ScrollView, ScrollViewProps } from '@tarojs/components';

export interface ScrollListProps<T extends DataObject = DataObject>
extends Pick<ScrollViewProps, 'className' | 'style'> {
Expand Down Expand Up @@ -62,7 +62,7 @@ export abstract class ScrollList<
>
{this.renderList()}

<footer className="mt-4 text-center text-muted small">
<footer className='mt-4 text-center text-muted small'>
{noMore || !allItems.length ? t('no_more') : t('load_more')}
</footer>
</ScrollView>
Expand Down
28 changes: 14 additions & 14 deletions src/components/SessionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ export class SessionBox extends PureComponent<SessionBoxProps> {

return (
<Dialog show showConfirmButton={false} closeOnClickOverlay={false}>
<div className="p-3">
<div className='p-3'>
<Input
className="p-3"
placeholder="手机号"
className='p-3'
placeholder='手机号'
onInput={({ detail }) => (this.mobilePhone = detail.value)}
/>
<div className="d-flex">
<div className="me-auto">
<div className='d-flex'>
<div className='me-auto'>
<Input
className="p-3"
placeholder="验证码"
className='p-3'
placeholder='验证码'
onInput={({ detail }) => (this.code = detail.value)}
/>
</div>
<div>
<Button
className="text-nowrap"
type="primary"
className='text-nowrap'
type='primary'
disabled={!mobilePhone || !!interval}
onClick={this.sendSMS}
>
Expand All @@ -81,10 +81,10 @@ export class SessionBox extends PureComponent<SessionBoxProps> {
</div>
</div>
<Button
className="mt-3"
className='mt-3'
block
type="primary"
formType="submit"
type='primary'
formType='submit'
disabled={!mobilePhone || !code}
onClick={this.signIn}
>
Expand All @@ -101,12 +101,12 @@ export class SessionBox extends PureComponent<SessionBoxProps> {
{ session } = userStore;

return (
<div className="position-relative">
<div className='position-relative'>
{(!autoCover || session) && children}

{!autoCover && !session && !showDialog && (
<div
className="position-absolute left-0 top-0 w-100 h-100"
className='position-absolute left-0 top-0 w-100 h-100'
style={{ zIndex: 1000 }}
onClick={this.checkSession}
/>
Expand Down
18 changes: 9 additions & 9 deletions src/pages/component.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PureComponent } from 'react';
import { CellGroup, Form } from '@antmjs/vantui';
import { PureComponent } from 'react';

import { AreaSelect } from '../components/AreaSelect';
import { MainNav } from '../components/MainNav';
import { RangeField } from '../components/RangeField';
import { AreaSelect } from '../components/AreaSelect';

definePageConfig({
navigationBarTitleText: '高级组件演示'
Expand All @@ -25,25 +25,25 @@ export default class ComponentPage extends PureComponent<{}, State> {
return (
<div>
<Form>
<CellGroup title="高级控件">
<CellGroup title='高级控件'>
<RangeField
title="范围"
unit="mm"
name="range"
title='范围'
unit='mm'
name='range'
max={100}
value={range}
onChange={({ detail }) => this.setState({ range: detail })}
/>
<AreaSelect
title="所在地"
name="area"
title='所在地'
name='area'
value={areaCode}
onChange={areaCode => this.setState({ areaCode })}
/>
</CellGroup>
</Form>

<MainNav path="component" />
<MainNav path='component' />
</div>
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PureComponent } from 'react';
import { observer } from 'mobx-react';
import { Button } from '@antmjs/vantui';
import { observer } from 'mobx-react';
import { PureComponent } from 'react';

import { MainNav } from '../components/MainNav';
import { SessionBox } from '../components/SessionBox';
Expand All @@ -19,17 +19,17 @@ export default class HomePage extends PureComponent {
<SessionBox>
<span>index</span>

<Button type="primary" onClick={() => counterStore.reduceCount()}>
<Button type='primary' onClick={() => counterStore.reduceCount()}>
-
</Button>

<span>{counter}</span>

<Button type="primary" onClick={() => counterStore.addCount()}>
<Button type='primary' onClick={() => counterStore.addCount()}>
+
</Button>

<MainNav path="home" />
<MainNav path='home' />
</SessionBox>
);
}
Expand Down
Loading

0 comments on commit 8d08a7e

Please sign in to comment.