Skip to content

Commit

Permalink
wip js: Update prettier-eslint, etc., to latest!!
Browse files Browse the repository at this point in the history
TODO: find out what we actually want :) and finish commit message

Following the eagerly awaited resolution of
  prettier/prettier-eslint-cli#304

- add some @babel/ deps for peer-dep requirements

- resolutions line to get
  prettier/prettier-eslint#749

Fixes: zulip#4254
  • Loading branch information
chrisbobbe committed May 26, 2022
1 parent 86058d8 commit 3db2f86
Show file tree
Hide file tree
Showing 48 changed files with 1,059 additions and 1,282 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# $ git diff --no-index /tmp/{foo,bar}.json


parser: babel-eslint
parser: "@babel/eslint-parser"

extends:
- airbnb
Expand Down Expand Up @@ -204,6 +204,10 @@ rules:
prefer-destructuring:
- error
- AssignmentExpression: {array: false, object: false}
no-promise-executor-return: off # new Promise(r => setTimeout(r), 1000);

# Reasonable, but a bit noisy.
class-methods-use-this: off

# Likely-wrong code
no-unused-vars: [warn, {vars: local, args: none}]
Expand Down Expand Up @@ -285,9 +289,10 @@ rules:
react/prop-types: off # We handle this better with types.
react/require-default-props: off # We handle this better with types.

# These two could be good to fix.
# These could be good to fix.
react/prefer-stateless-function: off
react/sort-comp: off
react/no-unstable-nested-components: off


#
Expand Down Expand Up @@ -343,6 +348,7 @@ overrides:
- files: ['**/__tests__/**', 'jest/jestSetup.js']
rules:
no-restricted-imports: off
no-import-assign: off # Jest mocking

#
# ================================================================
Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,28 @@
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-proposal-numeric-separator": "^7.14.5",
"@babel/plugin-syntax-flow": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@babel/preset-env": "^7.11.0",
"@babel/runtime": "^7.12.5",
"@octokit/core": "^3.4.0",
"@rollup/plugin-babel": "^5.2.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@vusion/webfonts-generator": "^0.8.0",
"babel-eslint": "^10.0.3",
"core-js": "^3.1.4",
"deep-freeze": "^0.0.1",
"eslint": "^7.28.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint": "^8.15.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest": "^26.1.5",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-hooks": "^4.5.0",
"flow-bin": "^0.149.0",
"flow-coverage-report": "^0.8.0",
"flow-typed": "^3.3.1",
Expand All @@ -111,9 +113,9 @@
"jest-extended": "^0.11.5",
"jetifier": "^2.0.0",
"metro-react-native-babel-preset": "^0.66.0",
"prettier": "^1.18.2",
"prettier-eslint": "^12.0.0",
"prettier-eslint-cli": "^5.0.0",
"prettier": "^2.6.2",
"prettier-eslint": "^15.0.0",
"prettier-eslint-cli": "^6.0.1",
"react-native-cli": "^2.0.1",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2",
Expand All @@ -125,6 +127,7 @@
},
"resolutions": {
"jest-expo/react-test-renderer": "17.0.2",
"prettier-eslint-cli/prettier-eslint": "^15.0.0",
"react-native/use-subscription": ">=1.0.0 <1.6.0",
"sqlite3/**/node-gyp": "^8"
}
Expand Down
11 changes: 5 additions & 6 deletions src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,18 @@ const makeAvatarUrl = (tag: string) =>
// here with a full-blown URL object in the first place to prevent that.
new UploadedAvatarURL(new URL(`https://zulip.example.org/yo/avatar-${tag}.png`));

const randUserId: () => UserId = (mk => () => makeUserId(mk()))(
makeUniqueRandInt('user IDs', 10000),
);
const randUserId: () => UserId = (
mk => () =>
makeUserId(mk())
)(makeUniqueRandInt('user IDs', 10000));
const userOrBotProperties = (args: UserOrBotPropertiesArgs) => {
const user_id = args.user_id != null ? makeUserId(args.user_id) : randUserId();
const randName = randString();
return deepFreeze({
avatar_url: args.avatar_url ?? makeAvatarUrl(user_id.toString()),
avatar_version: 0,

date_joined: `2014-04-${randInt(30)
.toString()
.padStart(2, '0')}`,
date_joined: `2014-04-${randInt(30).toString().padStart(2, '0')}`,

email: args.email ?? `${randName}@example.org`,
full_name: args.full_name ?? `${randName} User`,
Expand Down
23 changes: 12 additions & 11 deletions src/account/accountActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const accountSwitchPlain = (index: number): AllAccountsAction => ({
index,
});

export const accountSwitch = (index: number): GlobalThunkAction<void> => (dispatch, getState) => {
NavigationService.dispatch(resetToMainTabs());
dispatch(accountSwitchPlain(index));
};
export const accountSwitch =
(index: number): GlobalThunkAction<void> =>
(dispatch, getState) => {
NavigationService.dispatch(resetToMainTabs());
dispatch(accountSwitchPlain(index));
};

export const removeAccount = (index: number): AllAccountsAction => ({
type: ACCOUNT_REMOVE,
Expand All @@ -41,13 +43,12 @@ const loginSuccessPlain = (realm: URL, email: string, apiKey: string): AllAccoun
apiKey,
});

export const loginSuccess = (realm: URL, email: string, apiKey: string): ThunkAction<void> => (
dispatch,
getState,
) => {
NavigationService.dispatch(resetToMainTabs());
dispatch(loginSuccessPlain(realm, email, apiKey));
};
export const loginSuccess =
(realm: URL, email: string, apiKey: string): ThunkAction<void> =>
(dispatch, getState) => {
NavigationService.dispatch(resetToMainTabs());
dispatch(loginSuccessPlain(realm, email, apiKey));
};

const logoutPlain = (): AllAccountsAction => ({
type: LOGOUT,
Expand Down
8 changes: 4 additions & 4 deletions src/account/accountsSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export type AccountStatus = {| ...Identity, isLoggedIn: boolean |};
* This should be used in preference to `getAccounts` where we don't
* actually need the API keys, but just need to know whether we have them.
*/
export const getAccountStatuses: GlobalSelector<
$ReadOnlyArray<AccountStatus>,
> = createSelector(getAccounts, accounts =>
accounts.map(({ realm, email, apiKey }) => ({ realm, email, isLoggedIn: apiKey !== '' })),
export const getAccountStatuses: GlobalSelector<$ReadOnlyArray<AccountStatus>> = createSelector(
getAccounts,
accounts =>
accounts.map(({ realm, email, apiKey }) => ({ realm, email, isLoggedIn: apiKey !== '' })),
);

/** The list of known accounts, reduced to `Identity`. */
Expand Down
5 changes: 2 additions & 3 deletions src/api/permissionsTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,5 @@ typesEquivalent<CreateWebPublicStreamPolicyT, $Values<typeof CreateWebPublicStre
*
* See CreateWebPublicStreamPolicy for an enum to refer to these by meaningful names.
*/
export const CreateWebPublicStreamPolicyValues: $ReadOnlyArray<CreateWebPublicStreamPolicyT> = objectValues(
CreateWebPublicStreamPolicy,
);
export const CreateWebPublicStreamPolicyValues: $ReadOnlyArray<CreateWebPublicStreamPolicyT> =
objectValues(CreateWebPublicStreamPolicy);
7 changes: 4 additions & 3 deletions src/autocomplete/StreamAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export default function StreamAutocomplete(props: Props): Node {
const { filter, onAutocomplete } = props;
const subscriptions = useSelector(getSubscriptions);

const handleStreamItemAutocomplete = useCallback(stream => onAutocomplete(`**${stream.name}**`), [
onAutocomplete,
]);
const handleStreamItemAutocomplete = useCallback(
stream => onAutocomplete(`**${stream.name}**`),
[onAutocomplete],
);

const isPrefixMatch = x => x.name.toLowerCase().startsWith(filter.toLowerCase());

Expand Down
2 changes: 1 addition & 1 deletion src/chat/__tests__/flagsReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('flagsReducer', () => {
const action = deepFreeze({
type: MESSAGE_FETCH_COMPLETE,
// prettier-ignore
messages: [{ id: 1, flags: ['read'] }, { id: 2, flags: [] }]
messages: [{ id: 1, flags: ['read'] }, { id: 2, flags: [] }],
});

const expectedState = {
Expand Down
6 changes: 2 additions & 4 deletions src/common/ServerCompatBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ export default function ServerCompatBanner(props: Props): Node {
visible = true;
text = isAdmin
? {
text:
'{realm} is running Zulip Server {serverVersion}, which is unsupported. Please upgrade your server as soon as possible.',
text: '{realm} is running Zulip Server {serverVersion}, which is unsupported. Please upgrade your server as soon as possible.',
values: { realm: realm.toString(), serverVersion: zulipVersion.raw() },
}
: {
text:
'{realm} is running Zulip Server {serverVersion}, which is unsupported. Please contact your administrator about upgrading.',
text: '{realm} is running Zulip Server {serverVersion}, which is unsupported. Please contact your administrator about upgrading.',
values: { realm: realm.toString(), serverVersion: zulipVersion.raw() },
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/common/ServerPushSetupBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export default function PushNotifsSetupBanner(props: Props): Node {
visible = true;
text = isAdmin
? {
text:
'The Zulip server at {realm} is not set up to deliver push notifications. Please contact your administrator.',
text: 'The Zulip server at {realm} is not set up to deliver push notifications. Please contact your administrator.',
values: { realm: realm.toString() },
}
: {
Expand Down
5 changes: 1 addition & 4 deletions src/common/ZulipStatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export default function ZulipStatusBar(props: Props): Node {
animated
showHideTransition="slide"
hidden={hidden && Platform.OS !== 'android'}
backgroundColor={Color(statusBarColor)
.darken(0.1)
.hsl()
.string()}
backgroundColor={Color(statusBarColor).darken(0.1).hsl().string()}
barStyle={getStatusBarStyle(statusBarColor)}
/>
)
Expand Down
4 changes: 1 addition & 3 deletions src/common/ZulipSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export default function ZulipSwitch(props: Props): Node {
value={value}
trackColor={{
false: 'hsl(0, 0%, 86%)',
true: Color(BRAND_COLOR)
.fade(0.3)
.toString(),
true: Color(BRAND_COLOR).fade(0.3).toString(),
}}
thumbColor={
/* eslint-disable operator-linebreak */
Expand Down
5 changes: 2 additions & 3 deletions src/compose/MentionWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ function MentionWarningsInner(props: Props, ref): Node {
return mentionWarnings;
}

const MentionWarnings: AbstractComponent<Props, ImperativeHandle> = forwardRef(
MentionWarningsInner,
);
const MentionWarnings: AbstractComponent<Props, ImperativeHandle> =
forwardRef(MentionWarningsInner);

export default MentionWarnings;
Loading

0 comments on commit 3db2f86

Please sign in to comment.