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

View File

@@ -332,6 +332,7 @@ module.exports = {
'ts/**/*.ts', 'ts/**/*.ts',
'ts/**/*.tsx', 'ts/**/*.tsx',
'app/**/*.ts', 'app/**/*.ts',
'app/**/*.tsx',
'build/intl-linter/**/*.ts', 'build/intl-linter/**/*.ts',
], ],
parser: '@typescript-eslint/parser', 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 { AUMID } from './startup_config.main.js';
import type { WindowsNotificationData } from '../ts/services/notifications.preload.js'; import type { WindowsNotificationData } from '../ts/services/notifications.preload.js';
import OS from '../ts/util/os/osMain.node.js'; import OS from '../ts/util/os/osMain.node.js';
// eslint-disable-next-line local-rules/file-suffix import { renderWindowsToast } from './renderWindowsToast.std.js';
import { renderWindowsToast } from './renderWindowsToast.dom.js';
export { sendDummyKeystroke }; export { sendDummyKeystroke };

View File

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

View File

@@ -3,7 +3,7 @@
import { assert } from 'chai'; 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'; import { NotificationType } from '../../types/notifications.std.js';
describe('renderWindowsToast', () => { describe('renderWindowsToast', () => {