Skip to content

Commit

Permalink
wip eslint: Disable no-undef-init; undo its effects on our code.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Nov 11, 2020
1 parent 163baed commit 0efafc6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ rules:
no-plusplus: off
no-nested-ternary: off

# We prefer `let foo = undefined;` over `let foo;`, not vice versa.
#
# Sadly there doesn't seem to be a rule to say what we want, but at least
# turn off the one that says the opposite.
#
# This rule is dubious to begin with, because explicit is better than
# implicit. Then for us, the overriding reason we definitely don't
# want it is that plain `let foo;` can trigger a Flow bug:
# https://github.com/facebook/flow/issues/8526
# while `let foo = undefined;` makes Flow handle the logic smoothly.
no-undef-init: off

# Allow multiple classes per file.
#
# It's best to have just one class per file, but there are cases
Expand Down
2 changes: 1 addition & 1 deletion src/caughtup/caughtUpReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default (state: CaughtUpState = initialState, action: Action): CaughtUpSt
return state;
}
const key = JSON.stringify(action.narrow);
let caughtUp;
let caughtUp = undefined;
if (action.foundNewest !== undefined && action.foundOldest !== undefined) {
/* This should always be the case for Zulip Server v1.8 or newer. */
caughtUp = { older: action.foundOldest, newer: action.foundNewest };
Expand Down
2 changes: 1 addition & 1 deletion src/compose/ComposeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ComposeMenu extends PureComponent<Props> {
// from this library when in the test environment.
const DocumentPicker = (await import('react-native-document-picker')).default;

let response;
let response = undefined;
try {
response = (await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
Expand Down
1 change: 0 additions & 1 deletion src/message/renderMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default (
): RenderedSectionDescriptor[] => {
const showHeader = !isPrivateOrGroupNarrow(narrow) && !isTopicNarrow(narrow);

// eslint-disable-next-line no-undef-init
let prevItem = undefined;
const sections = [{ key: 0, data: [], message: {} }];
messages.forEach(item => {
Expand Down
2 changes: 1 addition & 1 deletion src/webview/js/generatedEs3.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ var compiledWebviewJs = (function (exports) {
var scrollEventsDisabled = true;
var hasLongPressed = false;
var longPressTimeout;
var longPressTimeout = undefined;
var lastTouchPositionX = -1;
var lastTouchPositionY = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/webview/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ const sendScrollMessageIfListShort = () => {
let scrollEventsDisabled = true;

let hasLongPressed = false;
let longPressTimeout;
let longPressTimeout = undefined;
let lastTouchPositionX = -1;
let lastTouchPositionY = -1;

Expand Down

0 comments on commit 0efafc6

Please sign in to comment.