Skip to content

Commit

Permalink
chore(eslint): use eslint in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Feb 19, 2018
1 parent 5f947aa commit 6749215
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 19 deletions.
8 changes: 7 additions & 1 deletion .eslintignore
Expand Up @@ -3,6 +3,12 @@
**/__fixtures__/**/*.js
**/coverage/**
**/flow-typed/**
**/examples/**
**/__tests__/fixtures**
**/s2s-templates-redux/templates/**
s2s.config.js
**/examples/react-class-to-sfc/**
**/examples/import-css/**
**/examples/getting-started/**
**/examples/**/registerServiceWorker.js
**/examples/**/tempPolyfills.js
**/examples/**/setupTests.js
6 changes: 6 additions & 0 deletions examples/shopping-cart/.eslintrc.json
@@ -0,0 +1,6 @@
{
"extends": ["precure/react"],
"rules": {
"import/extensions": 0
}
}
4 changes: 2 additions & 2 deletions examples/shopping-cart/src/api/shop.js
Expand Up @@ -3,15 +3,15 @@ import _products from './products.json'

const TIMEOUT = 100

export function getProducts(cb: Function, timeout: number = TIMEOUT) {
export function getProducts(cb: (*) => void, timeout: number = TIMEOUT) {
setTimeout(() => {
cb(_products)
}, timeout)
}

export function buyProducts(
payload: *,
cb: Function,
cb: () => void,
timeout: number = TIMEOUT
) {
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/shopping-cart/src/components/Cart/index.js
Expand Up @@ -6,7 +6,7 @@ import Product from '../Product'
type Props = {
products: ProductType[],
total: string,
onCheckoutClicked: Function,
onCheckoutClicked: () => void,
}

const Cart = (props: Props) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/shopping-cart/src/components/Cart/index.test.js
Expand Up @@ -2,8 +2,8 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import toJson from 'enzyme-to-json'
import Comp from '.'
import Product from '../Product'
import Comp from '.'

const setup = (total = '0', products = []) => {
const actions = {
Expand All @@ -13,7 +13,7 @@ const setup = (total = '0', products = []) => {
const comp = shallow(<Comp products={products} total={total} {...actions} />)

return {
comp: comp,
comp,
actions,
button: comp.find('button'),
products: comp.find(Product),
Expand Down
Expand Up @@ -8,7 +8,7 @@ const setup = props => {
const comp = shallow(<Comp {...props} />)

return {
comp: comp,
comp,
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/shopping-cart/src/components/ProductItem/index.js
Expand Up @@ -5,7 +5,7 @@ import Product from '../Product'

type Props = {
product: ProductType,
onAddToCartClicked: Function,
onAddToCartClicked: () => void,
}

const ProductItem = ({ product, onAddToCartClicked }: Props) => (
Expand Down
Expand Up @@ -13,8 +13,8 @@ const setup = product => {
const component = shallow(<ProductItem product={product} {...actions} />)

return {
component: component,
actions: actions,
component,
actions,
button: component.find('button'),
product: component.find(Product),
}
Expand Down
Expand Up @@ -8,7 +8,7 @@ const setup = (props: Props) => {
const comp = shallow(<Comp {...props}>{props.children}</Comp>)

return {
comp: comp,
comp,
children: comp.children().at(1),
h3: comp.find('h3'),
}
Expand Down
Expand Up @@ -9,7 +9,7 @@ import { checkout } from './logic'
type Props = {
products: ProductInCart[],
total: string,
checkout: Function,
checkout: () => void,
}

class CartContainer extends React.Component<Props> {
Expand Down
Expand Up @@ -20,12 +20,13 @@ function addedIds<S: number[]>(state: S, action: Action): S {

function quantityById<S: QuantityById>(state: S, action: Action): Exact<S> {
switch (action.type) {
case Actions.ADD_TO_CART:
case Actions.ADD_TO_CART: {
const { productId } = action
return {
...state,
[productId]: (state[productId] || 0) + 1,
}
}
default:
return state
}
Expand Down
@@ -1,6 +1,6 @@
// @flow
import reducer, { initialState } from './reducer'
import * as actions from '../ProductsContainer/actions'
import reducer, { initialState } from './reducer'

test('provide the initial state', () => {
expect(reducer(undefined, { type: '@@INIT' })).toEqual(initialState)
Expand Down
Expand Up @@ -9,7 +9,7 @@ import * as selectors from './selectors'

type Props = {
products: Product[],
addToCart: Function,
addToCart: number => void,
}

class ProductsContainer extends React.Component<Props> {
Expand Down
@@ -1,9 +1,9 @@
// @flow
import type { State } from '../../types'
import * as selectros from './selectors'
import * as actions from './actions'
import reducer from '../../reducer'
import { addToCart } from '../CartContainer/actions'
import * as selectros from './selectors'
import * as actions from './actions'

let state: State

Expand Down
2 changes: 1 addition & 1 deletion examples/shopping-cart/src/registerServiceWorker.js
Expand Up @@ -14,7 +14,7 @@ const isLocalhost = Boolean(
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
/^127(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3}$/
)
)

Expand Down
2 changes: 1 addition & 1 deletion examples/shopping-cart/src/types/index.js
Expand Up @@ -9,7 +9,7 @@ export type Action = _Action
export type GetState = () => State

export type ThunkAction = (
dispatch: Dispatch,
dispatch: Dispatch, // eslint-disable-line no-use-before-define
getState: GetState
) => void | Promise<void>

Expand Down

0 comments on commit 6749215

Please sign in to comment.