Unexpected any types replaced (#160)

* Any types replaced

* No console rule disabled
This commit is contained in:
Guzel738 2021-01-26 21:42:16 +03:00 committed by GitHub
parent 9f3ae3a614
commit 3c843e1266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 9 deletions

View file

@ -28,7 +28,8 @@
"prettier/prettier": "error",
"@typescript-eslint/explicit-module-boundary-types": "off",
"jsx-a11y/label-has-associated-control": "off",
"import/prefer-default-export": "off"
"import/prefer-default-export": "off",
"@typescript-eslint/no-explicit-any": "error"
},
"overrides": [
{

View file

@ -38,8 +38,8 @@ interface FilterProps {
partition: TopicMessage['partition'];
}
function usePrevious(value: any) {
const ref = useRef();
function usePrevious(value: Date | null) {
const ref = useRef<Date | null>();
useEffect(() => {
ref.current = value;
});
@ -73,7 +73,8 @@ const Messages: React.FC<Props> = ({
Partial<TopicMessageQueryParams>
>({ limit: 100 });
const [debouncedCallback] = useDebouncedCallback(
(query: any) => setQueryParams({ ...queryParams, ...query }),
(query: Partial<TopicMessageQueryParams>) =>
setQueryParams({ ...queryParams, ...query }),
1000
);
@ -98,7 +99,7 @@ const Messages: React.FC<Props> = ({
);
}, [messages, partitions]);
const getSeekToValuesForPartitions = (partition: any) => {
const getSeekToValuesForPartitions = (partition: Option) => {
const foundedValues = filterProps.find(
(prop) => prop.partition === partition.value
);
@ -178,7 +179,7 @@ const Messages: React.FC<Props> = ({
return format(date, 'yyyy-MM-dd HH:mm:ss');
};
const getMessageContentBody = (content: any) => {
const getMessageContentBody = (content: Record<string, unknown>) => {
try {
const contentObj =
typeof content !== 'object' ? JSON.parse(content) : content;
@ -226,7 +227,7 @@ const Messages: React.FC<Props> = ({
});
};
const filterOptions = (options: Option[], filter: any) => {
const filterOptions = (options: Option[], filter: string) => {
if (!filter) {
return options;
}
@ -256,7 +257,10 @@ const Messages: React.FC<Props> = ({
<td style={{ width: 150 }}>{message.offset}</td>
<td style={{ width: 100 }}>{message.partition}</td>
<td key={Math.random()} style={{ wordBreak: 'break-word' }}>
{getMessageContentBody(message.content)}
{message.content &&
getMessageContentBody(
message.content as Record<string, unknown>
)}
</td>
</tr>
))}

View file

@ -2,11 +2,17 @@ import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../../reducers';
declare global {
interface Window {
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
}
}
export default () => {
const middlewares = [thunk];
const composeEnhancers =
(window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(applyMiddleware(...middlewares));

View file

@ -9,6 +9,7 @@
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
/* eslint-disable no-console */
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||