use standard to lint HTML too (#186)

This commit is contained in:
Nolan Lawson 2018-04-19 21:38:01 -07:00 committed by GitHub
parent ef80919269
commit bfc3c46462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 214 additions and 210 deletions

View file

@ -32,6 +32,7 @@ Lint:
Automatically fix most linting issues: Automatically fix most linting issues:
npx standard --fix npx standard --fix
npx standard --fix --plugin html 'routes/**/*.html'
## Testing ## Testing

9
package-lock.json generated
View file

@ -3084,6 +3084,15 @@
} }
} }
}, },
"eslint-plugin-html": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-4.0.3.tgz",
"integrity": "sha512-ArFnlfQxwYSz/CP0zvk8Cy3MUhcDpT3o6jgO8eKD/b8ezcLVBrgkYzmMv+7S/ya+Yl9pN+Cz2tsgYp/zElkQzA==",
"dev": true,
"requires": {
"htmlparser2": "3.9.2"
}
},
"eslint-plugin-import": { "eslint-plugin-import": {
"version": "2.9.0", "version": "2.9.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz",

View file

@ -3,7 +3,7 @@
"description": "Alternative web client for Mastodon", "description": "Alternative web client for Mastodon",
"version": "0.2.2", "version": "0.2.2",
"scripts": { "scripts": {
"lint": "standard", "lint": "standard && standard --plugin html 'routes/**/*.html'",
"dev": "run-s build-svg build-inline-script serve-dev", "dev": "run-s build-svg build-inline-script serve-dev",
"serve-dev": "run-p --race build-sass-watch serve", "serve-dev": "run-p --race build-sass-watch serve",
"serve": "node server.js", "serve": "node server.js",
@ -83,6 +83,7 @@
"yargs": "11.0.0" "yargs": "11.0.0"
}, },
"devDependencies": { "devDependencies": {
"eslint-plugin-html": "4.0.3",
"now": "11.1.7", "now": "11.1.7",
"standard": "11.0.1", "standard": "11.0.1",
"testcafe": "0.19.1" "testcafe": "0.19.1"
@ -117,7 +118,8 @@
"atob", "atob",
"btoa", "btoa",
"Blob", "Blob",
"Element" "Element",
"Image"
], ],
"ignore": [ "ignore": [
"dist", "dist",

View file

@ -9,7 +9,7 @@
{{/if}} {{/if}}
</div> </div>
<script> <script>
import Nav from './Nav.html'; import Nav from './Nav.html'
import { store } from '../_store/store' import { store } from '../_store/store'
import InformationalFooter from './InformationalFooter.html' import InformationalFooter from './InformationalFooter.html'

View file

@ -21,7 +21,6 @@
} }
</style> </style>
<script> <script>
import { mark, stop } from '../_utils/marks' import { mark, stop } from '../_utils/marks'
export default { export default {

View file

@ -146,5 +146,4 @@
} }
} }
} }
</script> </script>

View file

@ -42,7 +42,7 @@
}, },
computed: { computed: {
hidePage: ($timelineInitialized, $timelinePreinitialized) => !$timelineInitialized && !$timelinePreinitialized, hidePage: ($timelineInitialized, $timelinePreinitialized) => !$timelineInitialized && !$timelinePreinitialized,
hideTimeline: ($timelineInitialized) => !$timelineInitialized, hideTimeline: ($timelineInitialized) => !$timelineInitialized
}, },
store: () => store, store: () => store,
components: { components: {

View file

@ -36,7 +36,7 @@
}, },
computed: { computed: {
hidePage: ($timelineInitialized, $timelinePreinitialized) => !$timelineInitialized && !$timelinePreinitialized, hidePage: ($timelineInitialized, $timelinePreinitialized) => !$timelineInitialized && !$timelinePreinitialized,
hideTimeline: ($timelineInitialized) => !$timelineInitialized, hideTimeline: ($timelineInitialized) => !$timelineInitialized
}, },
store: () => store, store: () => store,
components: { components: {

View file

@ -94,7 +94,7 @@
composeAutosuggestionSelected: 0, composeAutosuggestionSelected: 0,
composeAutosuggestionSearchText: searchText, composeAutosuggestionSearchText: searchText,
composeAutosuggestionSearchResults: results, composeAutosuggestionSearchResults: results,
composeAutosuggestionType: type, composeAutosuggestionType: type
}) })
}) })
this.observe('shown', shown => { this.observe('shown', shown => {
@ -114,7 +114,6 @@
} else { } else {
/* no await */ insertEmojiAtPosition(realm, item, startIndex, endIndex) /* no await */ insertEmojiAtPosition(realm, item, startIndex, endIndex)
} }
}, },
async searchAccounts (searchText) { async searchAccounts (searchText) {
searchText = searchText.substring(1) searchText = searchText.substring(1)

View file

@ -197,7 +197,7 @@
dialogs.showComposeDialog() dialogs.showComposeDialog()
} else { } else {
// else we're actually posting a new toot // else we're actually posting a new toot
this.doPostStatus(); this.doPostStatus()
} }
}, },
doPostStatus () { doPostStatus () {

View file

@ -126,6 +126,6 @@ export default {
components: { components: {
ModalDialog, ModalDialog,
GenericDialogList GenericDialogList
}, }
} }
</script> </script>

View file

@ -39,7 +39,7 @@
note = `<p>${note}</p>` note = `<p>${note}</p>`
} }
return note return note
}, }
} }
} }
</script> </script>

View file

@ -19,7 +19,6 @@
} }
</style> </style>
<script> <script>
import PseudoVirtualListLazyItem from './PseudoVirtualListLazyItem.html' import PseudoVirtualListLazyItem from './PseudoVirtualListLazyItem.html'
import { getRectFromEntry } from '../../_utils/getRectFromEntry' import { getRectFromEntry } from '../../_utils/getRectFromEntry'
import { mark, stop } from '../../_utils/marks' import { mark, stop } from '../../_utils/marks'

View file

@ -22,7 +22,7 @@
} }
</style> </style>
<script> <script>
import SettingsNav from './SettingsNav.html'; import SettingsNav from './SettingsNav.html'
import FreeTextLayout from '../../_components/FreeTextLayout' import FreeTextLayout from '../../_components/FreeTextLayout'
export default { export default {
@ -30,5 +30,5 @@
FreeTextLayout, FreeTextLayout,
SettingsNav SettingsNav
} }
}; }
</script> </script>

View file

@ -14,7 +14,7 @@
export default { export default {
helpers: { helpers: {
getCurrentClass (page, name) { getCurrentClass (page, name) {
return page === name ? "selected" : "" return page === name ? 'selected' : ''
}, },
getAriaLabel (page, name, label) { getAriaLabel (page, name, label) {
return page === name ? `${label} (current page)` : label return page === name ? `${label} (current page)` : label

View file

@ -98,12 +98,11 @@
} }
</style> </style>
<script> <script>
import { DEFAULT_MEDIA_WIDTH, DEFAULT_MEDIA_HEIGHT } from '../../_static/media' import { DEFAULT_MEDIA_WIDTH, DEFAULT_MEDIA_HEIGHT, ONE_TRANSPARENT_PIXEL } from '../../_static/media'
import { importDialogs } from '../../_utils/asyncModules' import { importDialogs } from '../../_utils/asyncModules'
import { mouseover } from '../../_utils/events' import { mouseover } from '../../_utils/events'
import NonAutoplayGifv from '../NonAutoplayGifv.html' import NonAutoplayGifv from '../NonAutoplayGifv.html'
import PlayVideoIcon from '../PlayVideoIcon.html' import PlayVideoIcon from '../PlayVideoIcon.html'
import { ONE_TRANSPARENT_PIXEL } from '../../_static/media'
import { store } from '../../_store/store' import { store } from '../../_store/store'
import LazyImage from '../LazyImage.html' import LazyImage from '../LazyImage.html'
import AutoplayVideo from '../AutoplayVideo.html' import AutoplayVideo from '../AutoplayVideo.html'

View file

@ -46,7 +46,7 @@
statusId: (status) => status && status.id, statusId: (status) => status && status.id,
uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => { uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => {
return `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId}/${statusId || ''}` return `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId}/${statusId || ''}`
}, }
} }
} }
</script> </script>

View file

@ -202,18 +202,18 @@
spoilerShown: ($spoilersShown, uuid) => !!$spoilersShown[uuid], spoilerShown: ($spoilersShown, uuid) => !!$spoilersShown[uuid],
replyShown: ($repliesShown, uuid) => !!$repliesShown[uuid], replyShown: ($repliesShown, uuid) => !!$repliesShown[uuid],
showMedia: (originalStatus, isStatusInNotification) => { showMedia: (originalStatus, isStatusInNotification) => {
return !isStatusInNotification return !isStatusInNotification &&
&& originalStatus.media_attachments originalStatus.media_attachments &&
&& originalStatus.media_attachments.length originalStatus.media_attachments.length
}, },
ariaLabel: (originalAccount, originalStatus, visibility) => { ariaLabel: (originalAccount, originalStatus, visibility) => {
return (visibility === 'direct' ? 'Direct message' : 'Status') + return (visibility === 'direct' ? 'Direct message' : 'Status') +
` by ${originalAccount.display_name || originalAccount.username}` ` by ${originalAccount.display_name || originalAccount.username}`
}, },
showHeader: (notification, status, timelineType) => { showHeader: (notification, status, timelineType) => {
return (notification && (notification.type === 'reblog' || notification.type === 'favourite')) return (notification && (notification.type === 'reblog' || notification.type === 'favourite')) ||
|| status.reblog status.reblog ||
|| timelineType === 'pinned' timelineType === 'pinned'
}, },
className: (visibility, timelineType, isStatusInOwnThread) => { className: (visibility, timelineType, isStatusInOwnThread) => {
return classname( return classname(

View file

@ -81,7 +81,6 @@
} }
</style> </style>
<script> <script>
import Avatar from '../Avatar.html' import Avatar from '../Avatar.html'
export default { export default {

View file

@ -141,7 +141,7 @@
mediaAttachments: (originalStatus) => originalStatus.media_attachments, mediaAttachments: (originalStatus) => originalStatus.media_attachments,
sensitiveShown: ($sensitivesShown, uuid) => !!$sensitivesShown[uuid], sensitiveShown: ($sensitivesShown, uuid) => !!$sensitivesShown[uuid],
sensitive: (originalStatus, $markMediaAsSensitive) => originalStatus.sensitive || $markMediaAsSensitive, sensitive: (originalStatus, $markMediaAsSensitive) => originalStatus.sensitive || $markMediaAsSensitive,
delegateKey: (uuid) => `sensitive-${uuid}`, delegateKey: (uuid) => `sensitive-${uuid}`
}, },
methods: { methods: {
onClickSensitiveMediaButton () { onClickSensitiveMediaButton () {

View file

@ -166,7 +166,7 @@
favoriteKey: (uuid) => `fav-${uuid}`, favoriteKey: (uuid) => `fav-${uuid}`,
reblogKey: (uuid) => `reblog-${uuid}`, reblogKey: (uuid) => `reblog-${uuid}`,
replyKey: (uuid) => `reply-${uuid}`, replyKey: (uuid) => `reply-${uuid}`,
optionsKey: (uuid) => `options-${uuid}`, optionsKey: (uuid) => `options-${uuid}`
} }
} }
</script> </script>

View file

@ -123,14 +123,12 @@
// for threads, it's simpler to just render all items as a pseudo-virtual list // for threads, it's simpler to just render all items as a pseudo-virtual list
// due to need to scroll to the right item and thus calculate all item heights up-front // due to need to scroll to the right item and thus calculate all item heights up-front
virtual: (timelineType) => timelineType !== 'status', virtual: (timelineType) => timelineType !== 'status',
scrollToItem: (timelineType, timelineValue, $firstTimelineItemId) => {
// Scroll to the first item if this is a "status in own thread" timeline. // Scroll to the first item if this is a "status in own thread" timeline.
// Don't scroll to the first item because it obscures the "back" button. // Don't scroll to the first item because it obscures the "back" button.
return timelineType === 'status' scrollToItem: (timelineType, timelineValue, $firstTimelineItemId) => (
&& $firstTimelineItemId timelineType === 'status' && $firstTimelineItemId &&
&& timelineValue !== $firstTimelineItemId timelineValue !== $firstTimelineItemId && timelineValue
&& timelineValue ),
},
itemIdsToAdd: ($itemIdsToAdd) => $itemIdsToAdd, itemIdsToAdd: ($itemIdsToAdd) => $itemIdsToAdd,
headerProps: (itemIdsToAdd) => { headerProps: (itemIdsToAdd) => {
return { return {

View file

@ -105,7 +105,7 @@
}, },
scrollTop: ($scrollTop) => $scrollTop, scrollTop: ($scrollTop) => $scrollTop,
// TODO: bug in svelte store, shouldn't need to do this // TODO: bug in svelte store, shouldn't need to do this
allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight, allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight
}, },
methods: { methods: {
calculateListOffset () { calculateListOffset () {

View file

@ -115,5 +115,5 @@
// TODO: bug in svelte/store the observer in oncreate() never get removed without this hack // TODO: bug in svelte/store the observer in oncreate() never get removed without this hack
allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight
} }
}; }
</script> </script>

View file

@ -22,6 +22,6 @@
this.store.setForRealm({footerHeight: rect.height}) this.store.setForRealm({footerHeight: rect.height})
}) })
}, },
store: () => virtualListStore, store: () => virtualListStore
} }
</script> </script>

View file

@ -111,5 +111,5 @@
computed: { computed: {
isLockedAccount: ($currentVerifyCredentials) => $currentVerifyCredentials && $currentVerifyCredentials.locked isLockedAccount: ($currentVerifyCredentials) => $currentVerifyCredentials && $currentVerifyCredentials.locked
} }
}; }
</script> </script>

View file

@ -22,5 +22,5 @@
HiddenFromSSR, HiddenFromSSR,
TimelinePage TimelinePage
} }
}; }
</script> </script>

View file

@ -27,5 +27,5 @@
data: () => ({ data: () => ({
version version
}) })
}; }
</script> </script>

View file

@ -42,5 +42,5 @@
SettingsLayout SettingsLayout
}, },
store: () => store store: () => store
}; }
</script> </script>

View file

@ -19,5 +19,5 @@
SettingsList, SettingsList,
SettingsListItem SettingsListItem
} }
}; }
</script> </script>

View file

@ -112,7 +112,7 @@
}, },
store: () => store, store: () => store,
data: () => ({ data: () => ({
themes: themes, themes: themes
}), }),
async oncreate () { async oncreate () {
let { instanceName } = this.get() let { instanceName } = this.get()