Skip to content

Commit

Permalink
adding eslintrc file to avoid problems with class components
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabiana Fonseca committed Jun 30, 2020
1 parent e54983d commit 777dddc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "vtex",
"root": true,
"env": {
"node": true,
"es6": true,
"jest": true
},
"rules": {
"react/prefer-stateless-function": false
}
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ docs/_book/
npm-debug.log
.build/
lib
.eslintrc
base
11 changes: 11 additions & 0 deletions react/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "vtex-react/io",
"env": {
"browser": true,
"es6": true,
"jest": true
},
"rules": {
"react/prefer-stateless-function": false
}
}
3 changes: 1 addition & 2 deletions react/components/CustomButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react'

import Table from './Table'
import { OrderFormItem } from '../typings/orderForm'

/**
* This component is responsible for rendering the custom button itself. For instance,
Expand All @@ -27,6 +26,6 @@ interface CustomButtonProps {
items: OrderFormItem[]
}

// interface CustomButtonState {}
interface CustomButtonState {}

export default CustomButton
2 changes: 0 additions & 2 deletions react/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { Component } from 'react'

import { OrderFormItem } from '../typings/orderForm'

class Table extends Component<TableProps> {
constructor(props: any) {
super(props)
Expand Down
9 changes: 2 additions & 7 deletions react/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import React, { Component } from 'react'

import CustomButton from './components/CustomButton'
import { OrderForm } from './typings/orderForm'

class CheckoutButtonExample extends React.Component<
{},
CheckoutButtonExampleState
> {
class CheckoutButtonExample extends Component<{}, CheckoutButtonExampleState> {
/**
* This component is the one that is referenced in the extension point. To use it
* as an example, we add an event listener, which updates the state every time the
Expand All @@ -28,14 +24,13 @@ class CheckoutButtonExample extends React.Component<

public render() {
this.listenOrderFormUpdated()

console.log(window.vtex.i18n.getLocale())

return <CustomButton {...this.state.orderForm!} />
}
}

// interface CheckoutButtonExampleProps {}
interface CheckoutButtonExampleProps {}

interface CheckoutButtonExampleState {
orderForm: OrderForm | null
Expand Down
2 changes: 1 addition & 1 deletion react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"include": [
"./**/*.tsx",
"typings.d.ts"
"./**/*.d.ts"
],
"exclude": [
"node_modules"
Expand Down
10 changes: 5 additions & 5 deletions react/typings/orderForm.d.ts → react/typings/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
declare global {
type Window = any
interface Window extends Window {
vtex: any
}

export interface OrderFormContext {
interface OrderFormContext {
orderForm: OrderForm
loading: boolean
}

export interface OrderFormItem {
interface OrderFormItem {
additionalInfo: ItemAdditionalInfo
availability: string
detailUrl: string
Expand Down Expand Up @@ -38,7 +38,7 @@ interface SKUSpecification {
fieldValues: string[]
}

export interface OrderForm {
interface OrderForm {
id: string
items: OrderFormItem[]
marketingData: MarketingData
Expand Down

0 comments on commit 777dddc

Please sign in to comment.