Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(lint): lints some files, adds new rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Casasola committed Nov 8, 2019
1 parent c584b54 commit d46fa35
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
19 changes: 10 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,23 @@ module.exports = {
},
plugins: ['react', '@typescript-eslint', 'prettier', 'jest'],
rules: {
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
// 'prettier/prettier': 'error',
'arrow-body-style': ['warn', 'as-needed'],
'react/jsx-one-expression-per-line': 'off',
'react/jsx-wrap-multilines': 'off',
'react/jsx-props-no-spreading': 'off',
'arrow-body-style': ['warn', 'as-needed'],
'no-param-reassign': ['error', { props: false }],
'import/prefer-default-export': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
curly: ['error', 'all'],
'no-console': 'off',
'eol-last': ['error', 'always'],
'no-debugger': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
'no-nested-ternary': 'off',
curly: ['error', 'all'],
},
}
22 changes: 11 additions & 11 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ import { Button, Props as ButtonProps } from '../Button'
import { ButtonsAlignment } from './interfaces'

interface Props {
/** Defines if the modal should be visible.*/
/** Defines if the modal should be visible. */
show: boolean
/** Toggles the modal visibility.*/
/** Toggles the modal visibility. */
toggle(): void
/** Defines the title of the modal.*/
/** Defines the title of the modal. */
title?: string
/** Defines the body of the modal.*/
/** Defines the body of the modal. */
body?: ReactNode
/**
* Renders a close button in modal header.
* @default true
**/
* */
showHeaderCloseButton?: boolean
/**
* Defines if the modal should be vertically centered.
* @default false
**/
* */
verticallyCentered?: boolean
/**
* Defines the buttons alignment.
* @default "edges"
**/
* */
buttonsAlignment?: ButtonsAlignment
/**
* Optional close button properties.
**/
* */
closeButton?: ButtonProps
/**
* Optional middle button properties.
**/
* */
middleButton?: ButtonProps
/**
* Optional success button properties.
**/
* */
successButton?: ButtonProps
}

Expand Down Expand Up @@ -69,7 +69,7 @@ const Modal = (props: Props) => {
onHide={() => toggle()}
>
{(showHeaderCloseButton === false ? title : true) && (
<BootstrapModal.Header closeButton={showHeaderCloseButton === false ? false : true}>
<BootstrapModal.Header closeButton={showHeaderCloseButton !== false}>
{title && <BootstrapModal.Title>{title}</BootstrapModal.Title>}
</BootstrapModal.Header>
)}
Expand Down
7 changes: 4 additions & 3 deletions stories/modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react'
import { storiesOf } from '@storybook/react'
import { Modal } from '../src'
import { Button } from '../src'
import { Modal, Button } from '../src'

storiesOf('Modal', module)
.addParameters({
Expand All @@ -11,7 +10,9 @@ storiesOf('Modal', module)
propTablesExclude: [Button],
},
})
.addDecorator(storyFn => <div style={{ marginLeft: '2em', marginRight: '2em' }}>{storyFn()}</div>)
.addDecorator((storyFn) => (
<div style={{ marginLeft: '2em', marginRight: '2em' }}>{storyFn()}</div>
))
.add('Simple modal', () => {
const [show, setShow] = useState(false)
return (
Expand Down
4 changes: 2 additions & 2 deletions test/modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import { Modal } from '../src'
import BootstrapModal from 'react-bootstrap/Modal'
import { Modal } from '../src'

describe('Modal', () => {
it('Modal renders itself without crashing', () => {
const modalWrapper = shallow(<Modal show={true} toggle={() => {}} />)
const modalWrapper = shallow(<Modal show toggle={() => {}} />)
expect(modalWrapper.find(BootstrapModal)).toHaveLength(1)
})
})

0 comments on commit d46fa35

Please sign in to comment.