Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ESLint to replace double quotes #30107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,16 @@ module.exports = defineConfig({
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
"@typescript-eslint/prefer-nullish-coalescing": ['error', { ignorePrimitives: { boolean: true } }],
"@typescript-eslint/no-restricted-imports": [
"warn",
'@typescript-eslint/prefer-nullish-coalescing': ['error', { ignorePrimitives: { boolean: true } }],
'@typescript-eslint/no-restricted-imports': [
'warn',
{
"name": "react-redux",
"importNames": ["useSelector", "useDispatch"],
"message": "Use typed hooks `useAppDispatch` and `useAppSelector` instead."
'name': 'react-redux',
'importNames': ['useSelector', 'useDispatch'],
'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',

// Those rules set stricter rules for TS files
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/domain_blocks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import api, { getLinks } from '../api';

import { blockDomainSuccess, unblockDomainSuccess } from "./domain_blocks_typed";
import { blockDomainSuccess, unblockDomainSuccess } from './domain_blocks_typed';
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_FAIL = 'DOMAIN_BLOCK_FAIL';
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';

export * from "./interactions_typed";
export * from './interactions_typed';

export function favourite(status) {
return function (dispatch) {
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {
importFetchedStatuses,
} from './importer';
import { submitMarkers } from './markers';
import { notificationsUpdate } from "./notifications_typed";
import { notificationsUpdate } from './notifications_typed';
import { register as registerPushNotifications } from './push_notifications';
import { saveSettings } from './settings';

export * from "./notifications_typed";
export * from './notifications_typed';

export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { countableText } from '../util/counter';
import { CharacterCounter } from './character_counter';
import { EditIndicator } from './edit_indicator';
import { NavigationBar } from './navigation_bar';
import { PollForm } from "./poll_form";
import { PollForm } from './poll_form';
import { ReplyIndicator } from './reply_indicator';
import { UploadForm } from './upload_form';

Expand Down
8 changes: 4 additions & 4 deletions app/javascript/mastodon/features/emoji/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const lightEmoji = emojiFilenames(['👽', '⚾', '🐔', '☁️', '💨', '
* @returns {string}
*/
const emojiFilename = (filename, colorScheme) => {
const borderedEmoji = colorScheme === "light" ? lightEmoji : darkEmoji;
const borderedEmoji = colorScheme === 'light' ? lightEmoji : darkEmoji;
return borderedEmoji.includes(filename) ? (filename + '_border') : filename;
};

Expand Down Expand Up @@ -104,7 +104,7 @@ const emojifyTextNode = (node, customEmojis) => {
if(isSystemTheme) {
let source = document.createElement('source');
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);
}

Expand All @@ -114,10 +114,10 @@ const emojifyTextNode = (node, customEmojis) => {
img.setAttribute('alt', unicode_emoji);
img.setAttribute('title', title);

let theme = "light";
let theme = 'light';

if(!isSystemTheme && !document.body?.classList.contains('theme-mastodon-light'))
theme = "dark";
theme = 'dark';

img.setAttribute('src', `${assetHost}/emoji/${emojiFilename(filename, theme)}.svg`);
replacement.appendChild(img);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class Card extends PureComponent {
};

if (largeImage && card.get('type') === 'video') {
thumbnailStyle.aspectRatio = `16 / 9`;
thumbnailStyle.aspectRatio = '16 / 9';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially could skip these too, with the allowTemplateLiterals

} else if (largeImage) {
thumbnailStyle.aspectRatio = '1.91 / 1';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class NavigationPanel extends Component {
if(transientSingleColumn)
banner = (<div className='switch-to-advanced'>
{intl.formatMessage(messages.openedInClassicInterface)}
{" "}
{' '}
<a href={`/deck${location.pathname}`} className='switch-to-advanced__toggle'>
{intl.formatMessage(messages.advancedInterface)}
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const element = document.getElementById('initial-state');
const initialState = element?.textContent && JSON.parse(element.textContent);

/** @type {string} */
const initialPath = document.querySelector("head meta[name=initialPath]")?.getAttribute("content") ?? '';
const initialPath = document.querySelector('head meta[name=initialPath]')?.getAttribute('content') ?? '';
/** @type {boolean} */
export const hasMultiColumnPath = initialPath === '/'
|| initialPath === '/getting-started'
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toServerSideType } from 'mastodon/utils/filters';

import { me } from '../initial_state';

export { makeGetAccount } from "./accounts";
export { makeGetAccount } from './accounts';

const getFilters = (state, { contextType }) => {
if (!contextType) return null;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const connectStream = (channelName, params, callbacks) => (dispatch, getS
const accessToken = getAccessToken();
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
// to using individual connections for each channel
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = (api) => {
};

const envOptions = {
useBuiltIns: "usage",
corejs: { version: "3.30" },
useBuiltIns: 'usage',
corejs: { version: '3.30' },
debug: false,
include: [
'transform-numeric-separator',
Expand Down
2 changes: 1 addition & 1 deletion config/formatjs-formatter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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) => {
const results = {};
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {
'node_modules',
],
alias: {
"@": resolve(settings.source_path),
'@': resolve(settings.source_path),
}
},

Expand Down
4 changes: 2 additions & 2 deletions streaming/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class RequestError extends Error {
*/
constructor(message) {
super(message);
this.name = "RequestError";
this.name = 'RequestError';
this.status = 400;
}
}
Expand All @@ -40,7 +40,7 @@ export class AuthenticationError extends Error {
*/
constructor(message) {
super(message);
this.name = "AuthenticationError";
this.name = 'AuthenticationError';
this.status = 401;
}
}
22 changes: 11 additions & 11 deletions streaming/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const parseJSON = (json, req) => {
req.log.error({ err }, `Error parsing message from ${req.remoteAddress}`);
}
} else {
logger.error({ err }, `Error parsing message from redis`);
logger.error({ err }, 'Error parsing message from redis');
}
return null;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ const startServer = async () => {
const wss = new WebSocket.Server({ noServer: true });

// 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}`);
});

Expand All @@ -312,7 +312,7 @@ const startServer = async () => {
// logger. This decorates the `request` object.
attachWebsocketHttpLogger(request);

request.log.info("HTTP Upgrade Requested");
request.log.info('HTTP Upgrade Requested');

/** @param {Error} err */
const onSocketError = (err) => {
Expand Down Expand Up @@ -365,7 +365,7 @@ const startServer = async () => {
socket.removeListener('error', onSocketError);

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);

Expand Down Expand Up @@ -454,7 +454,7 @@ const startServer = async () => {

callbacks.forEach(callback => callback(json));
};
redisSubscribeClient.on("message", onRedisMessage);
redisSubscribeClient.on('message', onRedisMessage);

/**
* @callback SubscriptionListener
Expand Down Expand Up @@ -805,7 +805,7 @@ const startServer = async () => {
* @returns {SubscriptionListener}
*/
const streamFrom = (channelIds, req, log, output, attachCloseHandler, destinationType, needsFiltering = false) => {
log.info({ channelIds }, `Starting stream`);
log.info({ channelIds }, 'Starting stream');

/**
* @param {string} event
Expand Down Expand Up @@ -912,7 +912,7 @@ const startServer = async () => {
// If the payload already contains the `filtered` property, it means
// 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:
if (Object.hasOwn(payload, "filtered")) {
if (Object.hasOwn(payload, 'filtered')) {
transmit(event, payload);
return;
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@ const startServer = async () => {
const heartbeat = setInterval(() => res.write(':thump\n'), 15000);

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
// method we don't have knowledge of the channel names
Expand Down Expand Up @@ -1121,7 +1121,7 @@ const startServer = async () => {

ws.send(message, (/** @type {Error|undefined} */ err) => {
if (err) {
req.log.error({err}, `Failed to send to websocket`);
req.log.error({err}, 'Failed to send to websocket');
}
});
};
Expand Down Expand Up @@ -1376,7 +1376,7 @@ const startServer = async () => {
* @param {string[]} 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(';')];

Expand Down Expand Up @@ -1411,7 +1411,7 @@ const startServer = async () => {
// 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) {
// 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' }));
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion streaming/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function sanitizeRequestLog(req) {
}

export const logger = pino({
name: "streaming",
name: 'streaming',
// Reformat the log level to a string:
formatters: {
level: (label) => {
Expand Down