Skip to content

Commit

Permalink
♻️ Add shared eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 21, 2022
1 parent e09adf5 commit 451ffbc
Show file tree
Hide file tree
Showing 123 changed files with 1,145 additions and 1,517 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint
43 changes: 2 additions & 41 deletions apps/builder/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,4 @@
module.exports = {
ignorePatterns: ['node_modules'],
env: {
browser: true,
es6: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'next/core-web-vitals',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
plugins: ['react', '@typescript-eslint'],
rules: {
'react/no-unescaped-entities': [0],
'react/display-name': [0],
'no-restricted-imports': [
'error',
{
patterns: [
'*/src/*',
'src/*',
'*/src',
'@/features/*/*',
'!@/features/blocks/*',
'!@/features/*/api',
],
},
],
},
root: true,
extends: ['custom'],
}
10 changes: 3 additions & 7 deletions apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,16 @@
"@types/qs": "6.9.7",
"@types/react": "18.0.25",
"@types/tinycolor2": "1.4.3",
"@typescript-eslint/eslint-plugin": "5.43.0",
"@typescript-eslint/parser": "5.43.0",
"configs": "workspace:*",
"db": "workspace:*",
"dotenv": "16.0.3",
"eslint": "8.27.0",
"eslint-config-next": "13.0.3",
"eslint-plugin-react": "7.31.10",
"models": "workspace:*",
"next-transpile-modules": "10.0.0",
"superjson": "^1.11.0",
"tsconfig": "workspace:*",
"typescript": "4.8.4",
"utils": "workspace:*",
"zod": "3.19.1"
"zod": "3.19.1",
"eslint": "8.28.0",
"eslint-config-custom": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion apps/builder/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlaywrightTestConfig } from '@playwright/test'
import path from 'path'
import { playwrightBaseConfig } from 'configs/playwright'
import { playwrightBaseConfig } from 'utils/playwright/baseConfig'

const config: PlaywrightTestConfig = {
...playwrightBaseConfig,
Expand Down
1 change: 0 additions & 1 deletion apps/builder/src/components/SearchableDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const SearchableDropdown = ({
const { onOpen, onClose, isOpen } = useDisclosure()
const [inputValue, setInputValue] = useState(selectedItem ?? '')
const debounced = useDebouncedCallback(
// eslint-disable-next-line @typescript-eslint/no-empty-function
onValueChange ? onValueChange : () => {},
env('E2E_TEST') === 'true' ? 0 : debounceTimeout
)
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/VariableSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const VariableSearchInput = ({
leftIcon={<PlusIcon />}
bgColor={keyboardFocusIndex === 0 ? 'gray.200' : 'transparent'}
>
Create "{inputValue}"
Create &quot;{inputValue}&quot;
</Button>
)}
{filteredItems.length > 0 && (
Expand Down
1 change: 0 additions & 1 deletion apps/builder/src/features/account/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const userContext = createContext<{
currentWorkspaceId?: string
updateUser: (newUser: Partial<User>) => void
saveUser: (newUser?: Partial<User>) => Promise<void>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
}>({})

Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/auth/components/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SignInPage = ({ type }: Props) => {
</Heading>
{type === 'signin' ? (
<Text>
Don't have an account?{' '}
Don&apos;t have an account?{' '}
<TextLink href="/register">Sign up for free</TextLink>
</Text>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const UsageContent = ({ workspace }: Props) => {
p="3"
label={
<Text>
Your typebots are popular! You will soon reach your plan's
chats limit. 🚀
Your typebots are popular! You will soon reach your
plan&apos;s chats limit. 🚀
<br />
<br />
Make sure to <strong>update your plan</strong> to increase
Expand Down Expand Up @@ -111,8 +111,8 @@ export const UsageContent = ({ workspace }: Props) => {
p="3"
label={
<Text>
Your typebots are popular! You will soon reach your plan's
storage limit. 🚀
Your typebots are popular! You will soon reach your
plan&apos;s storage limit. 🚀
<br />
<br />
Make sure to <strong>update your plan</strong> in order to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const ChangePlanForm = () => {
<Text color="gray.500">
Need custom limits? Specific features?{' '}
<TextLink href={'https://typebot.io/enterprise-lead-form'} isExternal>
Let's chat!
Let&apos;s chat!
</TextLink>
</Text>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,20 @@ const ActionOptions = ({
onOptionsChange({ ...options, cellsToExtract } as GoogleSheetsOptions)

const UpdatingCellItem = useMemo(
() => (props: TableListItemProps<Cell>) =>
<CellWithValueStack {...props} columns={sheet?.columns ?? []} />,
() =>
function Component(props: TableListItemProps<Cell>) {
return <CellWithValueStack {...props} columns={sheet?.columns ?? []} />
},
[sheet?.columns]
)

const ExtractingCellItem = useMemo(
() => (props: TableListItemProps<ExtractingCell>) =>
<CellWithVariableIdStack {...props} columns={sheet?.columns ?? []} />,
() =>
function Component(props: TableListItemProps<ExtractingCell>) {
return (
<CellWithVariableIdStack {...props} columns={sheet?.columns ?? []} />
)
},
[sheet?.columns]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ export const WebhookSettings = ({
}

const ResponseMappingInputs = useMemo(
() => (props: TableListItemProps<ResponseVariableMapping>) =>
<DataVariableInputs {...props} dataItems={responseKeys} />,
() =>
function Component(props: TableListItemProps<ResponseVariableMapping>) {
return <DataVariableInputs {...props} dataItems={responseKeys} />
},
[responseKeys]
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getDeepKeys = (obj: any): string[] => {
let keys: string[] = []
for (const key in obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const AnnoucementModal = ({ isOpen, onClose }: Props) => {
<Modal isOpen={isOpen} onClose={handleCloseClick} size="2xl">
<ModalOverlay />
<ModalContent>
<ModalHeader>What's new in Typebot 2.0?</ModalHeader>
<ModalHeader>What&apos;s new in Typebot 2.0?</ModalHeader>
<ModalCloseButton />
<ModalBody as={Stack} spacing="6" pb="10">
<Text>Typebo 2.0 has been launched February the 15th 🎉.</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@chakra-ui/react'
import { TypebotViewer } from 'bot-engine'
import { useUser } from '@/features/account'
import { Answer, Typebot } from 'models'
import { AnswerInput, Typebot } from 'models'
import React, { useEffect, useRef, useState } from 'react'
import { getViewerUrl, sendRequest } from 'utils'
import confetti from 'canvas-confetti'
Expand Down Expand Up @@ -79,7 +79,7 @@ export const OnboardingModal = ({ totalTypebots }: Props) => {
setTypebot(data as Typebot)
}

const handleNewAnswer = async (answer: Answer) => {
const handleNewAnswer = async (answer: AnswerInput) => {
const isName = answer.variableId === 'cl126f4hf000i2e6d8zvzc3t1'
const isCompany = answer.variableId === 'cl126jqww000w2e6dq9yv4ifq'
const isCategories = answer.variableId === 'cl126mo3t001b2e6dvyi16bkd'
Expand Down
26 changes: 16 additions & 10 deletions apps/builder/src/features/editor/hooks/useUndo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum ActionType {
Flush = 'FLUSH',
}

export interface Actions<T> {
export interface Actions<T extends { updatedAt: string } | undefined> {
set: (
newPresent: T | ((current: T) => T),
options?: { updateDate: boolean }
Expand All @@ -24,13 +24,13 @@ export interface Actions<T> {
presentRef: React.MutableRefObject<T>
}

interface Action<T> {
interface Action<T extends { updatedAt: string } | undefined> {
type: ActionType
newPresent?: T
updateDate?: boolean
}

export interface State<T> {
export interface State<T extends { updatedAt: string } | undefined> {
past: T[]
present: T
future: T[]
Expand All @@ -42,7 +42,10 @@ const initialState = {
future: [],
}

const reducer = <T>(state: State<T>, action: Action<T>) => {
const reducer = <T extends { updatedAt: string } | undefined>(
state: State<T>,
action: Action<T>
) => {
const { past, present, future } = state

switch (action.type) {
Expand Down Expand Up @@ -98,8 +101,6 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
past: [...past, present].filter(isDefined),
present: {
...newPresent,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
updatedAt: updateDate ? new Date() : newPresent.updatedAt,
},
future: [],
Expand All @@ -111,11 +112,13 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
}
}

const useUndo = <T>(initialPresent: T): [State<T>, Actions<T>] => {
const useUndo = <T extends { updatedAt: string } | undefined>(
initialPresent: T
): [State<T>, Actions<T>] => {
const [state, dispatch] = useReducer(reducer, {
...initialState,
present: initialPresent,
}) as [State<T>, React.Dispatch<Action<T>>]
})
const presentRef = useRef<T>(initialPresent)

const canUndo = state.past.length !== 0
Expand All @@ -136,7 +139,7 @@ const useUndo = <T>(initialPresent: T): [State<T>, Actions<T>] => {
const set = useCallback(
(newPresent: T | ((current: T) => T), options = { updateDate: true }) => {
const updatedTypebot =
'id' in newPresent
newPresent && 'id' in newPresent
? newPresent
: (newPresent as (current: T) => T)(presentRef.current)
presentRef.current = updatedTypebot
Expand All @@ -153,7 +156,10 @@ const useUndo = <T>(initialPresent: T): [State<T>, Actions<T>] => {
dispatch({ type: ActionType.Flush })
}, [])

return [state, { set, undo, redo, flush, canUndo, canRedo, presentRef }]
return [
state as State<T>,
{ set, undo, redo, flush, canUndo, canRedo, presentRef },
]
}

export default useUndo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const editorContext = createContext<{
setRightPanel: Dispatch<SetStateAction<RightPanel | undefined>>
startPreviewAtGroup: string | undefined
setStartPreviewAtGroup: Dispatch<SetStateAction<string | undefined>>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
}>({})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const typebotContext = createContext<
ItemsActions &
VariablesActions &
EdgesActions
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
>({})

Expand Down
1 change: 0 additions & 1 deletion apps/builder/src/features/folders/TypebotDndProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const typebotDndContext = createContext<{
setDraggedTypebot: Dispatch<SetStateAction<TypebotInDashboard | undefined>>
mouseOverFolderId?: string | null
setMouseOverFolderId: Dispatch<SetStateAction<string | undefined | null>>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
}>({})

Expand Down
Loading

5 comments on commit 451ffbc

@vercel
Copy link

@vercel vercel bot commented on 451ffbc Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 451ffbc Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
cares.urlabout.me
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
sellmycarglasgow.com
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
abutton.wpwakanda.com
aidigitalmarketing.kr
bbutton.wpwakanda.com
bot.incusservices.com
bot.meuesocial.com.br
bot.ramonmatos.com.br
cdd.searchcube.com.sg
chat.missarkansas.org
sbutton.wpwakanda.com
815639944.21000000.one
aplicacao.bmind.com.br
apply.ansuraniphone.my
bbutton.wpwwakanda.com
bot.louismarcondes.com
bot.t20worldcup.com.au
c23111azqw.nigerias.io
felipewelington.com.br
form.searchcube.com.sg
gcase.barrettamario.it
help.giversforgood.com
info.clickasuransi.com
kodawariab736.skeep.it
my.swamprecordsgnv.com
premium.kandabrand.com
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
bot.blackboxtips.com.br
bot.upgradesolutions.eu
help.comebackreward.com
mainmenu.diddancing.com
register.kandabrand.com
signup.hypemarketing.in
subfooter.wpwakanda.com
survey.hypemarketing.in
testbot.afterorigin.com
91181264.your-access.one
ai.chromebookstoreph.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
instant.botscientis.info
link.cascadigital.com.br
onboarding.growthside.io
reward.onlinebotdemo.xyz
type.opaulovieira.com.br
aibot.angrybranding.co.uk
bot.aidigitalmarketing.kr
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
bot.cabinrentalagency.com
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
chat.ertcrebateportal.com
chat.thisiscrushhouse.com
sellmyharleylouisiana.com
verfica.botmachine.com.br
configurator.bouclidom.com
help.atlasoutfittersk9.com
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
piazzatorre.barrettamario.it
requests.swamprecordsgnv.com
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
yourfeedback.comebackreward.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
viewer-v2-alpha-typebot-io.vercel.app
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 451ffbc Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 451ffbc Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 451ffbc Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.