Skip to content
Merged
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lint-staged.config.js
jest.config.js
17 changes: 6 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"plugins": ["jest"],
"extends": [
"@doist/eslint-config/recommended-requiring-type-checking",
"@doist/eslint-config/react",
"react-app",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:jest/recommended",
"prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier/@typescript-eslint"
"plugin:jest/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -30,9 +25,8 @@
"webpack.config.*"
],
"rules": {
"prettier/prettier": "error",
"react/no-did-mount-set-state": "error",
"react/no-did-update-set-state": "error",
"func-style": "off",
"import/no-default-export": "off", // Legacy API.
"react/no-find-dom-node": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": "off"
Expand All @@ -43,6 +37,7 @@
// jest mocks are hard to type, allow incomplete types in tests.
"files": ["stories/**/*", "*.test.*"],
"rules": {
"react/no-unescaped-entities": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.10.1",
"@babel/register": "^7.0.0",
"@doist/eslint-config": "^3.0.0",
"@doist/prettier-config": "^3.0.5",
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-docs": "^5.3.18",
Expand Down
2 changes: 2 additions & 0 deletions src/components/avatar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function getInitials(name?: string) {
const lastInitial = seed[seed.length - 1]

let initials = firstInitial[0]
// Better readable this way.
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
if (firstInitial[0] !== lastInitial[0]) {
initials += lastInitial[0]
}
Expand Down
8 changes: 0 additions & 8 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'

import { Tooltip } from '../tooltip'
Expand Down Expand Up @@ -77,13 +76,6 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(

Button.displayName = 'Button'

Button.propTypes = {
loading: PropTypes.bool,
variant: PropTypes.oneOf(['primary', 'secondary', 'danger', 'link']),
size: PropTypes.oneOf(['default', 'small', 'large']),
tooltip: PropTypes.node,
}

Button.defaultProps = {
size: 'default',
loading: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'
import { shallow, mount } from 'enzyme'
import toJson from 'enzyme-to-json'

import * as Modal from './modal'
import { default as Modal } from '../modal'
import type { Modal as ModalType } from '../modal'
import Button from '../button' // for more descriptive snapshots

Expand Down
11 changes: 11 additions & 0 deletions src/components/time/time-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import dayjs from 'dayjs'
/**
* There's a problem with our setup where the default export from
* localizedFormat (and likely every other dayjs plugin) isn't properly
* recognized. The proposed workarounds (importing with `.js` ending, or adding
* `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type
* checking. After spending some time on this it was decided that further
* investigations are not worth it, the code works and the eslint ignore is fine.
* ref: https://github.com/iamkun/dayjs/issues/593
* ref: https://day.js.org/docs/en/installation/typescript
*/
// eslint-disable-next-line import/default
import LocalizedFormat from 'dayjs/plugin/localizedFormat'

dayjs.extend(LocalizedFormat)
Expand Down
2 changes: 1 addition & 1 deletion stories/components/ButtonStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function StandardButtonsStory() {
<Button>Plain Button</Button>
<p>
You can <Button variant="link">add link buttons inline</Button> and it works as
you'd expect.
you&apos;d expect.
</p>
</section>
)
Expand Down
6 changes: 4 additions & 2 deletions stories/components/MenuStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function SimpleMenuExample() {

const SimpleMenuChapter = {
subtitle: 'Some menu examples',
// eslint-disable-next-line react/display-name
sections: [{ sectionFn: () => <SimpleMenuExample />, options: optionsSourceOnly }],
}

Expand Down Expand Up @@ -154,8 +155,8 @@ function OverflowMenuExample() {
be used as a context menu).
</p>
<ul>
{items.map((item) => (
<Item {...item} />
{items.map((item, index) => (
<Item key={index} {...item} />
))}
</ul>
</section>
Expand All @@ -164,6 +165,7 @@ function OverflowMenuExample() {

const OverflowMenuChapter = {
subtitle: 'A list of items with an overflow options menu',
// eslint-disable-next-line react/display-name
sections: [{ sectionFn: () => <OverflowMenuExample />, options: optionsSourceOnly }],
}

Expand Down
3 changes: 2 additions & 1 deletion stories/components/ModalStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { withKnobs, text, boolean } from '@storybook/addon-knobs'

import { optionsNoSourceNoProps } from '../utils/StoryUtils'

import Modal from '../../src/components/modal'
import { default as Modal } from '../../src/components/modal'
import Button from '../../src/components/button'

import {
howToText,
modalBoxText,
Expand Down