-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESLINT] eslint-deprecation plugin implementation (#6914) #8198
base: main
Are you sure you want to change the base?
Conversation
… alternatives. - Self declarated deprecated occurrences were not replaced. - Hooks, components, context and sections of the code that can be potentially harmfull if changed were not replaced, but marked as pending on PR.
💚 CLA has been signed |
👋 Since this is a community submitted pull request, a Buildkite build has not been started automatically. Would an Elastic organization member please verify the contents of this pull request and kick off a build manually? |
Hello! |
@Cedgo1997 thank you so much for your contribution and for signing the CLA! There is nothing that you have to do more! I'll review your PR soon 💚 |
@@ -12,7 +12,7 @@ import type { WrapperProps } from '@docusaurus/types'; | |||
|
|||
type Props = WrapperProps<typeof MDXContentType>; | |||
|
|||
const MDXContent = (props: Props): JSX.Element => ( | |||
const MDXContent = (props: Props): React.JSX.Element => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 how about we import JSX from react
as it's done in other files for consistency?
Same in:
packages/website/src/pages/index.tsx
packages/docusaurus-theme/src/theme/PaginatorNavLink/index.tsx
packages/docusaurus-theme/src/theme/TOCCollapsible/CollapseButton/index.tsx
@@ -63,6 +63,7 @@ export { | |||
wcagContrastMin, | |||
} from './color'; | |||
export type { HSV } from './color'; | |||
// eslint-disable-next-line deprecation/deprecation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 because we've set the rule to warn
and not error
, maybe we can remove this disable comment? That way, it will show up in the list and we will know to address it meaningfully?
Same in: packages/eui/src/services/color_picker/index.ts
@@ -1,4 +1,4 @@ | |||
import { applyMiddleware, createStore, compose } from 'redux'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 following the same logic as with the ESLint disable comments, maybe it'd be better to leave createStore
warning as is to highlight the need to migrate to Redux Toolkit (that is strongly recommended by the Redux team)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 the changes on this PR are purely for development purposes (code quality). They do not contain any bug fixes, functionalities. Consumers don't have to be informed about them through changelog. So we can remove this file and add to the PR skip-changelog
label to unblock the CI checks.
/** | ||
* Replace deprecated type from React as its marked as | ||
* not relevant by eslint deprecation plugin. | ||
* @example | ||
* ```ts | ||
* export function processStringToChildren( | ||
* input: string, | ||
* values: RenderableValues, | ||
* i18nMappingFunc?: (token: string) => string | ||
* ): string | ReactChild[] | ||
* ``` | ||
*/ | ||
export type ReactChild = | ||
| string | ||
| number | ||
| ReactElement<any, string | JSXElementConstructor<any>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 The deprecation note says:
This type is not relevant when using React. Inline the type instead to make the intent clear.
children
are commonly typed as ReactNode
which is a bit broader type including boolean and null but we can pass anything to children
. If there are any type errors because of the change, I'd inline ReactElement | string | number
in all the places where previously ReactChild
has been used, as suggested by the deprecation note.
// used to preserve spaces and line breaks | ||
textElement.style.whiteSpace = 'pre'; | ||
// do not inherit user-select (it may be `none`) | ||
textElement.style.webkitUserSelect = 'text'; | ||
textElement.style.userSelect = 'text'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cedgo1997 userSelect
is already defined below on the line 26. We can just remove the whole line.
Summary
This PR provides:
This PR doesn't contain:
@deprecated
decorator.Implementation:
eslint-plugin-deprecation v2.0.0 (v3.0.0 is not compatible)
.eslintrc.js updated with new rule and plugin added to handle deprecation warns:
Replaced/updated code
Replaced Deprecated Aliases:
toBeCalled
->toHaveBeenCalled
toBeCalledTimes
->toHaveBeenCalledTimes
toBeCalledWith
->toHaveBeenCalledWith
Replaced css style declarations:
clip
->clipPath
webkitUserSelect
->userSelect
Replaced deprecated type declarations:
HTMLTableHeaderCellElement
->HTMLTableCellElement
Others replacements:
createStore
withlegacy_createStore
as adviced.ClientRect
withDomRect
,ClientRect
inherits fromDOMRect
, which is perfectly compatible, but less specific.JSX
imported fromReact
instead of globalJSX
.ReactChild
type declaration insrc/components/common.js
to handle ReactChild deprecation alternative (Type was extracted by original declaration from react).Pending deprecate code (Recommended to open a new issue):
color
prop from_breadcrumb_content.tsx
.useColorStopsState
reported as deprecated.document.execCommand
is reported as deprecated, however, there isn't a known alternative to it.hasDragDrop
frompopover.tsx
.Goal
fromelastic_charts
mark as deprecated by plugin but alternative may require further analysis.EuiFilterSelectItem
andEuiFilterSelectItemClass
are reported as deprecated.PlayFunctionContext
from'@storybook/csf'
is marked as deprecated.name
prop frombutton_group.tsx
.QA
Remove or strikethrough items that do not apply to your PR.
General checklist
- [ ] Checked in both light and dark modes- [ ] Checked in mobile- [ ] Checked in Chrome, Safari, Edge, and Firefox- [ ] Checked for accessibility including keyboard-only and screenreader modes@default
if default values are missing) and playground toggles