Browse Source

Code style improvements in JavaScript (#13159)

* JS-linter: fix trailing comma's

* Configure eslinter to ignore this onchange error.
master
Bèr Kessels 4 years ago
committed by GitHub
parent
commit
fd76955f39
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 28 additions and 27 deletions
  1. +1
    -1
      app/javascript/mastodon/actions/accounts.js
  2. +1
    -1
      app/javascript/mastodon/components/intersection_observer_article.js
  3. +1
    -1
      app/javascript/mastodon/features/blocks/index.js
  4. +1
    -0
      app/javascript/mastodon/features/compose/components/poll_form.js
  5. +1
    -1
      app/javascript/mastodon/features/domain_blocks/index.js
  6. +1
    -1
      app/javascript/mastodon/features/favourites/index.js
  7. +1
    -1
      app/javascript/mastodon/features/follow_requests/index.js
  8. +1
    -1
      app/javascript/mastodon/features/followers/index.js
  9. +1
    -1
      app/javascript/mastodon/features/following/index.js
  10. +4
    -4
      app/javascript/mastodon/features/getting_started/index.js
  11. +1
    -1
      app/javascript/mastodon/features/lists/index.js
  12. +1
    -1
      app/javascript/mastodon/features/mutes/index.js
  13. +1
    -1
      app/javascript/mastodon/features/reblogs/index.js
  14. +1
    -1
      app/javascript/mastodon/features/status/components/card.js
  15. +1
    -1
      app/javascript/mastodon/features/ui/components/__tests__/column-test.js
  16. +2
    -2
      app/javascript/mastodon/reducers/notifications.js
  17. +2
    -2
      app/javascript/mastodon/reducers/timelines.js
  18. +1
    -1
      app/javascript/mastodon/selectors/index.js
  19. +1
    -1
      app/javascript/mastodon/service_worker/web_push_notifications.js
  20. +1
    -1
      app/javascript/mastodon/store/configureStore.js
  21. +1
    -1
      config/webpack/development.js
  22. +2
    -2
      config/webpack/shared.js

+ 1
- 1
app/javascript/mastodon/actions/accounts.js View File

@ -106,7 +106,7 @@ export function fetchAccount(id) {
dispatch, dispatch,
getState, getState,
db.transaction('accounts', 'read').objectStore('accounts').index('id'), db.transaction('accounts', 'read').objectStore('accounts').index('id'),
id
id,
).then(() => db.close(), error => { ).then(() => db.close(), error => {
db.close(); db.close();
throw error; throw error;

+ 1
- 1
app/javascript/mastodon/components/intersection_observer_article.js View File

@ -44,7 +44,7 @@ export default class IntersectionObserverArticle extends React.Component {
intersectionObserverWrapper.observe( intersectionObserverWrapper.observe(
id, id,
this.node, this.node,
this.handleIntersection
this.handleIntersection,
); );
this.componentMounted = true; this.componentMounted = true;

+ 1
- 1
app/javascript/mastodon/features/blocks/index.js View File

@ -68,7 +68,7 @@ class Blocks extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{accountIds.map(id => {accountIds.map(id =>
<AccountContainer key={id} id={id} />
<AccountContainer key={id} id={id} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 0
app/javascript/mastodon/features/compose/components/poll_form.js View File

@ -155,6 +155,7 @@ class PollForm extends ImmutablePureComponent {
<div className='poll__footer'> <div className='poll__footer'>
<button disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button> <button disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
{/* eslint-disable-next-line jsx-a11y/no-onchange */}
<select value={expiresIn} onChange={this.handleSelectDuration}> <select value={expiresIn} onChange={this.handleSelectDuration}>
<option value={300}>{intl.formatMessage(messages.minutes, { number: 5 })}</option> <option value={300}>{intl.formatMessage(messages.minutes, { number: 5 })}</option>
<option value={1800}>{intl.formatMessage(messages.minutes, { number: 30 })}</option> <option value={1800}>{intl.formatMessage(messages.minutes, { number: 30 })}</option>

+ 1
- 1
app/javascript/mastodon/features/domain_blocks/index.js View File

@ -69,7 +69,7 @@ class Blocks extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{domains.map(domain => {domains.map(domain =>
<DomainContainer key={domain} domain={domain} />
<DomainContainer key={domain} domain={domain} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/favourites/index.js View File

@ -79,7 +79,7 @@ class Favourites extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{accountIds.map(id => {accountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />
<AccountContainer key={id} id={id} withNote={false} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/follow_requests/index.js View File

@ -68,7 +68,7 @@ class FollowRequests extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{accountIds.map(id => {accountIds.map(id =>
<AccountAuthorizeContainer key={id} id={id} />
<AccountAuthorizeContainer key={id} id={id} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/followers/index.js View File

@ -93,7 +93,7 @@ class Followers extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{blockedBy ? [] : accountIds.map(id => {blockedBy ? [] : accountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />
<AccountContainer key={id} id={id} withNote={false} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/following/index.js View File

@ -93,7 +93,7 @@ class Following extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{blockedBy ? [] : accountIds.map(id => {blockedBy ? [] : accountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />
<AccountContainer key={id} id={id} withNote={false} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 4
- 4
app/javascript/mastodon/features/getting_started/index.js View File

@ -106,20 +106,20 @@ class GettingStarted extends ImmutablePureComponent {
if (profile_directory) { if (profile_directory) {
navItems.push( navItems.push(
<ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} to='/directory' />
<ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} to='/directory' />,
); );
height += 48; height += 48;
} }
navItems.push( navItems.push(
<ColumnSubheading key={i++} text={intl.formatMessage(messages.personal)} />
<ColumnSubheading key={i++} text={intl.formatMessage(messages.personal)} />,
); );
height += 34; height += 34;
} else if (profile_directory) { } else if (profile_directory) {
navItems.push( navItems.push(
<ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} to='/directory' />
<ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} to='/directory' />,
); );
height += 48; height += 48;
@ -129,7 +129,7 @@ class GettingStarted extends ImmutablePureComponent {
<ColumnLink key={i++} icon='envelope' text={intl.formatMessage(messages.direct)} to='/timelines/direct' />, <ColumnLink key={i++} icon='envelope' text={intl.formatMessage(messages.direct)} to='/timelines/direct' />,
<ColumnLink key={i++} icon='bookmark' text={intl.formatMessage(messages.bookmarks)} to='/bookmarks' />, <ColumnLink key={i++} icon='bookmark' text={intl.formatMessage(messages.bookmarks)} to='/bookmarks' />,
<ColumnLink key={i++} icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />, <ColumnLink key={i++} icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />,
<ColumnLink key={i++} icon='list-ul' text={intl.formatMessage(messages.lists)} to='/lists' />
<ColumnLink key={i++} icon='list-ul' text={intl.formatMessage(messages.lists)} to='/lists' />,
); );
height += 48*4; height += 48*4;

+ 1
- 1
app/javascript/mastodon/features/lists/index.js View File

@ -74,7 +74,7 @@ class Lists extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{lists.map(list => {lists.map(list =>
<ColumnLink key={list.get('id')} to={`/timelines/list/${list.get('id')}`} icon='list-ul' text={list.get('title')} />
<ColumnLink key={list.get('id')} to={`/timelines/list/${list.get('id')}`} icon='list-ul' text={list.get('title')} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/mutes/index.js View File

@ -68,7 +68,7 @@ class Mutes extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{accountIds.map(id => {accountIds.map(id =>
<AccountContainer key={id} id={id} />
<AccountContainer key={id} id={id} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/reblogs/index.js View File

@ -79,7 +79,7 @@ class Reblogs extends ImmutablePureComponent {
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
> >
{accountIds.map(id => {accountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />
<AccountContainer key={id} id={id} withNote={false} />,
)} )}
</ScrollableList> </ScrollableList>
</Column> </Column>

+ 1
- 1
app/javascript/mastodon/features/status/components/card.js View File

@ -98,7 +98,7 @@ export default class Card extends React.PureComponent {
}, },
}, },
]), ]),
0
0,
); );
}; };

+ 1
- 1
app/javascript/mastodon/features/ui/components/__tests__/column-test.js View File

@ -19,7 +19,7 @@ describe('', () => {
const wrapper = mount( const wrapper = mount(
<Column heading='notifications'> <Column heading='notifications'>
<div className='scrollable' /> <div className='scrollable' />
</Column>
</Column>,
); );
wrapper.find(ColumnHeader).find('button').simulate('click'); wrapper.find(ColumnHeader).find('button').simulate('click');
expect(global.requestAnimationFrame.mock.calls.length).toEqual(1); expect(global.requestAnimationFrame.mock.calls.length).toEqual(1);

+ 2
- 2
app/javascript/mastodon/reducers/notifications.js View File

@ -72,11 +72,11 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingRece
mutable.update(usePendingItems ? 'pendingItems' : 'items', list => { mutable.update(usePendingItems ? 'pendingItems' : 'items', list => {
const lastIndex = 1 + list.findLastIndex( const lastIndex = 1 + list.findLastIndex(
item => item !== null && (compareId(item.get('id'), items.last().get('id')) > 0 || item.get('id') === items.last().get('id'))
item => item !== null && (compareId(item.get('id'), items.last().get('id')) > 0 || item.get('id') === items.last().get('id')),
); );
const firstIndex = 1 + list.take(lastIndex).findLastIndex( const firstIndex = 1 + list.take(lastIndex).findLastIndex(
item => item !== null && compareId(item.get('id'), items.first().get('id')) > 0
item => item !== null && compareId(item.get('id'), items.first().get('id')) > 0,
); );
return list.take(firstIndex).concat(items, list.skip(lastIndex)); return list.take(firstIndex).concat(items, list.skip(lastIndex));

+ 2
- 2
app/javascript/mastodon/reducers/timelines.js View File

@ -54,7 +54,7 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is
return oldIds.take(firstIndex + 1).concat( return oldIds.take(firstIndex + 1).concat(
isPartial && oldIds.get(firstIndex) !== null ? newIds.unshift(null) : newIds, isPartial && oldIds.get(firstIndex) !== null ? newIds.unshift(null) : newIds,
oldIds.skip(lastIndex)
oldIds.skip(lastIndex),
); );
}); });
} }
@ -166,7 +166,7 @@ export default function timelines(state = initialState, action) {
return state.update( return state.update(
action.timeline, action.timeline,
initialTimeline, initialTimeline,
map => map.set('online', false).update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items)
map => map.set('online', false).update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items),
); );
default: default:
return state; return state;

+ 1
- 1
app/javascript/mastodon/selectors/index.js View File

@ -117,7 +117,7 @@ export const makeGetStatus = () => {
map.set('account', accountBase); map.set('account', accountBase);
map.set('filtered', filtered); map.set('filtered', filtered);
}); });
}
},
); );
}; };

+ 1
- 1
app/javascript/mastodon/service_worker/web_push_notifications.js View File

@ -117,7 +117,7 @@ const handlePush = (event) => {
badge: '/badge.png', badge: '/badge.png',
data: { access_token, preferred_locale, url: '/web/notifications' }, data: { access_token, preferred_locale, url: '/web/notifications' },
}); });
})
}),
); );
}; };

+ 1
- 1
app/javascript/mastodon/store/configureStore.js View File

@ -10,6 +10,6 @@ export default function configureStore() {
thunk, thunk,
loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'] }), loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'] }),
errorsMiddleware(), errorsMiddleware(),
soundsMiddleware()
soundsMiddleware(),
), window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f)); ), window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f));
}; };

+ 1
- 1
config/webpack/development.js View File

@ -54,7 +54,7 @@ module.exports = merge(sharedConfig, {
watchOptions: Object.assign( watchOptions: Object.assign(
{}, {},
settings.dev_server.watch_options, settings.dev_server.watch_options,
watchOptions
watchOptions,
), ),
writeToDisk: filePath => /ocr/.test(filePath), writeToDisk: filePath => /ocr/.test(filePath),
}, },

+ 2
- 2
config/webpack/shared.js View File

@ -31,7 +31,7 @@ module.exports = {
Object.keys(themes).reduce((themePaths, name) => { Object.keys(themes).reduce((themePaths, name) => {
themePaths[name] = resolve(join(settings.source_path, themes[name])); themePaths[name] = resolve(join(settings.source_path, themes[name]));
return themePaths; return themePaths;
}, {})
}, {}),
), ),
output: { output: {
@ -73,7 +73,7 @@ module.exports = {
// temporary fix for https://github.com/ReactTraining/react-router/issues/5576 // temporary fix for https://github.com/ReactTraining/react-router/issues/5576
// to reduce bundle size // to reduce bundle size
resource.request = resource.request.replace(/^history/, 'history/es'); resource.request = resource.request.replace(/^history/, 'history/es');
}
},
), ),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: 'css/[name]-[contenthash:8].css', filename: 'css/[name]-[contenthash:8].css',

Loading…
Cancel
Save