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

Add eslint rule to avoid using unnecessary template experssions #50138

Open
wants to merge 7 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,18 @@ module.exports = {
'plugin:you-dont-need-lodash-underscore/all',
'plugin:prettier/recommended',
],
plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash', 'deprecation'],
plugins: [
'@stylistic/js',
'@typescript-eslint',
'jsdoc',
'you-dont-need-lodash-underscore',
'react-native-a11y',
'react',
'testing-library',
'eslint-plugin-react-compiler',
'lodash',
'deprecation',
],
ignorePatterns: ['lib/**'],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down Expand Up @@ -173,6 +184,9 @@ module.exports = {
},
],
'@typescript-eslint/no-use-before-define': ['error', {functions: false}],
// Add rules related to quotes
'@stylistic/js/quotes': ['error', 'single', {avoidEscape: true}],
'@typescript-eslint/no-unnecessary-template-expression': 'error',

// ESLint core rules
'es/no-nullish-coalescing-operators': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17311,7 +17311,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12552,7 +12552,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11835,7 +11835,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14550,7 +14550,7 @@ function getCommitHistoryAsJSON(fromTag, toTag) {
spawnedProcess.on('close', (code) => {
if (code !== 0) {
console.log('code: ', code);
return reject(new Error(`${stderr}`));
return reject(new Error(stderr));
}
resolve(stdout);
});
Expand Down Expand Up @@ -14872,7 +14872,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/getArtifactInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11796,7 +11796,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11836,7 +11836,7 @@ function getCommitHistoryAsJSON(fromTag, toTag) {
spawnedProcess.on('close', (code) => {
if (code !== 0) {
console.log('code: ', code);
return reject(new Error(`${stderr}`));
return reject(new Error(stderr));
}
resolve(stdout);
});
Expand Down Expand Up @@ -12158,7 +12158,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/getPreviousVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,7 @@ function getCommitHistoryAsJSON(fromTag, toTag) {
spawnedProcess.on('close', (code) => {
if (code !== 0) {
console.log('code: ', code);
return reject(new Error(`${stderr}`));
return reject(new Error(stderr));
}
resolve(stdout);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11898,7 +11898,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11796,7 +11796,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12721,7 +12721,7 @@ async function run() {
if (date) {
message += `on ${date}`;
}
message += `🚀`;
message += '🚀';
message += `\n\nplatform | result\n---|---\n🤖 android 🤖|${androidResult}\n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult}\n🕸 web 🕸|${webResult}`;
if (deployVerb === 'Cherry-picked' && !/no ?qa/gi.test(prTitle ?? '')) {
Expand Down Expand Up @@ -13192,7 +13192,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function run() {
if (date) {
message += `on ${date}`;
}
message += `🚀`;
message += '🚀';
message += `\n\nplatform | result\n---|---\n🤖 android 🤖|${androidResult}\n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult}\n🕸 web 🕸|${webResult}`;

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/postTestBuildComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11895,7 +11895,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18384,7 +18384,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11806,7 +11806,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/reviewerChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11898,7 +11898,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/verifySignedCommits/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11838,7 +11838,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/GitUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function getCommitHistoryAsJSON(fromTag: string, toTag: string): Promise<CommitT
spawnedProcess.on('close', (code) => {
if (code !== 0) {
console.log('code: ', code);
return reject(new Error(`${stderr}`));
return reject(new Error(stderr));
}

resolve(stdout);
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/GithubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class GithubUtils {
const merger = internalQAPRMap[URL];
const mergerMention = `@${merger}`;
issueBody += `${resolvedInternalQAPRs.includes(URL) ? '- [x]' : '- [ ]'} `;
issueBody += `${URL}`;
issueBody += URL;
issueBody += ` - ${mergerMention}`;
issueBody += '\r\n';
});
Expand Down
32 changes: 16 additions & 16 deletions desktop/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
return;
}

expectedUpdateVersion = arg.substr(`${EXPECTED_UPDATE_VERSION_FLAG}=`.length);

Check failure on line 110 in desktop/main.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'substr' is deprecated. A legacy feature for browser compatibility
});

// Add the listeners and variables required to ensure that auto-updating
Expand Down Expand Up @@ -202,8 +202,8 @@
init: () => {
autoUpdater.on(ELECTRON_EVENTS.UPDATE_DOWNLOADED, (info) => {
const systemMenu = Menu.getApplicationMenu();
const updateMenuItem = systemMenu?.getMenuItemById(`update`);
const checkForUpdatesMenuItem = systemMenu?.getMenuItemById(`checkForUpdates`);
const updateMenuItem = systemMenu?.getMenuItemById('update');
const checkForUpdatesMenuItem = systemMenu?.getMenuItemById('checkForUpdates');

downloadedVersion = info.version;

Expand Down Expand Up @@ -343,14 +343,14 @@
const initialMenuTemplate: MenuItemConstructorOptions[] = [
{
id: 'mainMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.mainMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.mainMenu'),
submenu: [
{id: 'about', role: 'about'},
{id: 'update', label: Localize.translate(preferredLocale, `desktopApplicationMenu.update`), click: quitAndInstallWithUpdate, visible: false},
{id: 'checkForUpdates', label: Localize.translate(preferredLocale, `desktopApplicationMenu.checkForUpdates`), click: manuallyCheckForUpdates},
{id: 'update', label: Localize.translate(preferredLocale, 'desktopApplicationMenu.update'), click: quitAndInstallWithUpdate, visible: false},
{id: 'checkForUpdates', label: Localize.translate(preferredLocale, 'desktopApplicationMenu.checkForUpdates'), click: manuallyCheckForUpdates},
{
id: 'viewShortcuts',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.viewShortcuts`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.viewShortcuts'),
accelerator: 'CmdOrCtrl+J',
click: () => {
showKeyboardShortcutsPage(browserWindow);
Expand All @@ -368,12 +368,12 @@
},
{
id: 'fileMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.fileMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.fileMenu'),
submenu: [{id: 'closeWindow', role: 'close', accelerator: 'Cmd+w'}],
},
{
id: 'editMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.editMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.editMenu'),
submenu: [
{id: 'undo', role: 'undo'},
{id: 'redo', role: 'redo'},
Expand All @@ -396,7 +396,7 @@
{type: 'separator'},
{
id: 'speechSubmenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.speechSubmenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.speechSubmenu'),
submenu: [
{id: 'startSpeaking', role: 'startSpeaking'},
{id: 'stopSpeaking', role: 'stopSpeaking'},
Expand All @@ -406,7 +406,7 @@
},
{
id: 'viewMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.viewMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.viewMenu'),
submenu: [
{id: 'reload', role: 'reload'},
{id: 'forceReload', role: 'forceReload'},
Expand All @@ -421,7 +421,7 @@
},
{
id: 'historyMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.historyMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.historyMenu'),
submenu: [
{
id: 'back',
Expand Down Expand Up @@ -462,33 +462,33 @@
},
{
id: 'helpMenu',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.helpMenu`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.helpMenu'),
role: 'help',
submenu: [
{
id: 'learnMore',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.learnMore`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.learnMore'),
click: () => {
shell.openExternal(CONST.MENU_HELP_URLS.LEARN_MORE);
},
},
{
id: 'documentation',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.documentation`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.documentation'),
click: () => {
shell.openExternal(CONST.MENU_HELP_URLS.DOCUMENTATION);
},
},
{
id: 'communityDiscussions',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.communityDiscussions`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.communityDiscussions'),
click: () => {
shell.openExternal(CONST.MENU_HELP_URLS.COMMUNITY_DISCUSSIONS);
},
},
{
id: 'searchIssues',
label: Localize.translate(preferredLocale, `desktopApplicationMenu.searchIssues`),
label: Localize.translate(preferredLocale, 'desktopApplicationMenu.searchIssues'),
click: () => {
shell.openExternal(CONST.MENU_HELP_URLS.SEARCH_ISSUES);
},
Expand All @@ -507,7 +507,7 @@
const denial = {action: 'deny'} as const;

// Make sure local urls stay in electron perimeter
if (url.substr(0, 'file://'.length).toLowerCase() === 'file://') {

Check failure on line 510 in desktop/main.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'substr' is deprecated. A legacy feature for browser compatibility
return denial;
}

Expand Down
Loading
Loading