diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..20fdcbf38 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,5 @@ +!.eslintrc.js +.gitignore +*.json +*.lock +*.hbs \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index e8108cc2b..91203c30b 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,8 +1,20 @@ // see details: // https://github.com/groupher/eslint-config-web/blob/master/index.js module.exports = { - extends: ['@groupher/eslint-config-web'], + root: true, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: [ + '@groupher/eslint-config-web', + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + ], + // extends: ['@groupher/eslint-config-web'], settings: { + // see if the import lib exsit or not + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, 'import/resolver': { 'babel-module': {}, 'eslint-import-resolver-custom-alias': { @@ -14,7 +26,6 @@ module.exports = { '@/constant': 'utils/constant', '@/hooks': 'src/hooks', '@/hoc': 'src/hoc', - '@/config': 'config', '@/stores': 'src/stores', '@/model': 'src/stores/SharedModel', '@/utils': 'utils', @@ -22,12 +33,28 @@ module.exports = { '@/Img': 'src/components/Img', '@/SvgIcons': 'src/components/SvgIcons', '@/i18n': 'i18n', + '@/types': 'src/types', }, - extensions: ['.js', '.jsx'], + extensions: ['.js', '.jsx', '.ts', '.tsx'], }, }, }, rules: { + '@typescript-eslint/ban-ts-comment': 0, + 'react/jsx-filename-extension': [ + 2, + { extensions: ['.js', '.jsx', '.ts', '.tsx'] }, + ], 'import/no-named-as-default': 0, + 'import/extensions': [ + 'error', + 'ignorePackages', + { + js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', + }, + ], }, } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ae354bdc..d05a018d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: repository: 'coderplanets/coderplanets_server' path: 'backend_server' - name: (Backend) Setup Elixir and OTP - uses: actions/setup-elixir@v1 + uses: erlef/setup-elixir@v1 with: elixir-version: '1.10.3' # Define the elixir version [required] otp-version: '22.3' # Define the OTP version [required] diff --git a/.gitignore b/.gitignore index be884a229..7feb5f152 100755 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cypress/videos/ .vscode/ .DS_Store report.* +.eslintcache diff --git a/next-env.d.ts b/next-env.d.ts new file mode 100644 index 000000000..7b7aa2c77 --- /dev/null +++ b/next-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/package.json b/package.json index 58805bbea..41523e764 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "clean": "shjs ./utils/scripts/clean.js", "gen": "plop --plopfile ./utils/scripts/generators/index.js", "analyze": "cross-env ANALYZE=true next build", - "lint": "./node_modules/.bin/eslint --ext .js --fix src/ utils/", - "lint:staged": "git diff --cached --name-only --diff-filter=ACRM | grep \".js$\" | xargs ./node_modules/.bin/eslint --ext .js", + "lint": "./node_modules/.bin/eslint --ext .js,.ts,.tsx --fix src/ utils/", + "lint:staged": "git diff --cached --name-only --diff-filter=ACRM | xargs ./node_modules/.bin/eslint --cache --ext .js,.ts,.tsx && tsc --noemit", "test": "cross-env NODE_ENV=test jest --config .jest.config.js", "test:dev": "cross-env NODE_ENV=test jest --config .jest.config.js", "test:watch": "npm run test -- --watch", @@ -140,6 +140,9 @@ "@commitlint/cli": "^8.2.0", "@commitlint/config-conventional": "^8.2.0", "@groupher/eslint-config-web": "2.0.9", + "@types/ramda": "^0.27.38", + "@typescript-eslint/eslint-plugin": "^4.17.0", + "@typescript-eslint/parser": "^4.17.0", "babel-eslint": "^10.0.2", "babel-jest": "^23.6.0", "bundlewatch": "^0.2.7", @@ -160,6 +163,7 @@ "react-test-renderer": "16.10.0", "shelljs": "0.8.4", "standard-version": "^8.0.1", - "start-server-and-test": "1.10.1" + "start-server-and-test": "1.10.1", + "typescript": "^4.2.3" } } diff --git a/src/components/AlertBar/index.js b/src/components/AlertBar/index.js index 140f75746..6cb573e28 100755 --- a/src/components/AlertBar/index.js +++ b/src/components/AlertBar/index.js @@ -15,7 +15,7 @@ import { Wrapper } from './styles' const log = buildLog('c:AlertBar:index') const AlertBar = ({ children }) => { - return {children} + return {children} } AlertBar.propTypes = { diff --git a/src/components/AlertBar/styles/index.js b/src/components/AlertBar/styles/index.js index 19174d6fe..cd814f4f8 100755 --- a/src/components/AlertBar/styles/index.js +++ b/src/components/AlertBar/styles/index.js @@ -4,7 +4,7 @@ import styled from 'styled-components' // import { theme } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` font-size: 14px; font-variant: tabular-nums; diff --git a/src/components/Buttons/NotifyButton/index.js b/src/components/Buttons/NotifyButton/index.js index 8396fc6f3..c950f0db9 100644 --- a/src/components/Buttons/NotifyButton/index.js +++ b/src/components/Buttons/NotifyButton/index.js @@ -25,9 +25,9 @@ import { /* eslint-disable-next-line */ const log = buildLog('c:NotifyButton:index') -const NotifyButton = ({ testId, subscribed }) => { +const NotifyButton = ({ testid, subscribed }) => { return ( - + {subscribed ? (
@@ -68,12 +68,12 @@ const NotifyButton = ({ testId, subscribed }) => { } NotifyButton.propTypes = { - testId: T.string, + testid: T.string, subscribed: T.bool, } NotifyButton.defaultProps = { - testId: 'notify-button', + testid: 'notify-button', subscribed: false, } diff --git a/src/components/Buttons/styles/notify_button/index.js b/src/components/Buttons/styles/notify_button/index.js index a714ba61c..96861597d 100644 --- a/src/components/Buttons/styles/notify_button/index.js +++ b/src/components/Buttons/styles/notify_button/index.js @@ -4,7 +4,7 @@ import Img from '@/Img' import { css, theme } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn()}; ` diff --git a/src/components/Charger/index.js b/src/components/Charger/index.js index 7b34f7317..995543aa9 100755 --- a/src/components/Charger/index.js +++ b/src/components/Charger/index.js @@ -19,7 +19,7 @@ const log = buildLog('c:Charger:index') // bubbles effect: https://codepen.io/Johnm__/pen/qZqgGJ const Charger = () => { return ( - + diff --git a/src/components/Charger/styles/index.js b/src/components/Charger/styles/index.js index 9eb791e3d..97a20650b 100755 --- a/src/components/Charger/styles/index.js +++ b/src/components/Charger/styles/index.js @@ -106,7 +106,7 @@ const liquid2Rule = styledCss` ` export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` text-align: center; position: relative; diff --git a/src/components/CollapseMenu/Group.js b/src/components/CollapseMenu/Group.js index f8c56aa8f..6eba77a92 100644 --- a/src/components/CollapseMenu/Group.js +++ b/src/components/CollapseMenu/Group.js @@ -81,7 +81,7 @@ const Group = ({ key={item.id} item={item} active={activeItem.id === item.id} - activeId={activeItem.id} + activeid={activeItem.id} onSelect={onSelect} /> ))} diff --git a/src/components/CollapseMenu/Item.js b/src/components/CollapseMenu/Item.js index 4c00d11e7..a758e10ae 100644 --- a/src/components/CollapseMenu/Item.js +++ b/src/components/CollapseMenu/Item.js @@ -2,7 +2,7 @@ import React from 'react' import { Wrapper, Title } from './styles/item' -// const Item = ({ item, active, activeId, onSelect }) => { +// const Item = ({ item, active, activeid, onSelect }) => { const Item = ({ item, active, onSelect }) => { return ( diff --git a/src/components/CollapseMenu/index.js b/src/components/CollapseMenu/index.js index 9cf56e6cf..a120c209f 100755 --- a/src/components/CollapseMenu/index.js +++ b/src/components/CollapseMenu/index.js @@ -76,7 +76,7 @@ const defaultItems = [ ] const CollapseMenu = ({ - testId, + testid, items, activeItem, onSelect, @@ -87,7 +87,7 @@ const CollapseMenu = ({ const groupsKeys = keys(groupedItems) return ( - + {groupsKeys.map((groupKey) => ( { }, [executeIndex]) return ( - +
diff --git a/src/components/CrashErrorHint/styles/index.js b/src/components/CrashErrorHint/styles/index.js index 632d654a4..ea0c88da8 100755 --- a/src/components/CrashErrorHint/styles/index.js +++ b/src/components/CrashErrorHint/styles/index.js @@ -3,7 +3,7 @@ import styled from 'styled-components' import { css, theme, themeSkins } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn('align-center', 'justify-between')}; height: 100vh; diff --git a/src/components/DigestSentence/index.js b/src/components/DigestSentence/index.js index 88a03a013..4d1d7d9b3 100755 --- a/src/components/DigestSentence/index.js +++ b/src/components/DigestSentence/index.js @@ -16,7 +16,7 @@ import { Wrapper, PreviewWrapper, PreviewText, PreviewIcon } from './styles' const log = buildLog('c:DigestSentence:index') const DigestSentence = ({ - testId, + testid, children, onPreview, top, @@ -26,7 +26,7 @@ const DigestSentence = ({ }) => { return ( ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` color: ${theme('thread.articleDigest')}; font-size: 13px; diff --git a/src/components/DivideText/index.js b/src/components/DivideText/index.js index 9072a8ea8..cf47888db 100755 --- a/src/components/DivideText/index.js +++ b/src/components/DivideText/index.js @@ -14,9 +14,9 @@ import { Wrapper, Content, LeftLine, RightLine } from './styles' /* eslint-disable-next-line */ const log = buildLog('c:DivideText:index') -const DivideText = ({ testId, children }) => { +const DivideText = ({ testid, children }) => { return ( - + {children} @@ -25,12 +25,12 @@ const DivideText = ({ testId, children }) => { } DivideText.propTypes = { - testId: T.string, + testid: T.string, children: T.oneOfType([T.string, T.node]).isRequired, } DivideText.defaultProps = { - testId: 'divide-text', + testid: 'divide-text', } export default React.memo(DivideText) diff --git a/src/components/DivideText/styles/index.js b/src/components/DivideText/styles/index.js index 374fd5204..82e792516 100755 --- a/src/components/DivideText/styles/index.js +++ b/src/components/DivideText/styles/index.js @@ -4,7 +4,7 @@ import styled from 'styled-components' import { css } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center')}; width: 100%; diff --git a/src/components/EmailSubscriber/DefaultLayout/index.js b/src/components/EmailSubscriber/DefaultLayout/index.js index f76f56b01..1676ee87c 100644 --- a/src/components/EmailSubscriber/DefaultLayout/index.js +++ b/src/components/EmailSubscriber/DefaultLayout/index.js @@ -10,11 +10,11 @@ import { Wrapper, InnerWrapper } from '../styles/default_layout/index' /* eslint-disable-next-line */ const log = buildLog('c:DefaultLayout:index') -const DefaultLayout = ({ testId, activeByDefault, title, desc }) => { +const DefaultLayout = ({ testid, activeByDefault, title, desc }) => { const [active, setActive] = useState(activeByDefault) return ( - + {!active ? ( setActive(true)} /> diff --git a/src/components/EmailSubscriber/index.js b/src/components/EmailSubscriber/index.js index 45698a8c9..f8ceae344 100755 --- a/src/components/EmailSubscriber/index.js +++ b/src/components/EmailSubscriber/index.js @@ -13,7 +13,7 @@ import SimpleLayout from './SimpleLayout' import { Wrapper } from './styles' const EmailSubscriber = ({ - testId, + testid, title, desc, type, @@ -21,7 +21,7 @@ const EmailSubscriber = ({ activeByDefault, }) => { return ( - + {type === 'default' ? ( ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn('justify-center')}; position: relative; diff --git a/src/components/EmailSubscriber/styles/email_hint_icon.js b/src/components/EmailSubscriber/styles/email_hint_icon.js index 83675eb3b..4650fb5a7 100644 --- a/src/components/EmailSubscriber/styles/email_hint_icon.js +++ b/src/components/EmailSubscriber/styles/email_hint_icon.js @@ -6,7 +6,7 @@ import { theme, css, animate } from '@/utils' import { Wrapper as ParentWrapper } from './index' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center')}; ` diff --git a/src/components/EmailSubscriber/styles/index.js b/src/components/EmailSubscriber/styles/index.js index f20d35873..61419c1d5 100755 --- a/src/components/EmailSubscriber/styles/index.js +++ b/src/components/EmailSubscriber/styles/index.js @@ -1,6 +1,6 @@ import styled from 'styled-components' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))`` export const holder = 1 diff --git a/src/components/EmailSubscriber/styles/simple_layout.js b/src/components/EmailSubscriber/styles/simple_layout.js index 16cde96bd..d01c46139 100644 --- a/src/components/EmailSubscriber/styles/simple_layout.js +++ b/src/components/EmailSubscriber/styles/simple_layout.js @@ -5,7 +5,7 @@ import Input from '@/components/Input' import { css } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` position: relative; background: #022a34; diff --git a/src/components/ErrorPage/CodeSnippets.js b/src/components/ErrorPage/CodeSnippets.js index 3592081d5..8ed58302e 100644 --- a/src/components/ErrorPage/CodeSnippets.js +++ b/src/components/ErrorPage/CodeSnippets.js @@ -15,7 +15,7 @@ const arrow = '->' const CodeSnippets = ({ path }) => { return ( - +
case Page.goto( "{path}") diff --git a/src/components/ErrorPage/NotFoundMessage.js b/src/components/ErrorPage/NotFoundMessage.js index 8b4b87d5e..7285e4cda 100755 --- a/src/components/ErrorPage/NotFoundMessage.js +++ b/src/components/ErrorPage/NotFoundMessage.js @@ -9,18 +9,18 @@ const NotFoundMessage = ({ metric, path }) => { switch (metric) { case METRIC.USER: return ( - + 未找到该用户 {!isEmpty(path) && : {path.split(`/${ROUTE.USER}/`)[1]}} ) case METRIC.ARTICLE: - return 未找到该帖子 + return 未找到该帖子 case METRIC.COMMUNITY: return ( - + 未找到社区 {!isEmpty(path) && : {path}}, 欢迎 { ) default: - return 未找到该页面 + return 未找到该页面 } } diff --git a/src/components/ErrorPage/SpinPlanet.js b/src/components/ErrorPage/SpinPlanet.js index 7defd3a55..77b8c43ab 100644 --- a/src/components/ErrorPage/SpinPlanet.js +++ b/src/components/ErrorPage/SpinPlanet.js @@ -4,7 +4,7 @@ import { Wrapper, Planet, Hole } from './styles/spin_planet' const SpinPlanet = () => { return ( - + diff --git a/src/components/ErrorPage/index.js b/src/components/ErrorPage/index.js index 2b4181097..a735d053e 100755 --- a/src/components/ErrorPage/index.js +++ b/src/components/ErrorPage/index.js @@ -35,13 +35,13 @@ import { /* eslint-disable-next-line */ const log = buildLog('c:ErrorPage:index') -const ErrorPage = ({ testId, errorCode, metric, target }) => { +const ErrorPage = ({ testid, errorCode, metric, target }) => { const router = useRouter() return ( - + - + CoderPlanets @@ -69,14 +69,14 @@ const ErrorPage = ({ testId, errorCode, metric, target }) => { } ErrorPage.propTypes = { - testId: T.string, + testid: T.string, errorCode: T.oneOf([404, 500]), metric: T.oneOf(values(METRIC)), target: T.string, } ErrorPage.defaultProps = { - testId: 'error-page', + testid: 'error-page', errorCode: 404, metric: METRIC.COMMUNITY, target: '', diff --git a/src/components/ErrorPage/styles/code_snippets.js b/src/components/ErrorPage/styles/code_snippets.js index be3323635..32e68f5c9 100644 --- a/src/components/ErrorPage/styles/code_snippets.js +++ b/src/components/ErrorPage/styles/code_snippets.js @@ -3,7 +3,7 @@ import styled from 'styled-components' import { theme, css } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn('align-start')}; color: ${theme('thread.articleTitle')}; diff --git a/src/components/ErrorPage/styles/index.js b/src/components/ErrorPage/styles/index.js index 5f7cc289c..0a32f1c01 100755 --- a/src/components/ErrorPage/styles/index.js +++ b/src/components/ErrorPage/styles/index.js @@ -6,7 +6,7 @@ import Img from '@/Img' // import PromptIcon from '@/components/PromptIcon' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn('align-center', 'justify-between')}; height: 100vh; @@ -16,7 +16,7 @@ export const Wrapper = styled.div.attrs((props) => ({ background: rgba(0,59,74, 0.5); ` export const LogoWrapper = styled.a.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center')}; margin-top: 20px; @@ -43,7 +43,7 @@ export const TextWrapper = styled.div` margin-left: 115px; ` export const HintTitle = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` color: ${theme('thread.articleTitle')}; text-align: center; diff --git a/src/components/ErrorPage/styles/spin_planet.js b/src/components/ErrorPage/styles/spin_planet.js index 6c3284690..96e40bfbb 100644 --- a/src/components/ErrorPage/styles/spin_planet.js +++ b/src/components/ErrorPage/styles/spin_planet.js @@ -7,7 +7,7 @@ import { animate } from '@/utils' // see prototype in https://codepen.io/wwwebneko/pen/EyVbNe?__cf_chl_jschl_tk__=ea42fea4f3c12831123e6fa4871dc371d884b80f-1605582431-0-AaCbC_IecQcmQJpGB6rg-2q9uxuSjlmFbcwTbWrygu5jSC4fR6LX5l9MIHgbof5AmzFauO0FLQ-L1S9PZh6cdIEobYpUeQvMiWSXIuSZCAfF6BNN08alDBF-232m6NnwzRfU1nF3s8xRfJa0e5e0X8PKBdyDtttVkr8HC1XwZejcBIGKqT7-RoK_PWgLxNGbwAbIeCrgi3xU72sZ3ArdGEaq55Pgk6IAstRXuqm-4gY8eQNa1VAsH7GPsuWgoP5ooQRAaBPyDMaEPDcoLZMNqe7PePPNx9E-N4F_gTA7ERZFLLZEHk32dH-QCkPO4Dy-ewLmmRz4tGpSZYxYZW9b87JVGRL10Lk3R8H4QOsx3b3UcllTeXWtLX5ojMwWwqtdmRDCN2g6gB5-m5ic445Gkwg export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` position: relative; width: 125px; diff --git a/src/components/ExpandIcon/index.js b/src/components/ExpandIcon/index.js index f6b2d4c1f..973f08e83 100755 --- a/src/components/ExpandIcon/index.js +++ b/src/components/ExpandIcon/index.js @@ -39,7 +39,7 @@ const ExpandIcon = ({ onShow={() => setActive(true)} > diff --git a/src/components/ExpandIcon/styles/index.js b/src/components/ExpandIcon/styles/index.js index 8856274e0..abf00930c 100755 --- a/src/components/ExpandIcon/styles/index.js +++ b/src/components/ExpandIcon/styles/index.js @@ -11,7 +11,7 @@ import { } from './metric' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center')}; /* margin-left: 12px; */ diff --git a/src/components/FaqPeekList/index.js b/src/components/FaqPeekList/index.js index defe84454..65d486d4d 100755 --- a/src/components/FaqPeekList/index.js +++ b/src/components/FaqPeekList/index.js @@ -45,7 +45,7 @@ const FaqPeekList = ({ active }) => { }, [active]) return ( - + {active && } ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` position: relative; max-height: ${({ active }) => (active ? '220px' : '0')}; diff --git a/src/components/FiltersMenu/index.js b/src/components/FiltersMenu/index.js index cf455f842..aef271f2b 100755 --- a/src/components/FiltersMenu/index.js +++ b/src/components/FiltersMenu/index.js @@ -34,7 +34,7 @@ const initActiveMap = (items) => { const FiltersMenu = ({ title, items, - activeId, + activeid, noFilter, onItemClick, itemBgHighlight, @@ -42,7 +42,7 @@ const FiltersMenu = ({ withDivider, }) => { // const [expandMenuId, setExpandMenuId] = useState(null) - const [expandMenuId, setExpandMenuId] = useState(activeId) + const [expandMenuId, setExpandMenuId] = useState(activeid) const [activeMap, setActiveMap] = useState(initActiveMap(items)) const handleReset = useCallback(() => { @@ -123,7 +123,7 @@ FiltersMenu.propTypes = { ), }), ).isRequired, - activeId: T.oneOfType([T.string, T.instanceOf(null)]), + activeid: T.oneOfType([T.string, T.instanceOf(null)]), noFilter: T.bool, onItemClick: T.func, itemBgHighlight: T.bool, @@ -133,7 +133,7 @@ FiltersMenu.propTypes = { FiltersMenu.defaultProps = { title: '', - activeId: null, + activeid: null, noFilter: false, onItemClick: log, itemBgHighlight: true, diff --git a/src/components/FiltersMenu/styles/header.js b/src/components/FiltersMenu/styles/header.js index 2c923e691..6ed73ba63 100644 --- a/src/components/FiltersMenu/styles/header.js +++ b/src/components/FiltersMenu/styles/header.js @@ -4,7 +4,7 @@ import Img from '@/Img' import { css, theme } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center', 'justify-between')} width: 100%; diff --git a/src/components/Folder/index.js b/src/components/Folder/index.js index 2c30339fc..ec5a7fda1 100755 --- a/src/components/Folder/index.js +++ b/src/components/Folder/index.js @@ -34,7 +34,7 @@ const Folder = ({ onSelect, }) => { return ( - + {editable && ( diff --git a/src/components/Folder/styles/index.js b/src/components/Folder/styles/index.js index 768555313..0a82c020c 100755 --- a/src/components/Folder/styles/index.js +++ b/src/components/Folder/styles/index.js @@ -6,7 +6,7 @@ import { css, theme } from '@/utils' import { getWidth, getHeight } from './metric' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` position: relative; ${css.flexColumn()}; diff --git a/src/components/GotoTop/index.js b/src/components/GotoTop/index.js index 77c898bc0..b6e07aa76 100755 --- a/src/components/GotoTop/index.js +++ b/src/components/GotoTop/index.js @@ -12,9 +12,9 @@ import { scrollToHeader } from '@/utils' import { Wrapper, Icon, Hint } from './styles' -const GotoTop = ({ testId }) => { +const GotoTop = ({ testid }) => { return ( - + 回到顶部 @@ -22,11 +22,11 @@ const GotoTop = ({ testId }) => { } GotoTop.propTypes = { - testId: T.string, + testid: T.string, } GotoTop.defaultProps = { - testId: 'goto-top', + testid: 'goto-top', } export default React.memo(GotoTop) diff --git a/src/components/GotoTop/styles/index.js b/src/components/GotoTop/styles/index.js index f24384a15..9cbe0342d 100755 --- a/src/components/GotoTop/styles/index.js +++ b/src/components/GotoTop/styles/index.js @@ -4,7 +4,7 @@ import Img from '@/Img' import { css, theme } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-both')}; ${css.size(30)}; diff --git a/src/components/IconText/index.js b/src/components/IconText/index.js index 741136205..dae91707e 100755 --- a/src/components/IconText/index.js +++ b/src/components/IconText/index.js @@ -17,7 +17,7 @@ import { Wrapper, Icon, Text } from './styles' const log = buildLog('c:IconText:index') const IconText = ({ iconSrc, round, children, size, margin }) => ( - + {!nilOrEmpty(iconSrc) && ( )} diff --git a/src/components/IconText/styles/index.js b/src/components/IconText/styles/index.js index 5fa42b637..b0210d00c 100755 --- a/src/components/IconText/styles/index.js +++ b/src/components/IconText/styles/index.js @@ -6,7 +6,7 @@ import { css, theme } from '@/utils' import { getIconSize, getTextSize, getMargin } from './metric' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-center')}; ` diff --git a/src/components/ImgFallback/Avatar.js b/src/components/ImgFallback/Avatar.js index 57353d46f..b8fb81299 100644 --- a/src/components/ImgFallback/Avatar.js +++ b/src/components/ImgFallback/Avatar.js @@ -15,7 +15,7 @@ import { Wrapper, Name } from './styles/avatar' const log = buildLog('c:ImgFallback:Avatar') const Avatar = ({ - testId, + testid, className, size, user, @@ -31,7 +31,7 @@ const Avatar = ({ return ( ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flex('align-both')}; color: ${theme('thread.articleTitle')}; diff --git a/src/components/ImgFallback/styles/index.js b/src/components/ImgFallback/styles/index.js index a8221d394..6b28e2d43 100755 --- a/src/components/ImgFallback/styles/index.js +++ b/src/components/ImgFallback/styles/index.js @@ -4,6 +4,6 @@ import styled from 'styled-components' // import { theme } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))`` export const Title = styled.div`` diff --git a/src/components/ImgFallback/styles/work.js b/src/components/ImgFallback/styles/work.js index e4d74f126..0f4a1a096 100644 --- a/src/components/ImgFallback/styles/work.js +++ b/src/components/ImgFallback/styles/work.js @@ -4,7 +4,7 @@ import styled from 'styled-components' import { css } from '@/utils' export const Wrapper = styled.div.attrs((props) => ({ - 'data-test-id': props.testId, + 'data-test-id': props.testid, }))` ${css.flexColumn('align-center', 'justify-between')}; width: 70px; diff --git a/src/components/Input/Textarea.js b/src/components/Input/Textarea.js index 4221dda96..1ada89659 100644 --- a/src/components/Input/Textarea.js +++ b/src/components/Input/Textarea.js @@ -15,13 +15,13 @@ import { Wrapper } from './styles/textarea' /* eslint-disable-next-line */ const log = buildLog('c:Input:index') -const Textarea = ({ onChange, testId, ...restProps }) => { +const Textarea = ({ onChange, testid, ...restProps }) => { const handleOnChange = useCallback((e) => onChange && onChange(e), [onChange]) const validProps = pickBy((v) => v !== null, restProps) return ( { const handleOnChange = useCallback((e) => onChange && onChange(e), [onChange]) const validProps = pickBy((v) => v !== null, restProps) return behavior === 'default' ? ( - + {prefixIcon && } @@ -53,7 +53,7 @@ const Input = ({ ) : ( -