Skip to content

Commit

Permalink
Migrate from fbt to fbtee.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: c4d082f4438cf3123418e29418da0d2cf95a4563
  • Loading branch information
cpojer committed Jan 8, 2025
1 parent eb5c5ca commit f9c8fdd
Show file tree
Hide file tree
Showing 82 changed files with 515 additions and 1,066 deletions.
13 changes: 8 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ const { join } = require('node:path');
const { existsSync, readFileSync } = require('node:fs');

module.exports = {
extends: ['@nkzw', 'plugin:@deities/strict'],
extends: [
'@nkzw',
'plugin:@deities/strict',
'plugin:@nkzw/eslint-plugin-fbtee/recommended',
],
ignorePatterns: [
'artemis/prisma/pothos-types.ts',
'dist/',
Expand All @@ -25,7 +29,7 @@ module.exports = {
},
},
{
files: ['i18n/**/*.cjs', 'hera/i18n/**/EntityMap.tsx'],
files: ['i18n/**/*.ts', 'hera/i18n/**/EntityMap.tsx'],
rules: {
'sort-keys-fix/sort-keys-fix': 0,
},
Expand All @@ -50,8 +54,7 @@ module.exports = {
files: [
'.eslintrc.cjs',
'eslint-plugin/index.js',
'i18n/Common.cjs',
'infra/babelPlugins.tsx',
'infra/babelPresets.tsx',
],
rules: {
'@typescript-eslint/no-require-imports': 0,
Expand All @@ -64,7 +67,7 @@ module.exports = {
},
},
],
plugins: ['@deities', 'workspaces'],
plugins: ['@deities', 'workspaces', '@nkzw/eslint-plugin-fbtee'],
rules: {
'@typescript-eslint/array-type': [2, { default: 'generic' }],
'@typescript-eslint/no-restricted-imports': [
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ artemis/graphql/schemaImportMap.tsx
hera/i18n/CampaignMap.tsx
hera/i18n/EntityMap.tsx
hermes/CampaignMapName.tsx
i18n/Entities.cjs
i18n/Entities.ts
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ artemis/graphql/schemaImportMap.tsx
hera/i18n/CampaignMap.tsx
hera/i18n/EntityMap.tsx
hermes/CampaignMapName.tsx
i18n/Entities.cjs
i18n/Entities.ts

# Codegen but checked-in
hera/render/Images.tsx
6 changes: 3 additions & 3 deletions ares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "module",
"scripts": {
"fbt": "pnpm run fbt:manifest && pnpm run fbt:collect && pnpm run fbt:translate",
"fbt:collect": "../node_modules/.bin/fbt-collect --transform $(pwd)/scripts/collectionTransform.cjs --pretty --manifest < .src_manifest.json > ../source_strings.json",
"fbt:manifest": "../node_modules/.bin/fbt-manifest --src src ../hera ../ui",
"fbt:collect": "../node_modules/.bin/fbtee collect --fbt-common-path ../i18n/Common.ts --pretty --manifest < .src_manifest.json > ../source_strings.json",
"fbt:manifest": "../node_modules/.bin/fbtee manifest --src src ../hera ../ui",
"fbt:translate": "mkdir -p src/generated/ && node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm ./scripts/translations.js"
},
"dependencies": {
Expand All @@ -36,7 +36,7 @@
"@stripe/react-stripe-js": "^3.1.1",
"@stripe/stripe-js": "^5.4.0",
"cordova-plugin-purchase": "^13.12.1",
"fbt": "^1.0.2",
"fbtee": "^0.2.0",
"framer-motion": "^11.15.0",
"p-limit": "^6.2.0",
"react": "19.0.0",
Expand Down
8 changes: 4 additions & 4 deletions codegen/generate-translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const publishedCampaigns = new Map([
['tutorial', Number.POSITIVE_INFINITY],
]);

const COMMON_OUTPUT_FILE = join(root, 'i18n/Entities.cjs');
const COMMON_OUTPUT_FILE = join(root, 'i18n/Entities.ts');
const FBT_ENTITY_MAP_OUTPUT_FILE = join(root, 'hera/i18n/EntityMap.tsx');
const FBT_CAMPAIGN_MAP_OUTPUT_FILE = join(root, 'hera/i18n/CampaignMap.tsx');

Expand Down Expand Up @@ -369,7 +369,7 @@ for (const { description, key, message, unitId } of characterMessages) {
const plugins = ['@ianvs/prettier-plugin-sort-imports'];
writeFileSync(
COMMON_OUTPUT_FILE,
await format(sign(`module.exports = {${common.join(',\n')}};`), {
await format(sign(`export default {${common.join(',\n')}};`), {
filepath: COMMON_OUTPUT_FILE,
plugins,
singleQuote: true,
Expand All @@ -382,7 +382,7 @@ writeFileSync(
sign(
[
`import { getUnitInfoOrThrow } from '@deities/athena/info/Unit.tsx';`,
`import { fbt } from 'fbt';`,
`import { fbt } from 'fbtee';`,
...entities,
].join('\n'),
),
Expand All @@ -400,7 +400,7 @@ writeFileSync(
sign(
[
`import { getUnitInfoOrThrow } from '@deities/athena/info/Unit.tsx';`,
`import { fbt } from 'fbt';`,
`import { fbt } from 'fbtee';`,
`export const CampaignMetadata = {${campaignMetadata.join('\n')}};\n`,
`export default {`,
campaign.join('\n'),
Expand Down
2 changes: 1 addition & 1 deletion deimos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@deities/ui": "workspace:*",
"@emotion/css": "^11.13.5",
"array-shuffle": "^3.0.0",
"fbt": "^1.0.2",
"fbtee": "^0.2.0",
"framer-motion": "^11.15.0",
"react": "19.0.0",
"react-dom": "19.0.0",
Expand Down
4 changes: 2 additions & 2 deletions docs/content/playground/ClientScope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { AlertContext } from '@deities/ui/hooks/useAlert.tsx';
import { ScaleContext } from '@deities/ui/hooks/useScale.tsx';
import { setDefaultPortalContainer } from '@deities/ui/Portal.tsx';
import { css } from '@emotion/css';
import { init as initFbt, IntlVariations } from 'fbt';
import { IntlVariations, setupFbtee } from 'fbtee';
import { ReactElement } from 'react';

initializeCSSVariables();

initFbt({
setupFbtee({
hooks: {
getViewerContext: () => ({
GENDER: IntlVariations.GENDER_UNKNOWN,
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@emotion/css": "^11.13.5",
"@types/react": "^19.0.2",
"dunkel-theme": "^1.7.1",
"fbt": "^1.0.2",
"fbtee": "^0.2.0",
"framer-motion": "^11.15.0",
"licht-theme": "^1.7.1",
"react": "19.0.0",
Expand Down
5 changes: 3 additions & 2 deletions docs/vocs.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import babelPluginEmotion from '@emotion/babel-plugin';
import react from '@vitejs/plugin-react';
import React from 'react';
import { defineConfig } from 'vocs';
import babelPlugins from '../infra/babelPlugins.tsx';
import presets from '../infra/babelPresets.tsx';
import createResolver from '../infra/createResolver.tsx';

const Licht = JSON.parse(
Expand Down Expand Up @@ -149,7 +149,8 @@ export default defineConfig({
// @ts-expect-error
react({
babel: {
plugins: [...babelPlugins, babelPluginEmotion],
plugins: [babelPluginEmotion],
presets,
},
}),
],
Expand Down
4 changes: 0 additions & 4 deletions eslint-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ module.exports = {
rules: {
'@deities/no-copy-expression': 2,
'@deities/no-date-now': 2,
'@deities/no-fbt-import': 2,
'@deities/no-inline-css': 2,
'@deities/no-lazy-import': 2,
'@deities/require-fbt-description': 2,
'@deities/require-use-effect-arguments': 2,
'@deities/use-relay-types': 2,
},
Expand All @@ -16,10 +14,8 @@ module.exports = {
rules: {
'no-copy-expression': require('./no-copy-expression'),
'no-date-now': require('./no-date-now'),
'no-fbt-import': require('./no-fbt-import'),
'no-inline-css': require('./no-inline-css'),
'no-lazy-import': require('./no-lazy-import'),
'require-fbt-description': require('./require-fbt-description'),
'require-use-effect-arguments': require('./require-use-effect-arguments'),
'use-relay-types': require('./use-relay-types'),
},
Expand Down
23 changes: 0 additions & 23 deletions eslint-plugin/no-fbt-import.js

This file was deleted.

30 changes: 0 additions & 30 deletions eslint-plugin/require-fbt-description.js

This file was deleted.

20 changes: 11 additions & 9 deletions hera/action-response/processActionResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import dateNow from '@deities/hephaestus/dateNow.tsx';
import UnknownTypeError from '@deities/hephaestus/UnknownTypeError.tsx';
import ImmutableMap from '@nkzw/immutable-map';
import arrayShuffle from 'array-shuffle';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import addIncreaseValueAnimation from '../animations/addIncreaseValueAnimation.tsx';
import animateFireworks, {
getPossibleFireworksPositions,
Expand Down Expand Up @@ -65,7 +65,6 @@ import sabotageAction, {
addSabotageAnimation,
} from '../behavior/sabotage/sabotageAction.tsx';
import unfoldAction from '../behavior/unfold/unfoldAction.tsx';
import intlList, { Conjunctions, Delimiters } from '../i18n/intlList.tsx';
import translateMessage from '../i18n/translateMessage.tsx';
import abandonInvasion from '../lib/abandonInvasion.tsx';
import addEndTurnAnimations from '../lib/addEndTurnAnimations.tsx';
Expand Down Expand Up @@ -522,7 +521,12 @@ async function processActionResponse(
length: 'medium',
player: 0,
sound: null,
text: String(fbt(`The game ended in a draw!`, 'Draw')),
text: String(
fbt(
`The game ended in a draw!`,
'Text for when a game ended in a draw.',
),
),
type: 'banner',
}),
}));
Expand All @@ -544,11 +548,6 @@ async function processActionResponse(
).map(({ id }) => id),
]),
];
const winnerList = intlList(
winners.map(getTranslatedFactionName.bind(null, playerDetails)),
Conjunctions.AND,
Delimiters.COMMA,
);
const fireworks =
state.currentViewer && winners.includes(state.currentViewer) ? 5 : 3;
await update((currentState) => ({
Expand Down Expand Up @@ -581,7 +580,10 @@ async function processActionResponse(
sound: null,
text: String(
fbt(
fbt.param('winners', winnerList) +
fbt.list(
'winners',
winners.map(getTranslatedFactionName.bind(null, playerDetails)),
) +
' ' +
fbt.plural('wins', winners.length, {
many: 'win',
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/addIncreaseValueAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IncreaseFundsActionResponse,
} from '@deities/apollo/ActionResponse.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
import AnimationKey from '../lib/AnimationKey.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/maybeReceiveChaosStarsAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TileSize } from '@deities/athena/map/Configuration.tsx';
import Breakpoints from '@deities/ui/Breakpoints.tsx';
import Stack from '@deities/ui/Stack.tsx';
import { css } from '@emotion/css';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { motion } from 'framer-motion';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/objectiveAnimation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SecretDiscoveredActionResponse } from '@deities/apollo/ActionResponse.tsx';
import { OptionalObjectiveActionResponse } from '@deities/apollo/Objective.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
import AnimationKey from '../lib/AnimationKey.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/receiveBiomeAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SizeVector } from '@deities/athena/MapData.tsx';
import Breakpoints from '@deities/ui/Breakpoints.tsx';
import Stack from '@deities/ui/Stack.tsx';
import { css } from '@emotion/css';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { motion } from 'framer-motion';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/receiveCrystalAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TileSize } from '@deities/athena/map/Configuration.tsx';
import Breakpoints from '@deities/ui/Breakpoints.tsx';
import Stack from '@deities/ui/Stack.tsx';
import { css } from '@emotion/css';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { motion } from 'framer-motion';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/receivePortraitAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import pixelBorder from '@deities/ui/pixelBorder.tsx';
import Stack from '@deities/ui/Stack.tsx';
import { css } from '@emotion/css';
import arrayShuffle from 'array-shuffle';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { motion } from 'framer-motion';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/animations/receiveSkillSlotAnimation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReceiveRewardActionResponse } from '@deities/apollo/ActionResponse.tsx';
import applyActionResponse from '@deities/apollo/actions/applyActionResponse.tsx';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { resetBehavior } from '../behavior/Behavior.tsx';
import NullBehavior from '../behavior/NullBehavior.tsx';
import AnimationKey from '../lib/AnimationKey.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/behavior/BuySkills.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Icon from '@deities/ui/Icon.tsx';
import Info from '@deities/ui/icons/Info.tsx';
import { css } from '@emotion/css';
import More from '@iconify-icons/pixelarticons/more-horizontal.js';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { useState } from 'react';
import addFlashAnimation from '../lib/addFlashAnimation.tsx';
import getSkillConfigForDisplay from '../lib/getSkillConfigForDisplay.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/behavior/CreateUnit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import More from '@iconify-icons/pixelarticons/more-horizontal.js';
import Reply from '@iconify-icons/pixelarticons/reply.js';
import Shield from '@iconify-icons/pixelarticons/shield.js';
import Visible from '@iconify-icons/pixelarticons/visible.js';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { MouseEvent, useCallback, useState } from 'react';
import addFlashAnimation from '../lib/addFlashAnimation.tsx';
import toTransformOrigin, {
Expand Down
2 changes: 1 addition & 1 deletion hera/behavior/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CreateTracksCost } from '@deities/athena/map/Configuration.tsx';
import Vector, { sortByVectorKey } from '@deities/athena/map/Vector.tsx';
import { moveable } from '@deities/athena/Radius.tsx';
import useInput from '@deities/ui/controls/useInput.tsx';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import addFlashAnimation from '../lib/addFlashAnimation.tsx';
import animateSupply from '../lib/animateSupply.tsx';
import { RadiusType } from '../Radius.tsx';
Expand Down
2 changes: 1 addition & 1 deletion hera/behavior/Radar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { RadiusItem } from '@deities/athena/Radius.tsx';
import Icon from '@deities/ui/Icon.tsx';
import ZapOn from '@deities/ui/icons/ZapOn.tsx';
import Zap from '@iconify-icons/pixelarticons/zap.js';
import { fbt } from 'fbt';
import { fbt } from 'fbtee';
import { RadiusType } from '../Radius.tsx';
import { Actions, State, StateLike, StateWithActions } from '../Types.tsx';
import ActionWheel, {
Expand Down
Loading

0 comments on commit f9c8fdd

Please sign in to comment.