1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Use ESLint to replace double quotes

This commit is contained in:
Nick Schonning 2024-04-28 16:33:35 -04:00
parent dd53792714
commit 4cee2a03d6
No known key found for this signature in database
GPG key ID: 5DDAAD9C9AAFFD9F
18 changed files with 42 additions and 42 deletions

View file

@ -75,7 +75,7 @@ module.exports = defineConfig({
], ],
}, },
], ],
'no-empty': ['error', { "allowEmptyCatch": true }], 'no-empty': ['error', { 'allowEmptyCatch': true }],
'no-restricted-properties': [ 'no-restricted-properties': [
'error', 'error',
{ property: 'substring', message: 'Use .slice instead of .substring.' }, { property: 'substring', message: 'Use .slice instead of .substring.' },
@ -332,16 +332,16 @@ module.exports = defineConfig({
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
'@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/consistent-type-imports': 'error',
"@typescript-eslint/prefer-nullish-coalescing": ['error', { ignorePrimitives: { boolean: true } }], '@typescript-eslint/prefer-nullish-coalescing': ['error', { ignorePrimitives: { boolean: true } }],
"@typescript-eslint/no-restricted-imports": [ '@typescript-eslint/no-restricted-imports': [
"warn", 'warn',
{ {
"name": "react-redux", 'name': 'react-redux',
"importNames": ["useSelector", "useDispatch"], 'importNames': ['useSelector', 'useDispatch'],
"message": "Use typed hooks `useAppDispatch` and `useAppSelector` instead." 'message': 'Use typed hooks `useAppDispatch` and `useAppSelector` instead.'
} }
], ],
"@typescript-eslint/restrict-template-expressions": ['warn', { allowNumber: true }], '@typescript-eslint/restrict-template-expressions': ['warn', { allowNumber: true }],
'jsdoc/require-jsdoc': 'off', 'jsdoc/require-jsdoc': 'off',
// Those rules set stricter rules for TS files // Those rules set stricter rules for TS files

View file

@ -1,10 +1,10 @@
import api, { getLinks } from '../api'; import api, { getLinks } from '../api';
import { blockDomainSuccess, unblockDomainSuccess } from "./domain_blocks_typed"; import { blockDomainSuccess, unblockDomainSuccess } from './domain_blocks_typed';
import { openModal } from './modal'; import { openModal } from './modal';
export * from "./domain_blocks_typed"; export * from './domain_blocks_typed';
export const DOMAIN_BLOCK_REQUEST = 'DOMAIN_BLOCK_REQUEST'; export const DOMAIN_BLOCK_REQUEST = 'DOMAIN_BLOCK_REQUEST';
export const DOMAIN_BLOCK_FAIL = 'DOMAIN_BLOCK_FAIL'; export const DOMAIN_BLOCK_FAIL = 'DOMAIN_BLOCK_FAIL';

View file

@ -47,7 +47,7 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS'; export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';
export * from "./interactions_typed"; export * from './interactions_typed';
export function favourite(status) { export function favourite(status) {
return function (dispatch) { return function (dispatch) {

View file

@ -19,11 +19,11 @@ import {
} from './importer'; } from './importer';
import { submitMarkers } from './markers'; import { submitMarkers } from './markers';
import { decreasePendingNotificationsCount } from './notification_policies'; import { decreasePendingNotificationsCount } from './notification_policies';
import { notificationsUpdate } from "./notifications_typed"; import { notificationsUpdate } from './notifications_typed';
import { register as registerPushNotifications } from './push_notifications'; import { register as registerPushNotifications } from './push_notifications';
import { saveSettings } from './settings'; import { saveSettings } from './settings';
export * from "./notifications_typed"; export * from './notifications_typed';
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP'; export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';

View file

@ -158,7 +158,7 @@ export const expandAccountTimeline = (accountId, { maxId, withReplies, t
export const expandAccountFeaturedTimeline = (accountId, { tagged } = {}) => expandTimeline(`account:${accountId}:pinned${tagged ? `:${tagged}` : ''}`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true, tagged }); export const expandAccountFeaturedTimeline = (accountId, { tagged } = {}) => expandTimeline(`account:${accountId}:pinned${tagged ? `:${tagged}` : ''}`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true, tagged });
export const expandAccountMediaTimeline = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true, limit: 40 }); export const expandAccountMediaTimeline = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true, limit: 40 });
export const expandListTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }, done); export const expandListTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }, done);
export const expandLinkTimeline = (url, { maxId } = {}, done = noOp) => expandTimeline(`link:${url}`, `/api/v1/timelines/link`, { url, max_id: maxId }, done); export const expandLinkTimeline = (url, { maxId } = {}, done = noOp) => expandTimeline(`link:${url}`, '/api/v1/timelines/link', { url, max_id: maxId }, done);
export const expandHashtagTimeline = (hashtag, { maxId, tags, local } = {}, done = noOp) => { export const expandHashtagTimeline = (hashtag, { maxId, tags, local } = {}, done = noOp) => {
return expandTimeline(`hashtag:${hashtag}${local ? ':local' : ''}`, `/api/v1/timelines/tag/${hashtag}`, { return expandTimeline(`hashtag:${hashtag}${local ? ':local' : ''}`, `/api/v1/timelines/tag/${hashtag}`, {
max_id: maxId, max_id: maxId,

View file

@ -25,7 +25,7 @@ import { countableText } from '../util/counter';
import { CharacterCounter } from './character_counter'; import { CharacterCounter } from './character_counter';
import { EditIndicator } from './edit_indicator'; import { EditIndicator } from './edit_indicator';
import { NavigationBar } from './navigation_bar'; import { NavigationBar } from './navigation_bar';
import { PollForm } from "./poll_form"; import { PollForm } from './poll_form';
import { ReplyIndicator } from './reply_indicator'; import { ReplyIndicator } from './reply_indicator';
import { UploadForm } from './upload_form'; import { UploadForm } from './upload_form';

View file

@ -23,7 +23,7 @@ const lightEmoji = emojiFilenames(['👽', '⚾', '🐔', '☁️', '💨', '
* @returns {string} * @returns {string}
*/ */
const emojiFilename = (filename, colorScheme) => { const emojiFilename = (filename, colorScheme) => {
const borderedEmoji = colorScheme === "light" ? lightEmoji : darkEmoji; const borderedEmoji = colorScheme === 'light' ? lightEmoji : darkEmoji;
return borderedEmoji.includes(filename) ? (filename + '_border') : filename; return borderedEmoji.includes(filename) ? (filename + '_border') : filename;
}; };
@ -104,7 +104,7 @@ const emojifyTextNode = (node, customEmojis) => {
if(isSystemTheme) { if(isSystemTheme) {
let source = document.createElement('source'); let source = document.createElement('source');
source.setAttribute('media', '(prefers-color-scheme: dark)'); source.setAttribute('media', '(prefers-color-scheme: dark)');
source.setAttribute('srcset', `${assetHost}/emoji/${emojiFilename(filename, "dark")}.svg`); source.setAttribute('srcset', `${assetHost}/emoji/${emojiFilename(filename, 'dark')}.svg`);
replacement.appendChild(source); replacement.appendChild(source);
} }
@ -114,10 +114,10 @@ const emojifyTextNode = (node, customEmojis) => {
img.setAttribute('alt', unicode_emoji); img.setAttribute('alt', unicode_emoji);
img.setAttribute('title', title); img.setAttribute('title', title);
let theme = "light"; let theme = 'light';
if(!isSystemTheme && !document.body?.classList.contains('theme-mastodon-light')) if(!isSystemTheme && !document.body?.classList.contains('theme-mastodon-light'))
theme = "dark"; theme = 'dark';
img.setAttribute('src', `${assetHost}/emoji/${emojiFilename(filename, theme)}.svg`); img.setAttribute('src', `${assetHost}/emoji/${emojiFilename(filename, theme)}.svg`);
replacement.appendChild(img); replacement.appendChild(img);

View file

@ -158,7 +158,7 @@ export default class Card extends PureComponent {
}; };
if (largeImage && card.get('type') === 'video') { if (largeImage && card.get('type') === 'video') {
thumbnailStyle.aspectRatio = `16 / 9`; thumbnailStyle.aspectRatio = '16 / 9';
} else if (largeImage) { } else if (largeImage) {
thumbnailStyle.aspectRatio = '1.91 / 1'; thumbnailStyle.aspectRatio = '1.91 / 1';
} else { } else {

View file

@ -121,7 +121,7 @@ class NavigationPanel extends Component {
if(transientSingleColumn) if(transientSingleColumn)
banner = (<div className='switch-to-advanced'> banner = (<div className='switch-to-advanced'>
{intl.formatMessage(messages.openedInClassicInterface)} {intl.formatMessage(messages.openedInClassicInterface)}
{" "} {' '}
<a href={`/deck${location.pathname}`} className='switch-to-advanced__toggle'> <a href={`/deck${location.pathname}`} className='switch-to-advanced__toggle'>
{intl.formatMessage(messages.advancedInterface)} {intl.formatMessage(messages.advancedInterface)}
</a> </a>

View file

@ -68,7 +68,7 @@ const element = document.getElementById('initial-state');
const initialState = element?.textContent && JSON.parse(element.textContent); const initialState = element?.textContent && JSON.parse(element.textContent);
/** @type {string} */ /** @type {string} */
const initialPath = document.querySelector("head meta[name=initialPath]")?.getAttribute("content") ?? ''; const initialPath = document.querySelector('head meta[name=initialPath]')?.getAttribute('content') ?? '';
/** @type {boolean} */ /** @type {boolean} */
export const hasMultiColumnPath = initialPath === '/' export const hasMultiColumnPath = initialPath === '/'
|| initialPath === '/getting-started' || initialPath === '/getting-started'

View file

@ -5,7 +5,7 @@ import { toServerSideType } from 'mastodon/utils/filters';
import { me } from '../initial_state'; import { me } from '../initial_state';
export { makeGetAccount } from "./accounts"; export { makeGetAccount } from './accounts';
const getFilters = (state, { contextType }) => { const getFilters = (state, { contextType }) => {
if (!contextType) return null; if (!contextType) return null;

View file

@ -150,7 +150,7 @@ export const connectStream = (channelName, params, callbacks) => (dispatch, getS
const accessToken = getAccessToken(); const accessToken = getAccessToken();
const { onConnect, onReceive, onDisconnect } = callbacks(dispatch, getState); const { onConnect, onReceive, onDisconnect } = callbacks(dispatch, getState);
if(!accessToken) throw new Error("Trying to connect to the streaming server but no access token is available."); if(!accessToken) throw new Error('Trying to connect to the streaming server but no access token is available.');
// If we cannot use a websockets connection, we must fall back // If we cannot use a websockets connection, we must fall back
// to using individual connections for each channel // to using individual connections for each channel

View file

@ -7,8 +7,8 @@ module.exports = (api) => {
}; };
const envOptions = { const envOptions = {
useBuiltIns: "usage", useBuiltIns: 'usage',
corejs: { version: "3.30" }, corejs: { version: '3.30' },
debug: false, debug: false,
include: [ include: [
'transform-numeric-separator', 'transform-numeric-separator',

View file

@ -1,6 +1,6 @@
const path = require('path'); const path = require('path');
const currentTranslations = require(path.join(__dirname, "../app/javascript/mastodon/locales/en.json")); const currentTranslations = require(path.join(__dirname, '../app/javascript/mastodon/locales/en.json'));
exports.format = (msgs) => { exports.format = (msgs) => {
const results = {}; const results = {};

View file

@ -97,7 +97,7 @@ module.exports = {
'node_modules', 'node_modules',
], ],
alias: { alias: {
"@": resolve(settings.source_path), '@': resolve(settings.source_path),
} }
}, },

View file

@ -29,7 +29,7 @@ export class RequestError extends Error {
*/ */
constructor(message) { constructor(message) {
super(message); super(message);
this.name = "RequestError"; this.name = 'RequestError';
this.status = 400; this.status = 400;
} }
} }
@ -40,7 +40,7 @@ export class AuthenticationError extends Error {
*/ */
constructor(message) { constructor(message) {
super(message); super(message);
this.name = "AuthenticationError"; this.name = 'AuthenticationError';
this.status = 401; this.status = 401;
} }
} }

View file

@ -91,7 +91,7 @@ const parseJSON = (json, req) => {
req.log.error({ err }, `Error parsing message from ${req.remoteAddress}`); req.log.error({ err }, `Error parsing message from ${req.remoteAddress}`);
} }
} else { } else {
logger.error({ err }, `Error parsing message from redis`); logger.error({ err }, 'Error parsing message from redis');
} }
return null; return null;
} }
@ -292,7 +292,7 @@ const startServer = async () => {
const wss = new WebSocketServer({ noServer: true }); const wss = new WebSocketServer({ noServer: true });
// Set the X-Request-Id header on WebSockets: // Set the X-Request-Id header on WebSockets:
wss.on("headers", function onHeaders(headers, req) { wss.on('headers', function onHeaders(headers, req) {
headers.push(`X-Request-Id: ${req.id}`); headers.push(`X-Request-Id: ${req.id}`);
}); });
@ -312,7 +312,7 @@ const startServer = async () => {
// logger. This decorates the `request` object. // logger. This decorates the `request` object.
attachWebsocketHttpLogger(request); attachWebsocketHttpLogger(request);
request.log.info("HTTP Upgrade Requested"); request.log.info('HTTP Upgrade Requested');
/** @param {Error} err */ /** @param {Error} err */
const onSocketError = (err) => { const onSocketError = (err) => {
@ -365,7 +365,7 @@ const startServer = async () => {
socket.removeListener('error', onSocketError); socket.removeListener('error', onSocketError);
wss.handleUpgrade(request, socket, head, function done(ws) { wss.handleUpgrade(request, socket, head, function done(ws) {
request.log.info("Authenticated request & upgraded to WebSocket connection"); request.log.info('Authenticated request & upgraded to WebSocket connection');
const wsLogger = createWebsocketLogger(request, resolvedAccount); const wsLogger = createWebsocketLogger(request, resolvedAccount);
@ -454,7 +454,7 @@ const startServer = async () => {
callbacks.forEach(callback => callback(json)); callbacks.forEach(callback => callback(json));
}; };
redisSubscribeClient.on("message", onRedisMessage); redisSubscribeClient.on('message', onRedisMessage);
/** /**
* @callback SubscriptionListener * @callback SubscriptionListener
@ -776,7 +776,7 @@ const startServer = async () => {
* @returns {SubscriptionListener} * @returns {SubscriptionListener}
*/ */
const streamFrom = (channelIds, req, log, output, attachCloseHandler, destinationType, needsFiltering = false) => { const streamFrom = (channelIds, req, log, output, attachCloseHandler, destinationType, needsFiltering = false) => {
log.info({ channelIds }, `Starting stream`); log.info({ channelIds }, 'Starting stream');
/** /**
* @param {string} event * @param {string} event
@ -883,7 +883,7 @@ const startServer = async () => {
// If the payload already contains the `filtered` property, it means // If the payload already contains the `filtered` property, it means
// that filtering has been applied on the ruby on rails side, as // that filtering has been applied on the ruby on rails side, as
// such, we don't need to construct or apply the filters in streaming: // such, we don't need to construct or apply the filters in streaming:
if (Object.hasOwn(payload, "filtered")) { if (Object.hasOwn(payload, 'filtered')) {
transmit(event, payload); transmit(event, payload);
return; return;
} }
@ -1039,7 +1039,7 @@ const startServer = async () => {
const heartbeat = setInterval(() => res.write(':thump\n'), 15000); const heartbeat = setInterval(() => res.write(':thump\n'), 15000);
req.on('close', () => { req.on('close', () => {
req.log.info({ accountId: req.accountId }, `Ending stream`); req.log.info({ accountId: req.accountId }, 'Ending stream');
// We decrement these counters here instead of in streamHttpEnd as in that // We decrement these counters here instead of in streamHttpEnd as in that
// method we don't have knowledge of the channel names // method we don't have knowledge of the channel names
@ -1092,7 +1092,7 @@ const startServer = async () => {
ws.send(message, (/** @type {Error|undefined} */ err) => { ws.send(message, (/** @type {Error|undefined} */ err) => {
if (err) { if (err) {
req.log.error({err}, `Failed to send to websocket`); req.log.error({err}, 'Failed to send to websocket');
} }
}); });
}; };
@ -1347,7 +1347,7 @@ const startServer = async () => {
* @param {string[]} channelIds * @param {string[]} channelIds
*/ */
const removeSubscription = ({ request, logger, subscriptions }, channelIds) => { const removeSubscription = ({ request, logger, subscriptions }, channelIds) => {
logger.info({ channelIds, accountId: request.accountId }, `Ending stream`); logger.info({ channelIds, accountId: request.accountId }, 'Ending stream');
const subscription = subscriptions[channelIds.join(';')]; const subscription = subscriptions[channelIds.join(';')];
@ -1382,7 +1382,7 @@ const startServer = async () => {
// If we have a socket that is alive and open still, send the error back to the client: // If we have a socket that is alive and open still, send the error back to the client:
if (websocket.isAlive && websocket.readyState === websocket.OPEN) { if (websocket.isAlive && websocket.readyState === websocket.OPEN) {
// TODO: Use a better error response here // TODO: Use a better error response here
websocket.send(JSON.stringify({ error: "Error unsubscribing from channel" })); websocket.send(JSON.stringify({ error: 'Error unsubscribing from channel' }));
} }
}); });
}; };

View file

@ -37,7 +37,7 @@ function sanitizeRequestLog(req) {
} }
export const logger = pino({ export const logger = pino({
name: "streaming", name: 'streaming',
// Reformat the log level to a string: // Reformat the log level to a string:
formatters: { formatters: {
level: (label) => { level: (label) => {