Allow .tsx files to be .std.tsx

This commit is contained in:
Fedor Indutny
2025-10-28 14:22:36 -07:00
committed by GitHub
parent 14360b2ed7
commit 7b48f59f59
5 changed files with 31 additions and 18 deletions

View File

@@ -409,13 +409,13 @@ module.exports = {
const [, moduleName] = source.match(/^([^@\/]+|@[^\/]+\/[^\/]+)/);
if (NODE_PACKAGES.has(moduleName)) {
nodeUses.push(node);
} else if (source === 'react-dom/server') {
// no-op
} else if (
DOM_PACKAGES.has(moduleName) ||
source === 'react-dom/client'
) {
domUses.push(node);
} else if (source === 'react-dom/server') {
// no-op
} else if (!STD_PACKAGES.has(moduleName)) {
context.report({
node,
@@ -490,8 +490,13 @@ module.exports = {
expectedSuffix = 'std';
}
// All .std.tsx components should be .dom.tsx for now
if (expectedSuffix === 'std' && filename.endsWith('.tsx')) {
// All .tsx files should normally be .dom.tsx, but could also be
// .std.tsx.
if (
expectedSuffix === 'std' &&
filename.endsWith('.tsx') &&
fileSuffix !== 'std'
) {
expectedSuffix = 'dom';
}

View File

@@ -332,6 +332,7 @@ module.exports = {
'ts/**/*.ts',
'ts/**/*.tsx',
'app/**/*.ts',
'app/**/*.tsx',
'build/intl-linter/**/*.ts',
],
parser: '@typescript-eslint/parser',

View File

@@ -13,8 +13,7 @@ import { createLogger } from '../ts/logging/log.std.js';
import { AUMID } from './startup_config.main.js';
import type { WindowsNotificationData } from '../ts/services/notifications.preload.js';
import OS from '../ts/util/os/osMain.node.js';
// eslint-disable-next-line local-rules/file-suffix
import { renderWindowsToast } from './renderWindowsToast.dom.js';
import { renderWindowsToast } from './renderWindowsToast.std.js';
export { sendDummyKeystroke };

View File

@@ -19,21 +19,29 @@ function pathToUri(path: string) {
return `file:///${encodeURI(path.replace(/\\/g, '/'))}`;
}
const Toast = (props: {
function Toast(props: {
launch: string;
// Note: though React doesn't like it, Windows seems to require that this be camelcase
activationType: string;
children: React.ReactNode;
}) => React.createElement('toast', props);
const Visual = (props: { children: React.ReactNode }) =>
React.createElement('visual', props);
const Binding = (props: { template: string; children: React.ReactNode }) =>
React.createElement('binding', props);
const Text = (props: { id: string; children: React.ReactNode }) =>
React.createElement('text', props);
const Image = (props: { id: string; src: string; 'hint-crop': string }) =>
React.createElement('image', props);
const Audio = (props: { src: string }) => React.createElement('audio', props);
}) {
return React.createElement('toast', props);
}
function Visual(props: { children: React.ReactNode }) {
return React.createElement('visual', props);
}
function Binding(props: { template: string; children: React.ReactNode }) {
return React.createElement('binding', props);
}
function Text(props: { id: string; children: React.ReactNode }) {
return React.createElement('text', props);
}
function Image(props: { id: string; src: string; 'hint-crop': string }) {
return React.createElement('image', props);
}
function Audio(props: { src: string }) {
return React.createElement('audio', props);
}
export function renderWindowsToast({
avatarPath,

View File

@@ -3,7 +3,7 @@
import { assert } from 'chai';
import { renderWindowsToast } from '../../../app/renderWindowsToast.dom.js';
import { renderWindowsToast } from '../../../app/renderWindowsToast.std.js';
import { NotificationType } from '../../types/notifications.std.js';
describe('renderWindowsToast', () => {