Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const config = {
files: ['**/*.ts', '**/*.tsx', '**/*.js'],

rules: {
eqeqeq: 'error',

'no-eval': 'error',
'no-array-constructor': 'error',
camelcase: 'error',
Expand Down
2 changes: 1 addition & 1 deletion client/js/helpers/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function i18nFormat(
}
}

if (state != 'out') {
if (state !== 'out') {
return "Error formatting '" + translated + "', bug report?";
}

Expand Down
12 changes: 6 additions & 6 deletions client/js/helpers/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export function useLocation(): Location {
* Converts URL segment to FilterType value.
*/
export function filterTypeFromString(type: string): FilterType {
if (type == 'newest') {
if (type === 'newest') {
return FilterType.NEWEST;
} else if (type == 'unread') {
} else if (type === 'unread') {
return FilterType.UNREAD;
} else if (type == 'starred') {
} else if (type === 'starred') {
return FilterType.STARRED;
} else {
throw new Error(`Invalid filter type: “${type}”`);
Expand All @@ -41,11 +41,11 @@ export function filterTypeFromString(type: string): FilterType {
* Converts FilterType value to string usable in URL.
*/
export function filterTypeToString(type: FilterType): string {
if (type == FilterType.NEWEST) {
if (type === FilterType.NEWEST) {
return 'newest';
} else if (type == FilterType.UNREAD) {
} else if (type === FilterType.UNREAD) {
return 'unread';
} else if (type == FilterType.STARRED) {
} else if (type === FilterType.STARRED) {
return 'starred';
} else {
throw new Error(`Invalid filter type: “${type}”`);
Expand Down
4 changes: 2 additions & 2 deletions client/js/selfoss-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class selfoss {

if (configuration.authEnabled) {
this.loggedin.update(
window.localStorage.getItem('onlineSession') == 'true',
window.localStorage.getItem('onlineSession') === 'true',
);
}

Expand Down Expand Up @@ -450,7 +450,7 @@ class selfoss {

const httpCode = 'response' in error ? error.response.status : 0;

if (tryOffline && httpCode != 403) {
if (tryOffline && httpCode !== 403) {
return this.db.setOffline();
} else {
return Promise.reject(error);
Expand Down
4 changes: 2 additions & 2 deletions client/js/selfoss-db-offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,13 @@ export default class DbOffline {
if (ascOrder) {
keepEntry &&=
entry.datetime > fromDatetime ||
(entry.datetime.getTime() ==
(entry.datetime.getTime() ===
fromDatetime.getTime() &&
entry.id > fromId);
} else {
keepEntry &&=
entry.datetime < fromDatetime ||
(entry.datetime.getTime() ==
(entry.datetime.getTime() ===
fromDatetime.getTime() &&
entry.id < fromId);
}
Expand Down
14 changes: 7 additions & 7 deletions client/js/templates/EntriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export function EntriesPage(props: EntriesPageProps): React.JSX.Element {
key={entry.id}
item={entry}
currentTime={currentTime}
selected={selectedEntry == entry.id}
selected={selectedEntry === entry.id}
expanded={expandedEntries[entry.id] ?? false}
setNavExpanded={setNavExpanded}
showError={showError}
Expand Down Expand Up @@ -557,7 +557,7 @@ export function EntriesPage(props: EntriesPageProps): React.JSX.Element {
<span>{_('markread')}</span>
</button>
) : null}
{loadingState == LoadingState.FAILURE ? (
{loadingState === LoadingState.FAILURE ? (
<button
className="stream-button stream-error"
aria-live="assertive"
Expand Down Expand Up @@ -792,7 +792,7 @@ export class StateHolder extends React.Component<
this.state.entries.forEach((entry) => {
const { id } = entry;
const newStatus = entryStatuses.find(
(entryStatus) => entryStatus.id == id,
(entryStatus) => entryStatus.id === id,
);
if (newStatus) {
this.starEntryInView(id, newStatus.starred);
Expand Down Expand Up @@ -1147,12 +1147,12 @@ export class StateHolder extends React.Component<
* get next/prev item
*/
nextPrev(direction: Direction, open: boolean = true): void {
if (direction != Direction.NEXT && direction != Direction.PREV) {
if (direction !== Direction.NEXT && direction !== Direction.PREV) {
throw new Error('direction must be one of Direction.{PREV,NEXT}');
}

// when there are no entries
if (this.state.entries.length == 0) {
if (this.state.entries.length === 0) {
return;
}

Expand All @@ -1166,7 +1166,7 @@ export class StateHolder extends React.Component<

// select next/prev entry and save it to "current"
// if we would overflow, we stay on the old one
if (direction == Direction.NEXT) {
if (direction === Direction.NEXT) {
if (old === null) {
current = this.state.entries[0].id;
} else {
Expand Down Expand Up @@ -1222,7 +1222,7 @@ export class StateHolder extends React.Component<
* entry navigation (next/prev) with keys
*/
entryNav(direction: Direction): void {
if (direction != Direction.NEXT && direction != Direction.PREV) {
if (direction !== Direction.NEXT && direction !== Direction.PREV) {
throw new Error('direction must be one of Direction.{PREV,NEXT}');
}

Expand Down
6 changes: 2 additions & 4 deletions client/js/templates/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { ResponseItem, TagColor } from '../requests/items';
// TODO: do the search highlights client-side
function reHighlight(text: string): (React.JSX.Element | string)[] {
return text.split(/<span class="found">(.+?)<\/span>/).map((n, i) =>
i % 2 == 0 ? (
i % 2 === 0 ? (
n
) : (
<span key={i} className="found">
Expand Down Expand Up @@ -567,9 +567,7 @@ export default function Item(props: ItemProps): React.JSX.Element {
aria-hidden="true"
onClick={preventDefaultOnSmartphone}
>
{item.icon !== null &&
item.icon.trim().length > 0 &&
item.icon != '0' ? (
{item.icon !== null ? (
<img
src={`favicons/${item.icon}`}
aria-hidden="true"
Expand Down
6 changes: 3 additions & 3 deletions client/js/templates/NavSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ function handleFieldKeyUp({
searchRemoveButton: RefObject<HTMLButtonElement>;
}): void {
// keypress enter in search inputfield
if (event.which == 13) {
if (event.which === 13) {
searchButton.current.click();
}
if (event.keyCode == 27) {
if (event.keyCode === 27) {
searchRemoveButton.current.click();
}
}
Expand All @@ -85,7 +85,7 @@ function handleRemove({

setActive(false);

if (oldTerm == '') {
if (oldTerm === '') {
searchField.current.blur();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion client/js/templates/SearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeEntriesLink } from '../helpers/uri';
import * as icons from '../icons';

function splitTerm(term: string): string[] {
if (term == '') {
if (term === '') {
return [];
} else if (term.match(/^\/.+\/$/)) {
return [term];
Expand Down
4 changes: 2 additions & 2 deletions client/js/templates/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function handleDelete(args: {
_,
} = args;
const answer = confirm(_('source_warn'));
if (answer == false) {
if (!answer) {
return;
}

Expand Down Expand Up @@ -800,7 +800,7 @@ export default function Source(props: SourceProps): React.JSX.Element {
ref={sourceElem}
>
<div className="source-icon">
{source.icon && source.icon != '0' ? (
{source.icon !== null ? (
<img
src={`favicons/${source.icon}`}
aria-hidden="true"
Expand Down
1 change: 1 addition & 0 deletions client/js/templates/SourceParam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function SourceParam(
let checked;

if (spoutParam.type === 'checkbox') {
// eslint-disable-next-line eqeqeq -- Unclear if the type is correct since this is not used by any spout.
checked = value == '1';
// Value always has to be 1 since HTML sends [name]=[value] when a checkbox is checked
// and omits the field altogether from HTTP request when not checked.
Expand Down
2 changes: 1 addition & 1 deletion src/daos/mysql/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function get(ItemOptions $options): array {

// get items from database
$select = 'SELECT
items.id, datetime, items.title AS title, content, unread, starred, source, thumbnail, icon, uid, link, updatetime, author, sources.title as sourcetitle, sources.tags as tags
items.id, datetime, items.title AS title, content, unread, starred, source, thumbnail, NULLIF(icon, \'\') as icon, uid, link, updatetime, author, sources.title as sourcetitle, sources.tags as tags
FROM ' . $this->configuration->dbPrefix . 'items AS items, ' . $this->configuration->dbPrefix . 'sources AS sources
WHERE items.source=sources.id AND';
$order_sql = 'ORDER BY items.datetime ' . $order . ', items.id ' . $order;
Expand Down