Skip to content
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

[WIP] Revert "Revert "Bump ESLint, prettier and stylelint"" #2056

Closed
wants to merge 1 commit into from

Conversation

odinuge
Copy link
Member

@odinuge odinuge commented Nov 11, 2020

Reverts #2055

EDIT: This is solved by: #2084

Copy link
Member Author

@odinuge odinuge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Would be nice if you could split the various things into separate commits, so that we can review flow changes separate from logical changes in the code.

@@ -175,13 +173,13 @@ const ReactionPicker = ({
return searchEmojis(emojis, searchString);
}, [searchString, emojis]);

const onCategoryClick = useCallback((category) => {
const onCategoryClick = (category) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the warning/reason for this? I guess we should declare an empty array as deps, but not sure why it warns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was caused by: warning React Hook useCallback does nothing when called with only one argument. Did you forget to pass an array of dependencies? react-hooks/exhaustive-deps` eslint-plugin-react-hooks
Fixed this by passing an empty array as you suggested. 💯

@@ -273,7 +273,7 @@ export default class Table extends Component<Props, State> {

const match = Object.keys(this.state.filters).filter((key) => {
const { inlineFiltering = true, filterMapping = (val) => val } =
this.props.columns.find((col) => col.dataIndex == key) || {};
this.props.columns.find((col) => col.dataIndex === key) || {};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure this logic stays 100% similar and works if the dataIndex is a number?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as i can tell, dataIndex is always a string (In our codebase). If the dataIndex is a "number", it will probably just be typeof string anyways. 🤷

@@ -327,7 +330,7 @@ export const selectAllRegistrationsForEvent = createSelector(
updatedBy,
});
})
.filter((reg) => reg.event == eventId)
.filter((reg) => reg.event === eventId)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rip int and string comparison. Fixed by wrapping eventId in parseInt()

@@ -95,6 +95,7 @@ function loadData({ query, match: { params }, location }, dispatch) {

function mapStateToProps(state, props) {
const { pathname, search } = state.router.location;
// eslint-disable-next-line no-restricted-globals
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about fixing this instead of ignoring it, since the warning is legit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I fixed this with window.location instead of location and ConfirmModalWithParent instead of confirm()

@@ -44,9 +44,12 @@ const GroupMembersList = ({
filters,
}: Props) => {
const GroupMembersListColumns = (fullName, membership) => {
console.log(groupsById);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ripperino 😅

@@ -155,6 +158,7 @@ export const getContactedStatuses = (
) {
contacted.splice(contacted.indexOf(status), 1);
}
return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have a map and not a forEach here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. Moved these to forEach.

'403': 'Denne siden har du ikke tilgang på',
'404': 'Denne siden finnes ikke',
'500': 'Noe gikk veldig galt, Webkom er på saken!',
// Non-string literal property keys is not supported in flow yet
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, is there a reason?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue in the latest version of eslint.

@@ -53,10 +53,12 @@ const OnKeyDownHandler = ({
}) => (
useEffect(
() => (
// eslint-disable-next-line no-sequences
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have to have this warning, isn't it better to just rewrite the code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed these, but I am unsure of the () => (func1(), func2()) syntax meaning. Does this first execute func1, and then return func2? Hopefully you can review my suggested solution in my recently created PR. 🙂

@@ -158,6 +158,7 @@ const validateMandatory = (inputAnswers: Array<Object>, props) => {
if (question.mandatory && !answeredQuestionIds.includes(question.id)) {
errors.questions[question.id] = 'Dette feltet er obligatorisk';
}
return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, moved to forEach. 😄

@@ -158,6 +160,7 @@ export function deleteEntities(deleteTypes: ?EntityReducerTypes) {
? [Number(resultId), resultId.toString()]
: [resultId])
),
// eslint-disable-next-line no-sequences
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rewrite this instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unsure of the syntax here 🙂, but I think the rewrite should be about right. 🙃

@AdrianAndersen
Copy link
Member

This PR should be resolved in #2084

@odinuge odinuge closed this Jan 1, 2021
@ivarnakken ivarnakken deleted the revert-2055-revert-2041-bumpESLint branch March 8, 2022 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants