fix: fix lint

This commit is contained in:
Nolan Lawson 2019-08-19 19:08:59 -07:00
parent 8caa0c08c3
commit 4232da5e33
53 changed files with 132 additions and 113 deletions

View file

@ -9,7 +9,7 @@ const copyFile = promisify(fs.copyFile)
async function compileThirdPartyCss () {
let css = await readFile(path.resolve(__dirname, '../node_modules/emoji-mart/css/emoji-mart.css'), 'utf8')
css = `/* compiled from emoji-mart.css */` + new CleanCSS().minify(css).styles
css = '/* compiled from emoji-mart.css */' + new CleanCSS().minify(css).styles
await writeFile(path.resolve(__dirname, '../static/emoji-mart.css'), css, 'utf8')
}

View file

@ -57,9 +57,9 @@ const JSON_TEMPLATE = {
const HTML_HEADERS = {
'cache-control': 'public,max-age=3600',
'content-security-policy': `script-src 'self' ` +
'content-security-policy': 'script-src \'self\' ' +
`${[inlineScriptChecksum].concat(sapperInlineScriptChecksums).map(_ => `'sha256-${_}'`).join(' ')}; ` +
`worker-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'none'; object-src 'none'; manifest-src 'self'`,
'worker-src \'self\'; style-src \'self\' \'unsafe-inline\'; frame-src \'none\'; object-src \'none\'; manifest-src \'self\'',
'referrer-policy': 'no-referrer',
'strict-transport-security': 'max-age=15552000; includeSubDomains',
'x-content-type-options': 'nosniff',

View file

@ -44,7 +44,7 @@ async function cloneMastodon () {
} catch (e) {
console.log('Cloning mastodon...')
await exec(`git clone --single-branch --branch ${GIT_BRANCH} ${GIT_URL} "${mastodonDir}"`)
await exec(`git fetch origin --tags`, { cwd: mastodonDir }) // may already be cloned, e.g. in CI
await exec('git fetch origin --tags', { cwd: mastodonDir }) // may already be cloned, e.g. in CI
await exec(`git checkout ${GIT_TAG_OR_COMMIT}`, { cwd: mastodonDir })
await writeFile(path.join(dir, '../mastodon/.env'), envFile, 'utf8')
}

View file

@ -57,7 +57,7 @@ export async function logInToInstance () {
(err.knownError ? '' : (navigator.onLine
? `Is this a valid Mastodon instance? Is a browser extension
blocking the request? Are you in private browsing mode?`
: `Are you offline?`))
: 'Are you offline?'))
const { instanceNameInSearch } = store.get()
store.set({
logInToInstanceError: error,

View file

@ -9,6 +9,6 @@ export async function shareStatus (status) {
url: status.url
})
} catch (e) {
toast.say(`Unable to share: ` + (e.message || ''))
toast.say('Unable to share: ' + (e.message || ''))
}
}

View file

@ -52,7 +52,7 @@
data: () => ({
loading: true,
accounts: [],
accountActions: void 0
accountActions: undefined
}),
store: () => store,
components: {

View file

@ -44,7 +44,7 @@
export default {
data: () => ({
focus: void 0
focus: undefined
}),
store: () => store,
computed: {

View file

@ -48,9 +48,9 @@
export default {
data: () => ({
className: void 0,
className: undefined,
loaded: false,
error: void 0,
error: undefined,
isLink: false,
size: 'medium'
}),

View file

@ -66,7 +66,7 @@
export default {
data: () => ({
icon: void 0,
icon: undefined,
ariaTitle: ''
}),
components: {

View file

@ -27,7 +27,7 @@
export default {
data: () => ({
className: void 0,
className: undefined,
normalIconColor: false,
ariaLabel: '',
showIcon: false

View file

@ -1,7 +1,7 @@
<button type="button"
title={label}
aria-label={label}
aria-pressed={pressable ? !!pressed : void 0}
aria-pressed={pressable ? !!pressed : undefined}
aria-hidden={ariaHidden}
class={computedClass}
{disabled}
@ -112,11 +112,11 @@
big: false,
muted: false,
disabled: false,
svgClassName: void 0,
elementId: void 0,
svgClassName: undefined,
elementId: undefined,
pressable: false,
pressed: false,
className: void 0,
className: undefined,
sameColorWhenPressed: false,
ariaHidden: false,
clickListener: true

View file

@ -21,7 +21,7 @@
<script>
export default {
data: () => ({
className: void 0
className: undefined
})
}
</script>

View file

@ -46,15 +46,15 @@
data: () => ({
error: false,
forceSize: false,
fallback: void 0,
focus: void 0,
fallback: undefined,
focus: undefined,
background: '',
width: void 0,
height: void 0,
width: undefined,
height: undefined,
ariaHidden: false,
alt: '',
title: '',
blurhash: void 0
blurhash: undefined
}),
computed: {
computedStyle: ({ background }) => {

View file

@ -68,7 +68,7 @@
},
data: () => ({
oneTransparentPixel: ONE_TRANSPARENT_PIXEL,
focus: void 0
focus: undefined
}),
components: {
PlayVideoIcon,

View file

@ -13,12 +13,12 @@
{
name: '',
label: 'All',
href: `/notifications`
href: '/notifications'
},
{
name: 'mentions',
label: 'Mentions',
href: `/notifications/mentions`
href: '/notifications/mentions'
}
]
}),

View file

@ -27,7 +27,7 @@
export default {
data: () => ({
className: void 0
className: undefined
}),
components: {
SvgIcon

View file

@ -113,11 +113,13 @@
!!($autosuggestShown && composeFocused)
),
// text that is read to screen readers. based on https://haltersweb.github.io/Accessibility/autocomplete.html
assertiveAriaText: ({ shouldBeShown,
assertiveAriaText: ({
shouldBeShown,
autosuggestSearchResults,
autosuggestSelected,
autosuggestType,
$omitEmojiInDisplayNames }) => {
$omitEmojiInDisplayNames
}) => {
if (!shouldBeShown || !autosuggestSearchResults || !autosuggestSearchResults.length) {
return ''
}

View file

@ -135,12 +135,12 @@
ComposePoll
},
data: () => ({
size: void 0,
size: undefined,
isReply: false,
autoFocus: false,
hideBottomBorder: false,
hidden: false,
dialogId: void 0
dialogId: undefined
}),
store: () => store,
computed: {

View file

@ -151,24 +151,29 @@
// ctrl or cmd (on macs) was pressed; ctrl-enter means post a toot
const ctrlPressed = e.getModifierState('Control') || e.getModifierState('Meta')
switch (keyCode) {
case 9: // tab
case 9: { // tab
this.clickSelectedAutosuggestion(e)
break
case 13: // enter
}
case 13: { // enter
const autosuggestionClicked = this.clickSelectedAutosuggestion(e)
if (!autosuggestionClicked && ctrlPressed) {
this.fire('postAction')
}
break
case 38: // up
}
case 38: { // up
this.incrementAutosuggestSelected(-1, e)
break
case 40: // down
}
case 40: { // down
this.incrementAutosuggestSelected(1, e)
break
case 27: // escape
}
case 27: { // escape
this.clearAutosuggestions(e)
break
}
default:
}
},

View file

@ -21,7 +21,7 @@
onCreateDialog.call(this)
},
data: () => ({
title: void 0,
title: undefined,
realm: 'dialog'
}),
methods: {

View file

@ -48,10 +48,10 @@
onCreateDialog.call(this)
},
data: () => ({
component: void 0,
text: void 0,
onPositive: void 0,
onNegative: void 0,
component: undefined,
text: undefined,
onPositive: undefined,
onNegative: undefined,
title: '',
positiveText: 'OK',
negativeText: 'Cancel'

View file

@ -117,7 +117,7 @@
data: () => ({
loading: true,
loaded: false,
error: void 0
error: undefined
}),
computed: {
// try to estimate size of emoji-mart based on mobile vs desktop

View file

@ -42,8 +42,8 @@
onCreateDialog.call(this)
},
data: () => ({
positiveText: void 0,
negativeText: void 0,
positiveText: undefined,
negativeText: undefined,
className: ''
}),
methods: {

View file

@ -188,8 +188,8 @@
shouldAnimate: !process.browser || document.getElementsByClassName('modal-dialog').length < 2,
fadedIn: false,
muted: false,
className: void 0,
title: void 0,
className: undefined,
title: undefined,
shrinkWidthToFit: false,
clickHeaderToClose: false
}),

View file

@ -185,8 +185,8 @@
},
store: () => store,
data: () => ({
account: void 0,
status: void 0,
account: undefined,
status: undefined,
positiveText: 'Report',
reportMap: {},
recentStatuses: [],
@ -219,7 +219,7 @@
const { displayStatuses, account, comment, forward, reportMap } = this.get()
const statusIds = displayStatuses.map(({ id }) => id).filter(id => reportMap[id])
if (!statusIds.length) {
toast.say(`No toots to report.`)
toast.say('No toots to report.')
} else {
await reportStatuses(account, statusIds, comment, forward)
}

View file

@ -79,7 +79,7 @@ export default {
mentions: ({ status }) => status.mentions || [],
mentionsUser: ({ mentions, verifyCredentialsId }) => !!mentions.find(_ => _.id === verifyCredentialsId),
mutingConversation: ({ status }) => !!status.muted,
muteConversationLabel: ({ mutingConversation }) => mutingConversation ? `Unmute conversation` : `Mute conversation`,
muteConversationLabel: ({ mutingConversation }) => mutingConversation ? 'Unmute conversation' : 'Mute conversation',
muteConversationIcon: ({ mutingConversation }) => mutingConversation ? '#fa-volume-up' : '#fa-volume-off',
isPublicOrUnlisted: ({ visibility }) => visibility === 'public' || visibility === 'unlisted',
items: ({

View file

@ -23,9 +23,9 @@
export default {
oncreate,
data: () => ({
title: void 0,
positiveText: void 0,
negativeText: void 0
title: undefined,
positiveText: undefined,
negativeText: undefined
}),
methods: {
show,

View file

@ -24,7 +24,7 @@
}
},
data: () => ({
props: void 0
props: undefined
}),
components: {
ListItem

View file

@ -54,7 +54,7 @@
},
store: () => store,
data: () => ({
overrideFollowing: void 0
overrideFollowing: undefined
}),
computed: {
accountId: ({ account }) => account.id,

View file

@ -77,7 +77,7 @@
export default {
data: () => ({
actions: void 0
actions: undefined
}),
methods: {
onButtonClick (event, action, accountId) {

View file

@ -29,7 +29,7 @@
<script>
export default {
data: () => ({
label: void 0
label: undefined
})
}
</script>

View file

@ -17,8 +17,8 @@
<script>
export default {
data: () => ({
ariaLabel: void 0,
className: void 0
ariaLabel: undefined,
className: undefined
})
}
</script>

View file

@ -37,8 +37,8 @@
<script>
export default {
data: () => ({
icon: void 0,
ariaLabel: void 0
icon: undefined,
ariaLabel: undefined
})
}
</script>

View file

@ -2,11 +2,13 @@
import {
isVisible,
firstVisibleElementIndex,
scrollIntoViewIfNeeded } from '../../_utils/scrollIntoView'
scrollIntoViewIfNeeded
} from '../../_utils/scrollIntoView'
import {
addShortcutFallback,
removeShortcutFallback,
onKeyDownInShortcutScope } from '../../_utils/shortcuts'
onKeyDownInShortcutScope
} from '../../_utils/shortcuts'
import { smoothScroll } from '../../_utils/smoothScroll'
import { getScrollContainer } from '../../_utils/scrollContainer'

View file

@ -1,7 +1,8 @@
<script>
import {
addToShortcutScope,
removeFromShortcutScope } from '../../_utils/shortcuts'
removeFromShortcutScope
} from '../../_utils/shortcuts'
export default {
data: () => ({ scope: 'global', key: null }),
oncreate () {
@ -18,7 +19,8 @@
event.preventDefault()
this.fire('pressed', {
key: event.key,
timeStamp: event.timeStamp })
timeStamp: event.timeStamp
})
}
}
}

View file

@ -164,7 +164,7 @@ export default {
},
data: () => ({
oneTransparentPixel: ONE_TRANSPARENT_PIXEL,
mouseover: void 0
mouseover: undefined
}),
store: () => store,
events: {

View file

@ -176,8 +176,8 @@
Shortcut
},
data: () => ({
notification: void 0,
replyVisibility: void 0,
notification: undefined,
replyVisibility: undefined,
contentPreloaded: false,
enableShortcuts: null
}),
@ -284,8 +284,10 @@
absoluteFormattedDate: ({ createdAtDateTS }) => absoluteDateFormatter.format(createdAtDateTS),
timeagoFormattedDate: ({ createdAtDateTS, $now }) => formatTimeagoDate(createdAtDateTS, $now),
reblog: ({ status }) => status.reblog,
ariaLabel: ({ originalAccount, account, plainTextContent, timeagoFormattedDate, spoilerText,
showContent, reblog, notification, visibility, $omitEmojiInDisplayNames, $disableLongAriaLabels }) => (
ariaLabel: ({
originalAccount, account, plainTextContent, timeagoFormattedDate, spoilerText,
showContent, reblog, notification, visibility, $omitEmojiInDisplayNames, $disableLongAriaLabels
}) => (
getAccessibleLabelForStatus(originalAccount, account, plainTextContent,
timeagoFormattedDate, spoilerText, showContent,
reblog, notification, visibility, $omitEmojiInDisplayNames, $disableLongAriaLabels)
@ -318,11 +320,13 @@
// This params list deliberately does *not* include `spoilersShown` or `replyShown`, because these
// change frequently and would therefore cause costly recomputes if included here.
// The main goal here is to avoid typing by passing as many params as possible to child components.
params: ({ notification, notificationId, status, statusId, timelineType,
params: ({
notification, notificationId, status, statusId, timelineType,
account, accountId, uuid, isStatusInNotification, isStatusInOwnThread,
originalAccount, originalAccountId, visibility,
replyVisibility, spoilerText, originalStatus, originalStatusId, inReplyToId,
enableShortcuts, shortcutScope, originalStatusEmojis }) => ({
enableShortcuts, shortcutScope, originalStatusEmojis
}) => ({
notification,
notificationId,
status,

View file

@ -150,8 +150,8 @@
},
store: () => store,
data: () => ({
overrideNumReblogs: void 0,
overrideNumFavs: void 0
overrideNumReblogs: undefined,
overrideNumFavs: undefined
}),
computed: {
originalStatusId: ({ originalStatus }) => originalStatus.id,

View file

@ -107,11 +107,11 @@
case 'tag':
return `Statuses: #${timelineValue} hashtag`
case 'status':
return `Statuses: thread`
return 'Statuses: thread'
case 'account':
return `Statuses: account timeline`
return 'Statuses: account timeline'
case 'list':
return `Statuses: list`
return 'Statuses: list'
case 'notifications':
return `Notifications on ${$currentInstance}`
}

View file

@ -21,7 +21,7 @@
}
},
data: () => ({
props: void 0
props: undefined
}),
components: {
VirtualListItem

View file

@ -22,7 +22,7 @@
export default {
computed: {
list: ({ params, $lists }) => $lists && $lists.find(_ => _.id === params['listId']),
list: ({ params, $lists }) => $lists && $lists.find(_ => _.id === params.listId),
listTitle: ({ list }) => list ? list.title : ''
},
store: () => store,

View file

@ -59,7 +59,7 @@ export function timelineComputations (store) {
)
store.compute('currentTimelineValue', ['currentTimeline'], currentTimeline => {
if (!currentTimeline) {
return void 0
return undefined
}
const split = currentTimeline.split('/')
const len = split.length
@ -152,7 +152,7 @@ export function timelineComputations (store) {
)
store.compute('timelineNotificationItemSummaries',
[`timelineData_timelineItemSummariesToAdd`, 'timelineFilterFunction', 'currentInstance'],
['timelineData_timelineItemSummariesToAdd', 'timelineFilterFunction', 'currentInstance'],
(root, timelineFilterFunction, currentInstance) => (
get(root, [currentInstance, 'notifications'])
)

View file

@ -16,5 +16,5 @@ export function createAutosuggestAccessibleLabel (
label = `${displayName} @${selected.acct}`
}
return `${label} (${selectedIndex + 1} of ${searchResults.length}). ` +
`Press up and down arrows to review and enter to select.`
'Press up and down arrows to review and enter to select.'
}

View file

@ -1,6 +1,7 @@
import {
getScrollContainer,
getOffsetHeight } from './scrollContainer'
getOffsetHeight
} from './scrollContainer'
import { smoothScroll } from './smoothScroll'
let mainNavElement

View file

@ -1,8 +1,8 @@
export function timelineItemToSummary (item) {
return {
id: item.id,
replyId: (item.in_reply_to_id) || void 0,
reblogId: (item.reblog && item.reblog.id) || void 0,
type: item.type || void 0
replyId: (item.in_reply_to_id) || undefined,
reblogId: (item.reblog && item.reblog.id) || undefined,
type: item.type || undefined
}
}

View file

@ -5,10 +5,10 @@
import crypto from 'crypto'
const baseScripts = [
`__SAPPER__={baseUrl:"",preloaded:[{},{}]};`,
`__SAPPER__={baseUrl:"",preloaded:[{}]};`,
`__SAPPER__={baseUrl:"",preloaded:[{},null,null,{}]};`,
`__SAPPER__={baseUrl:"",preloaded:[{},null,{}]};`
'__SAPPER__={baseUrl:"",preloaded:[{},{}]};',
'__SAPPER__={baseUrl:"",preloaded:[{}]};',
'__SAPPER__={baseUrl:"",preloaded:[{},null,null,{}]};',
'__SAPPER__={baseUrl:"",preloaded:[{},null,{}]};'
]
const scriptsWithSW = baseScripts.map(script => (

View file

@ -156,7 +156,7 @@ async function showRichNotification (data, notification) {
}
case 'reblog':
case 'favourite':
case 'poll':
case 'poll': {
await self.registration.showNotification(data.title, {
badge,
icon,
@ -167,7 +167,8 @@ async function showRichNotification (data, notification) {
}
})
break
case 'mention':
}
case 'mention': {
const isPublic = ['public', 'unlisted'].includes(notification.status.visibility)
const actions = [
isPublic && {
@ -196,6 +197,7 @@ async function showRichNotification (data, notification) {
actions
})
break
}
}
}

View file

@ -50,8 +50,8 @@ test('content warnings can have emoji', async t => {
})
test('no XSS in content warnings or text', async t => {
const pwned1 = `<script>alert("pwned!")</script>`
const pwned2 = `<script>alert("pwned from CW!")</script>`
const pwned1 = '<script>alert("pwned!")</script>'
const pwned2 = '<script>alert("pwned from CW!")</script>'
await loginAsFoobar(t)
await t
.typeText(composeInput, pwned1)

View file

@ -101,7 +101,7 @@ test('Check status aria labels for de-emojified text', async t => {
.click(homeNavButton)
.click(displayNameInComposeBox)
.expect(getNthStatus(1).getAttribute('aria-label')).match(
new RegExp(`foo, hey ho lotsa emojos, (.* ago|just now), @foobar, Public`, 'i')
new RegExp('foo, hey ho lotsa emojos, (.* ago|just now), @foobar, Public', 'i')
)
.click(settingsNavButton)
.click(generalSettingsButton)

View file

@ -26,7 +26,7 @@ const INSTANCE_INFO = {
const createStatus = i => ({
id: i.toString(),
created_at: new Date().toISOString(),
content: `Status #4{id}`,
content: 'Status #4{id}',
account: {
id: '1'
}

View file

@ -63,17 +63,17 @@ describe('test-emoji.js', function () {
it('does not replace non-emoji characters', function () {
const replacer = _ => `<div>${_}</div>`
assert.strictEqual(
replaceEmoji(`it's over #9000`, replacer),
`it's over #9000`
replaceEmoji('it\'s over #9000', replacer),
'it\'s over #9000'
)
assert.strictEqual(
replaceEmoji(`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£™℠®`, replacer),
`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£™℠®`
replaceEmoji('woot !@#$%^&*()~' + '`' + '{[}]:;"\'<,>.?/£™℠®', replacer),
'woot !@#$%^&*()~' + '`' + '{[}]:;"\'<,>.?/£™℠®'
)
assert.strictEqual(
replaceEmoji(`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£™℠®`, replacer),
`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£™℠®`
replaceEmoji('woot !@#$%^&*()~' + '`' + '{[}]:;"\'<,>.?/£™℠®', replacer),
'woot !@#$%^&*()~' + '`' + '{[}]:;"\'<,>.?/£™℠®'
)
// hidden VARIATION SELECTOR character is in here
@ -118,19 +118,19 @@ describe('test-emoji.js', function () {
const replacer = _ => ''
assert.strictEqual(
replaceEmoji(`woot ${mindBlown}`, replacer),
`woot `
'woot '
)
assert.strictEqual(
replaceEmoji(`woot ${mindBlown} woot`, replacer),
`woot woot`
'woot woot'
)
assert.strictEqual(
replaceEmoji(`woot ${mindBlown}${elephant}`, replacer),
`woot `
'woot '
)
assert.strictEqual(
replaceEmoji(`woot ${mindBlown}${elephant} woot`, replacer),
`woot woot`
'woot woot'
)
})

View file

@ -7,7 +7,8 @@ import {
onKeyDownInShortcutScope,
popShortcutScope,
pushShortcutScope,
removeFromShortcutScope } from '../../src/routes/_utils/shortcuts'
removeFromShortcutScope
} from '../../src/routes/_utils/shortcuts'
import assert from 'assert'
function KeyDownEvent (key) {

View file

@ -50,7 +50,7 @@ export const neverMarkMediaSensitiveInput = $('#choice-never-mark-media-sensitiv
export const removeEmojiFromDisplayNamesInput = $('#choice-omit-emoji-in-display-names')
export const disableInfiniteScroll = $('#choice-disable-infinite-scroll')
export const disableUnreadNotifications = $('#choice-disable-unread-notification-counts')
export const dialogOptionsOption = $(`.modal-dialog button`)
export const dialogOptionsOption = $('.modal-dialog button')
export const emojiSearchInput = $('.emoji-mart-search input')
export const confirmationDialogOKButton = $('.confirmation-dialog-form-flex button:nth-child(1)')
export const confirmationDialogCancelButton = $('.confirmation-dialog-form-flex button:nth-child(2)')
@ -353,7 +353,7 @@ export function getNthStatusAndImage (nStatus, nImage) {
}
export function getFirstVisibleStatus () {
return $(`.list-item > article[aria-posinset]`).nth(0)
return $('.list-item > article[aria-posinset]').nth(0)
}
export function getNthReplyButton (n) {