Skip to content

Commit

Permalink
enable useTemplate rule
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi committed Jan 8, 2025
1 parent 20d6bd8 commit 6bd5322
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bump-manifest-version.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ function bumpVersion(existingVersion, type) {
case 'minor':
return [major, minor + 1, 0, 0];
default:
throw new Error('Unknown bump type: ' + type);
throw new Error(`Unknown bump type: ${type}`);
}
}
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"rules": {
"recommended": true,
"style": {
"useTemplate": "off",
"useTemplate": "info",
"noUnusedTemplateLiteral": "off",
"noUselessElse": "off",
"noNonNullAssertion": "off"
Expand Down
8 changes: 4 additions & 4 deletions esbuild/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function liveReloadPlugin({ target }: { target: Target }): ESBuildPlugin {
build.onLoad({ filter: /src\/background\/index\.ts$/ }, async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: reloadScriptBackground + '\n' + contents,
contents: `${reloadScriptBackground}\n${contents}`,
loader: 'ts' as const,
};
});
Expand All @@ -108,22 +108,22 @@ function liveReloadPlugin({ target }: { target: Target }): ESBuildPlugin {
async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: contents + '\n\n\n' + reloadScriptPopup,
contents: `${contents}\n\n\n${reloadScriptPopup}`,
loader: 'tsx' as const,
};
},
);
build.onLoad({ filter: /src\/pages\/.+\/index.tsx$/ }, async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: contents + '\n\n\n' + reloadScriptPages,
contents: `${contents}\n\n\n${reloadScriptPages}`,
loader: 'tsx' as const,
};
});
build.onLoad({ filter: /src\/content\// }, async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: contents + '\n\n\n' + reloadScriptContent,
contents: `${contents}\n\n\n${reloadScriptContent}`,
loader: 'ts' as const,
};
});
Expand Down
4 changes: 2 additions & 2 deletions esbuild/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ function processManifestPlugin({
}

if (channel === 'preview') {
json.name = json.name + ' Preview';
json.name = `${json.name} Preview`;
} else if (channel === 'nightly') {
json.name = json.name + ' Nightly';
json.name = `${json.name} Nightly`;
}

if (dev) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sade('build [target]', true)
.option('--dev', 'Dev-mode (watch, live-reload)', false)
.example('chrome --channel=nightly')
.example('firefox --channel=stable')
.describe(['`target` should be one of ' + TARGETS.join(', ')])
.describe([`\`target\` should be one of ${TARGETS.join(', ')}`])
.action(async (target: Target, opts: BuildArgs) => {
const options = { ...opts, target };
if (!options.target && !options.dev) {
Expand All @@ -36,11 +36,11 @@ sade('build [target]', true)
}

if (!TARGETS.includes(options.target)) {
console.warn('Invalid --target. Must be one of ' + TARGETS.join(', '));
console.warn(`Invalid --target. Must be one of ${TARGETS.join(', ')}`);
process.exit(1);
}
if (!CHANNELS.includes(options.channel)) {
console.warn('Invalid --channel. Must be one of ' + CHANNELS.join(', '));
console.warn(`Invalid --channel. Must be one of ${CHANNELS.join(', ')}`);
process.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/background/services/deduplicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Deduplicator {

if (entry) {
this.logger.debug(
`Deduplicating function=${fn.name}, ${cacheFnArgs ? 'args=' + JSON.stringify(args) : 'without args'}`,
`Deduplicating function=${fn.name}, ${cacheFnArgs ? `args=${JSON.stringify(args)}` : 'without args'}`,
);
return entry.promise as ReturnType<T>;
}
Expand Down
2 changes: 1 addition & 1 deletion src/background/services/openPayments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ export class OpenPaymentsService {
hash,
authServer,
}: VerifyInteractionHashParams): Promise<void> {
const grantEndpoint = new URL(authServer).origin + '/';
const grantEndpoint = `${new URL(authServer).origin}/`;
const data = new TextEncoder().encode(
`${clientNonce}\n${interactNonce}\n${interactRef}\n${grantEndpoint}`,
);
Expand Down
2 changes: 1 addition & 1 deletion src/content/keyAutoAdd/lib/keyAutoAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class KeyAutoAdd {
browser.runtime.getURL('pages/progress-connect/index.html'),
);
const params = new URLSearchParams({ mode: size });
iframeUrl.hash = '?' + params.toString();
iframeUrl.hash = `?${params.toString()}`;
if (this.ui.src !== iframeUrl.href && size !== 'hidden') {
this.ui.src = iframeUrl.href;
}
Expand Down
2 changes: 1 addition & 1 deletion src/content/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type { MonetizationEventPayload } from '@/shared/messages';
this.addEventListener('monetization', val);
handlers.set(this, val);
} else {
throw new Error('val must be a function, got ' + typeof val);
throw new Error(`val must be a function, got ${typeof val}`);
}
},
};
Expand Down
7 changes: 2 additions & 5 deletions src/content/services/monetizationLinkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ export class MonetizationLinkManager extends EventEmitter {
url = new URL(href);
if (url.protocol !== 'https:') {
throw new WalletAddressFormatError(
`Wallet address URL must be specified as a fully resolved https:// url, ` +
`got ${JSON.stringify(href)} `,
`Wallet address URL must be specified as a fully resolved https:// url, got ${JSON.stringify(href)} `,
);
}
} catch (e) {
Expand Down Expand Up @@ -517,9 +516,7 @@ export class MonetizationLinkManager extends EventEmitter {
const details = this.monetizationLinks.get(link);
if (!details) {
throw new Error(
'Could not find details for monetization node ' +
// node is removed, so the reference can not be displayed
link.outerHTML.slice(0, 200),
`Could not find details for monetization node ${link.outerHTML.slice(0, 200)}`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/shared/lib/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('useLocalStorage', () => {
<button
type="button"
data-testid="set-cb"
onClick={() => setData((data) => data + 'Foo')}
onClick={() => setData((data) => `${data}Foo`)}
>
Set data callback
</button>
Expand Down
18 changes: 6 additions & 12 deletions tests/e2e/fixtures/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,17 @@ export const expect = test.expect.extend({

const message = pass
? () =>
this.utils.matcherHint(assertionName, undefined, undefined, {
`${this.utils.matcherHint(assertionName, undefined, undefined, {
isNot: this.isNot,
}) +
'\n\n' +
`Expected: not ${this.utils.printExpected(expected)}\n` +
(matcherResult
})}\n\nExpected: not ${this.utils.printExpected(expected)}\n${matcherResult
? `Received: ${this.utils.printReceived(matcherResult.actual)}`
: '')
: ''}`
: () =>
this.utils.matcherHint(assertionName, undefined, undefined, {
`${this.utils.matcherHint(assertionName, undefined, undefined, {
isNot: this.isNot,
}) +
'\n\n' +
`Expected: ${this.utils.printExpected(expected)}\n` +
(matcherResult
})}\n\nExpected: ${this.utils.printExpected(expected)}\n${matcherResult
? `Received: ${this.utils.printReceived(matcherResult.actual)}`
: '');
: ''}`;

return {
name: assertionName,
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/fixtures/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function loadContext(
}

if (!context) {
throw new Error('Unknown browser: ' + browserName);
throw new Error(`Unknown browser: ${browserName}`);
}

// Note that loading this directly via config -> use({ storageState }) doesn't
Expand All @@ -195,7 +195,7 @@ function getPathToExtension(browserName: string) {
} else if (browserName === 'firefox') {
pathToExtension = path.join(BUILD_DIR, 'firefox');
} else {
throw new Error('Unknown browser: ' + browserName);
throw new Error(`Unknown browser: ${browserName}`);
}
return pathToExtension;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ export async function getBackground(
//
// }
} else {
throw new Error('Unsupported browser: ' + browserName);
throw new Error(`Unsupported browser: ${browserName}`);
}

if (!background) {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/helpers/testWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function revokeKey(
credentials: 'include',
});
if (!res.ok) {
throw new Error('Failed to revoke key: ' + (await res.text()));
throw new Error(`Failed to revoke key: ${await res.text()}`);
}
}, url);
}

0 comments on commit 6bd5322

Please sign in to comment.