From ab37925b0533a5751b427e1f9498426bd845f7c1 Mon Sep 17 00:00:00 2001 From: Ricardo Costa <48949546+ripecosta@users.noreply.github.com> Date: Mon, 12 Aug 2024 23:15:01 +0100 Subject: [PATCH 1/2] chore: update babel-plugin-tester to v10 --- package-lock.json | 93 +- package.json | 2 +- test/__snapshots__/icu.macro.spec.js.snap | 1376 ++++++++++++++++++--- 3 files changed, 1289 insertions(+), 182 deletions(-) diff --git a/package-lock.json b/package-lock.json index dffbb6a9e..8d324261e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "all-contributors-cli": "^6.26.1", "babel-core": "^7.0.0-bridge.0", "babel-plugin-macros": "^3.1.0", - "babel-plugin-tester": "^7.0.4", + "babel-plugin-tester": "^10.1.0", "coveralls": "^3.1.1", "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", @@ -3509,8 +3509,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", "dev": true, - "optional": true, - "peer": true, "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -3524,8 +3522,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", "dev": true, - "optional": true, - "peer": true, "dependencies": { "@babel/types": "^7.0.0" } @@ -3535,8 +3531,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", "dev": true, - "optional": true, - "peer": true, "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -3547,12 +3541,20 @@ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", "dev": true, - "optional": true, - "peer": true, "dependencies": { "@babel/types": "^7.20.7" } }, + "node_modules/@types/babel-plugin-tester": { + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/@types/babel-plugin-tester/-/babel-plugin-tester-9.0.10.tgz", + "integrity": "sha512-X+n3nZb8qIZ3a07qt7B5ONfptAZJ6nWLgU5I4U+gm0dRgtcjL+73P2tUkQAJ/iIbRF72BlW/2of5J0qbjlmsBw==", + "dev": true, + "dependencies": { + "@types/babel__core": "*", + "@types/prettier": "^2.0.0" + } + }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -3652,6 +3654,12 @@ "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==", "dev": true }, + "node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dev": true + }, "node_modules/@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -4682,20 +4690,37 @@ } }, "node_modules/babel-plugin-tester": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-7.0.4.tgz", - "integrity": "sha512-ZKhOa0aaaPNQVOZjxJ4svy8lIKjHswzCNxv3WROmirlFz+5IM22hzNg+p4MGC/C3Tv3sX5JfYSKJIcUE9aPdsA==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-10.1.0.tgz", + "integrity": "sha512-4P2tNaM/Mtg6ytA9YAqmgONnMYqWvdbGDuwRTpIIC9yFZGQrEHoyvDPCx+X1QALAufVb5DKieOPGj5dffiEiNg==", "dev": true, "dependencies": { + "@types/babel-plugin-tester": "^9.0.0", "lodash.mergewith": "^4.6.2", + "prettier": "^2.0.1", "strip-indent": "^3.0.0" }, "engines": { - "node": ">=8", + "node": ">=10.13", "npm": ">=6" }, "peerDependencies": { - "@babel/core": "^7.7.2" + "@babel/core": "^7.11.6" + } + }, + "node_modules/babel-plugin-tester/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/balanced-match": { @@ -14499,8 +14524,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", "dev": true, - "optional": true, - "peer": true, "requires": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -14514,8 +14537,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", "dev": true, - "optional": true, - "peer": true, "requires": { "@babel/types": "^7.0.0" } @@ -14525,8 +14546,6 @@ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", "dev": true, - "optional": true, - "peer": true, "requires": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -14537,12 +14556,20 @@ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", "dev": true, - "optional": true, - "peer": true, "requires": { "@babel/types": "^7.20.7" } }, + "@types/babel-plugin-tester": { + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/@types/babel-plugin-tester/-/babel-plugin-tester-9.0.10.tgz", + "integrity": "sha512-X+n3nZb8qIZ3a07qt7B5ONfptAZJ6nWLgU5I4U+gm0dRgtcjL+73P2tUkQAJ/iIbRF72BlW/2of5J0qbjlmsBw==", + "dev": true, + "requires": { + "@types/babel__core": "*", + "@types/prettier": "^2.0.0" + } + }, "@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -14635,6 +14662,12 @@ "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==", "dev": true }, + "@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dev": true + }, "@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -15407,13 +15440,23 @@ } }, "babel-plugin-tester": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-7.0.4.tgz", - "integrity": "sha512-ZKhOa0aaaPNQVOZjxJ4svy8lIKjHswzCNxv3WROmirlFz+5IM22hzNg+p4MGC/C3Tv3sX5JfYSKJIcUE9aPdsA==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-10.1.0.tgz", + "integrity": "sha512-4P2tNaM/Mtg6ytA9YAqmgONnMYqWvdbGDuwRTpIIC9yFZGQrEHoyvDPCx+X1QALAufVb5DKieOPGj5dffiEiNg==", "dev": true, "requires": { + "@types/babel-plugin-tester": "^9.0.0", "lodash.mergewith": "^4.6.2", + "prettier": "^2.0.1", "strip-indent": "^3.0.0" + }, + "dependencies": { + "prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true + } } }, "balanced-match": { diff --git a/package.json b/package.json index fbd00f390..12f19f377 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "all-contributors-cli": "^6.26.1", "babel-core": "^7.0.0-bridge.0", "babel-plugin-macros": "^3.1.0", - "babel-plugin-tester": "^7.0.4", + "babel-plugin-tester": "^10.1.0", "coveralls": "^3.1.1", "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", diff --git a/test/__snapshots__/icu.macro.spec.js.snap b/test/__snapshots__/icu.macro.spec.js.snap index 424e6dfa9..8b37f89c2 100644 --- a/test/__snapshots__/icu.macro.spec.js.snap +++ b/test/__snapshots__/icu.macro.spec.js.snap @@ -8,10 +8,17 @@ const x = Welcome, { name }! ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -23,10 +30,17 @@ const x = Welcome, { name }! ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = {name}]} values={{ - name -}} />; +import { Trans } from 'react-i18next'; +const x = ( + {name}]} + values={{ + name, + }} + /> +); + " `; @@ -40,9 +54,16 @@ const x = Trainers: { trainersCount, number } ↓ ↓ ↓ ↓ ↓ ↓ import { useTranslation, Trans } from 'react-i18next'; -const x = ; +const x = ( + +); + " `; @@ -54,10 +75,17 @@ const x = Trainers: { trainersCount, number }! ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = {(trainersCount)}]} values={{ - trainersCount -}} />; +import { Trans } from 'react-i18next'; +const x = ( + {trainersCount}]} + values={{ + trainersCount, + }} + /> +); + " `; @@ -69,10 +97,17 @@ const x = Caught on { catchDate, date, short } ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -84,10 +119,17 @@ const x = Caught on { catchDate, date, short }! ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = {(catchDate)}]} values={{ - catchDate -}} />; +import { Trans } from 'react-i18next'; +const x = ( + {catchDate}]} + values={{ + catchDate, + }} + /> +); + " `; @@ -99,10 +141,17 @@ const x = ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -114,10 +163,18 @@ const x = {(trainersCount)}]} values={{ - trainersCount -}} />; +import { Trans } from 'react-i18next'; +const x = ( + {trainersCount}]} + values={{ + trainersCount, + }} + /> +); + " `; @@ -129,10 +186,18 @@ const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -144,10 +209,17 @@ const x = {(catchDate)}]} values={{ - catchDate -}} />; +import { Trans } from 'react-i18next'; +const x = ( + {catchDate}]} + values={{ + catchDate, + }} + /> +); + " `; @@ -160,14 +232,18 @@ const x = {children}; -const x = {(catchDate)}]} />; +import { Trans } from 'react-i18next'; +const Link = ({ to, children }) => {children}; +const x = ( + {catchDate}]} + /> +); + " `; @@ -179,10 +255,18 @@ const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -200,10 +284,18 @@ const x = He, She, They]} values={{ - gender -}} />; +import { Trans } from 'react-i18next'; +const x = ( + He, She, They]} + values={{ + gender, + }} + /> +); + " `; @@ -240,10 +339,17 @@ const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -261,10 +367,18 @@ const x = no, #, #]} values={{ - itemsCount3 -}} />; +import { Trans } from 'react-i18next'; +const x = ( + no, #, #]} + values={{ + itemsCount3, + }} + /> +); + " `; @@ -283,11 +397,26 @@ const x = no, {location}, #, {location}, #, {location}]} values={{ - itemsCount3, - location: 'table' -}} />; +import { Trans } from 'react-i18next'; +const x = ( + no, + {location}, + #, + {location}, + #, + {location}, + ]} + values={{ + itemsCount3, + location: 'table', + }} + /> +); + " `; @@ -308,10 +437,17 @@ const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; @@ -331,10 +467,24 @@ const x = #st in line, #nd in line, #rd in line, #th in line, #th in line]} values={{ - position -}} />; +import { Trans } from 'react-i18next'; +const x = ( + #st in line, + #nd in line, + #rd in line, + #th in line, + #th in line, + ]} + values={{ + position, + }} + /> +); + " `; @@ -451,66 +601,139 @@ export default function TestPage({count = 1}) { import React from 'react'; import { useTranslation, Trans } from 'react-i18next'; -const Link = ({ - to, - children -}) => {children}; -export default function TestPage({ - count = 1 -}) { +const Link = ({ to, children }) => {children}; +export default function TestPage({ count = 1 }) { const [t] = useTranslation(); const catchDate = Date.now(); const completion = 0.75; const gender = Math.random() < 0.5 ? 'female' : 'male'; - return <> - {t('sample.text', 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', { - word: 'interpolation', - gender, - count, - catchDate, - completion - })} - Your cart, empty, # item, your cart, # items, your cart]} values={{ - linkPath: "/item/" + count - }} /> - her items, his items, their items]} values={{ - gender - }} /> - #st item, #nd item, #rd item, #th item]} values={{ - linkPath: "/item/" + itemIndex - }} /> - {(completion)} of your tasks]} values={{ - completion - }} /> - {(catchDate)}]} values={{ - catchDate - }} /> - - #st {type} - , - #nd {type} - , - #rd {type} - , - #th {type} - ]} values={{ - linkPath: \`/item/\${count}\`, - type: 'item', - prop - }} /> - - He - , - She - , - They - ]} values={{ - selectKey: \`\${gender}Person\`, - linkPath: \`/users/\${number}\`, - type: 'bugs' - }} /> - ; + return ( + <> + {t( + 'sample.text', + 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', + { + word: 'interpolation', + gender, + count, + catchDate, + completion, + }, + )} + Your cart, + empty, + # item, + your cart, + # items, + your cart, + ]} + values={{ + linkPath: '/item/' + count, + }} + /> + her items, + his items, + their items, + ]} + values={{ + gender, + }} + /> + + #st item + , + + #nd item + , + + #rd item + , + + #th item + , + ]} + values={{ + linkPath: '/item/' + itemIndex, + }} + /> + {completion} of your tasks]} + values={{ + completion, + }} + /> + {catchDate}]} + values={{ + catchDate, + }} + /> + + #st {type} + , + + #nd {type} + , + + #rd {type} + , + + #th {type} + , + ]} + values={{ + linkPath: \`/item/\${count}\`, + type: 'item', + prop, + }} + /> + + He + , + + She + , + + They + , + ]} + values={{ + selectKey: \`\${gender}Person\`, + linkPath: \`/users/\${number}\`, + type: 'bugs', + }} + /> + + ); } + " `; @@ -542,28 +765,39 @@ const x = ( ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans, number, date, plural, select } from "react-i18next"; -import React from "react"; -function Component({ - children, - style -}) { +import { Trans, number, date, plural, select } from 'react-i18next'; +import React from 'react'; +function Component({ children, style }) { return
{children}
; } const count = 2; const numbers = 34; -const selectInput = "thing"; +const selectInput = 'thing'; const now = new Date(); -const x = exciting!, friend, - with regular text and a date:
{date\`\${now}\`}
-
]} values={{ - count, - numbers, - selectInput, - now -}} />; +const x = ( + exciting!, + friend, + + with regular text and a date:
{date\`\${now}\`}
+
, + ]} + values={{ + count, + numbers, + selectInput, + now, + }} + /> +); + " `; @@ -575,9 +809,839 @@ const x = Welcome, "{ name }"! ↓ ↓ ↓ ↓ ↓ ↓ -import { Trans } from "react-i18next"; -const x = ; +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 1. unknown plugin > 1. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = Welcome, { name }! + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 2. unknown plugin > 2. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = Welcome, { name }! + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + {name}]} + values={{ + name, + }} + /> +); + +" +`; + +exports[`unknown plugin > 3. unknown plugin > 3. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' +import { useTranslation } from 'react-i18next' + +const x = Trainers: { trainersCount, number } + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { useTranslation, Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 4. unknown plugin > 4. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = Trainers: { trainersCount, number }! + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + {trainersCount}]} + values={{ + trainersCount, + }} + /> +); + +" +`; + +exports[`unknown plugin > 5. unknown plugin > 5. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = Caught on { catchDate, date, short } + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 6. unknown plugin > 6. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = Caught on { catchDate, date, short }! + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + {catchDate}]} + values={{ + catchDate, + }} + /> +); + +" +`; + +exports[`unknown plugin > 7. unknown plugin > 7. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 8. unknown plugin > 8. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + {trainersCount}]} + values={{ + trainersCount, + }} + /> +); + +" +`; + +exports[`unknown plugin > 9. unknown plugin > 9. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 10. unknown plugin > 10. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + {catchDate}]} + values={{ + catchDate, + }} + /> +); + +" +`; + +exports[`unknown plugin > 11. unknown plugin > 11. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' +const Link = ({to, children}) => ({children}) + +const x = This should be overridden by defaults + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const Link = ({ to, children }) => {children}; +const x = ( + {catchDate}]} + /> +); + +" +`; + +exports[`unknown plugin > 12. unknown plugin > 12. unknown plugin 1`] = ` +" +import { Trans } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 13. unknown plugin > 13. unknown plugin 1`] = ` +" +import { Select } from '../icu.macro' + +const x = He avoids bugs.} + female={She avoids bugs.} + other={They avoid bugs.} +/> + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + He, She, They]} + values={{ + gender, + }} + /> +); + +" +`; + +exports[`unknown plugin > 15. unknown plugin > 15. unknown plugin 1`] = ` +" +import { Plural } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 16. unknown plugin > 16. unknown plugin 1`] = ` +" +import { Plural } from '../icu.macro' + +const x = There is no item.} + one={There is # item.} + other={There are # items.} +/> + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + no, #, #]} + values={{ + itemsCount3, + }} + /> +); + +" +`; + +exports[`unknown plugin > 17. unknown plugin > 17. unknown plugin 1`] = ` +" +import { Plural } from '../icu.macro' + +const x = There is no item on the {location}.} + one={There is # item on the {location}.} + other={There are # items on the {location}.} +/> + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + no, + {location}, + #, + {location}, + #, + {location}, + ]} + values={{ + itemsCount3, + location: 'table', + }} + /> +); + +" +`; + +exports[`unknown plugin > 18. unknown plugin > 18. unknown plugin 1`] = ` +" +import { SelectOrdinal } from '../icu.macro' + +const x = + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + +" +`; + +exports[`unknown plugin > 19. unknown plugin > 19. unknown plugin 1`] = ` +" +import { SelectOrdinal } from '../icu.macro' + +const x = You are #st in line} + two={You are #nd in line} + few={You are #rd in line} + other={You are #th in line} + $0={You are #th in line} +/> + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + #st in line, + #nd in line, + #rd in line, + #th in line, + #th in line, + ]} + values={{ + position, + }} + /> +); + +" +`; + +exports[`unknown plugin > 20. unknown plugin > 20. unknown plugin 1`] = ` +" +import React from 'react' +import { useTranslation } from 'react-i18next' +import { Plural, Select, SelectOrdinal, Trans } from '../icu.macro' +const Link = ({to, children}) => ({children}) + +export default function TestPage({count = 1}) { + const [t] = useTranslation() + const catchDate = Date.now() + const completion = 0.75 + const gender = Math.random() < 0.5 ? 'female' : 'male' + return ( + <> + {t('sample.text', 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', {word: 'interpolation', gender, count, catchDate, completion})} + Your cart is empty.} + one={You have # item in your cart.} + other={You have # items in your cart.} + /> + + + He + {' '} + avoids {type}. + + } + femalePerson={ + + + She + {' '} + avoids {type}. + + } + other={ + + + They + {' '} + avoid {type}. + + } + /> + + ) +} + + ↓ ↓ ↓ ↓ ↓ ↓ + +import React from 'react'; +import { useTranslation, Trans } from 'react-i18next'; +const Link = ({ to, children }) => {children}; +export default function TestPage({ count = 1 }) { + const [t] = useTranslation(); + const catchDate = Date.now(); + const completion = 0.75; + const gender = Math.random() < 0.5 ? 'female' : 'male'; + return ( + <> + {t( + 'sample.text', + 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', + { + word: 'interpolation', + gender, + count, + catchDate, + completion, + }, + )} + Your cart, + empty, + # item, + your cart, + # items, + your cart, + ]} + values={{ + linkPath: '/item/' + count, + }} + /> + her items, + his items, + their items, + ]} + values={{ + gender, + }} + /> + + #st item + , + + #nd item + , + + #rd item + , + + #th item + , + ]} + values={{ + linkPath: '/item/' + itemIndex, + }} + /> + {completion} of your tasks]} + values={{ + completion, + }} + /> + {catchDate}]} + values={{ + catchDate, + }} + /> + + #st {type} + , + + #nd {type} + , + + #rd {type} + , + + #th {type} + , + ]} + values={{ + linkPath: \`/item/\${count}\`, + type: 'item', + prop, + }} + /> + + He + , + + She + , + + They + , + ]} + values={{ + selectKey: \`\${gender}Person\`, + linkPath: \`/users/\${number}\`, + type: 'bugs', + }} + /> + + ); +} + +" +`; + +exports[`unknown plugin > 21. unknown plugin > 21. unknown plugin 1`] = ` +" +import React from "react" +import { Trans, number, date, time, plural, select, selectOrdinal } from "../icu.macro"; + +function Component({ children, style }) { + return
{children}
+} + +const count = 2; +const numbers = 34; +const selectInput = "thing" +const now = new Date() +const x = ( + + exciting! + {plural\`\${count}, + =0 { hi there \${friend} } + other { woweee even supports nested \${number\`\${numbers}\`} } \`} and + {select\`\${selectInput}, + thing { another nested \${ + with regular text and a date:
{date\`\${now}\`}
+
}} \`} +
+); + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans, number, date, plural, select } from 'react-i18next'; +import React from 'react'; +function Component({ children, style }) { + return
{children}
; +} +const count = 2; +const numbers = 34; +const selectInput = 'thing'; +const now = new Date(); +const x = ( + exciting!, + friend, + + with regular text and a date:
{date\`\${now}\`}
+
, + ]} + values={{ + count, + numbers, + selectInput, + now, + }} + /> +); + +" +`; + +exports[`unknown plugin > 22. unknown plugin > 22. unknown plugin 1`] = ` +" +import { Trans } from "../icu.macro"; + +const x = Welcome, "{ name }"! + + ↓ ↓ ↓ ↓ ↓ ↓ + +import { Trans } from 'react-i18next'; +const x = ( + +); + " `; From 6a6e3ab538eb1f8901850eee24c72118fea81d99 Mon Sep 17 00:00:00 2001 From: Ricardo Costa <48949546+ripecosta@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:30:29 +0100 Subject: [PATCH 2/2] chore: update babel-plugin-tester to v11 --- package-lock.json | 94 +-- package.json | 2 +- test/__snapshots__/icu.macro.spec.js.snap | 933 ++-------------------- test/icu.macro.spec.js | 90 +-- 4 files changed, 160 insertions(+), 959 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8d324261e..1cf3a4e56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "all-contributors-cli": "^6.26.1", "babel-core": "^7.0.0-bridge.0", "babel-plugin-macros": "^3.1.0", - "babel-plugin-tester": "^10.1.0", + "babel-plugin-tester": "^11.0.4", "coveralls": "^3.1.1", "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", @@ -3509,6 +3509,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -3522,6 +3524,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@babel/types": "^7.0.0" } @@ -3531,6 +3535,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -3541,20 +3547,12 @@ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@babel/types": "^7.20.7" } }, - "node_modules/@types/babel-plugin-tester": { - "version": "9.0.10", - "resolved": "https://registry.npmjs.org/@types/babel-plugin-tester/-/babel-plugin-tester-9.0.10.tgz", - "integrity": "sha512-X+n3nZb8qIZ3a07qt7B5ONfptAZJ6nWLgU5I4U+gm0dRgtcjL+73P2tUkQAJ/iIbRF72BlW/2of5J0qbjlmsBw==", - "dev": true, - "dependencies": { - "@types/babel__core": "*", - "@types/prettier": "^2.0.0" - } - }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -3654,12 +3652,6 @@ "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==", "dev": true }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true - }, "node_modules/@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -4690,22 +4682,33 @@ } }, "node_modules/babel-plugin-tester": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-10.1.0.tgz", - "integrity": "sha512-4P2tNaM/Mtg6ytA9YAqmgONnMYqWvdbGDuwRTpIIC9yFZGQrEHoyvDPCx+X1QALAufVb5DKieOPGj5dffiEiNg==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-11.0.4.tgz", + "integrity": "sha512-cqswtpSPo0e++rZB0l/54EG17LL25l9gLgh59yXfnmNxX+2lZTIOpx2zt4YI9QIClVXc8xf63J6yWwKkzy0jNg==", "dev": true, "dependencies": { - "@types/babel-plugin-tester": "^9.0.0", + "core-js": "^3.27.2", + "debug": "^4.3.4", "lodash.mergewith": "^4.6.2", - "prettier": "^2.0.1", + "prettier": "^2.8.3", "strip-indent": "^3.0.0" }, "engines": { - "node": ">=10.13", - "npm": ">=6" + "node": "^14.20.0 || ^16.16.0 || >=18.5.0" }, "peerDependencies": { - "@babel/core": "^7.11.6" + "@babel/core": ">=7.11.6" + } + }, + "node_modules/babel-plugin-tester/node_modules/core-js": { + "version": "3.38.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.0.tgz", + "integrity": "sha512-XPpwqEodRljce9KswjZShh95qJ1URisBeKCjUdq27YdenkslVe7OO0ZJhlYXAChW7OhXaRLl8AAba7IBfoIHug==", + "dev": true, + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" } }, "node_modules/babel-plugin-tester/node_modules/prettier": { @@ -14524,6 +14527,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", "dev": true, + "optional": true, + "peer": true, "requires": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -14537,6 +14542,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", "dev": true, + "optional": true, + "peer": true, "requires": { "@babel/types": "^7.0.0" } @@ -14546,6 +14553,8 @@ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", "dev": true, + "optional": true, + "peer": true, "requires": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -14556,20 +14565,12 @@ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", "dev": true, + "optional": true, + "peer": true, "requires": { "@babel/types": "^7.20.7" } }, - "@types/babel-plugin-tester": { - "version": "9.0.10", - "resolved": "https://registry.npmjs.org/@types/babel-plugin-tester/-/babel-plugin-tester-9.0.10.tgz", - "integrity": "sha512-X+n3nZb8qIZ3a07qt7B5ONfptAZJ6nWLgU5I4U+gm0dRgtcjL+73P2tUkQAJ/iIbRF72BlW/2of5J0qbjlmsBw==", - "dev": true, - "requires": { - "@types/babel__core": "*", - "@types/prettier": "^2.0.0" - } - }, "@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -14662,12 +14663,6 @@ "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==", "dev": true }, - "@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true - }, "@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -15440,17 +15435,24 @@ } }, "babel-plugin-tester": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-10.1.0.tgz", - "integrity": "sha512-4P2tNaM/Mtg6ytA9YAqmgONnMYqWvdbGDuwRTpIIC9yFZGQrEHoyvDPCx+X1QALAufVb5DKieOPGj5dffiEiNg==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/babel-plugin-tester/-/babel-plugin-tester-11.0.4.tgz", + "integrity": "sha512-cqswtpSPo0e++rZB0l/54EG17LL25l9gLgh59yXfnmNxX+2lZTIOpx2zt4YI9QIClVXc8xf63J6yWwKkzy0jNg==", "dev": true, "requires": { - "@types/babel-plugin-tester": "^9.0.0", + "core-js": "^3.27.2", + "debug": "^4.3.4", "lodash.mergewith": "^4.6.2", - "prettier": "^2.0.1", + "prettier": "^2.8.3", "strip-indent": "^3.0.0" }, "dependencies": { + "core-js": { + "version": "3.38.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.0.tgz", + "integrity": "sha512-XPpwqEodRljce9KswjZShh95qJ1URisBeKCjUdq27YdenkslVe7OO0ZJhlYXAChW7OhXaRLl8AAba7IBfoIHug==", + "dev": true + }, "prettier": { "version": "2.8.8", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", diff --git a/package.json b/package.json index 12f19f377..4adfddd71 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "all-contributors-cli": "^6.26.1", "babel-core": "^7.0.0-bridge.0", "babel-plugin-macros": "^3.1.0", - "babel-plugin-tester": "^10.1.0", + "babel-plugin-tester": "^11.0.4", "coveralls": "^3.1.1", "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", diff --git a/test/__snapshots__/icu.macro.spec.js.snap b/test/__snapshots__/icu.macro.spec.js.snap index 8b37f89c2..5f6794d58 100644 --- a/test/__snapshots__/icu.macro.spec.js.snap +++ b/test/__snapshots__/icu.macro.spec.js.snap @@ -2,9 +2,11 @@ exports[`macros > 1. macros > 1. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = Welcome, { name }! + ↓ ↓ ↓ ↓ ↓ ↓ @@ -18,15 +20,16 @@ const x = ( }} /> ); - " `; exports[`macros > 2. macros > 2. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = Welcome, { name }! + ↓ ↓ ↓ ↓ ↓ ↓ @@ -40,16 +43,17 @@ const x = ( }} /> ); - " `; exports[`macros > 3. macros > 3. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' import { useTranslation } from 'react-i18next' const x = Trainers: { trainersCount, number } + ↓ ↓ ↓ ↓ ↓ ↓ @@ -63,15 +67,16 @@ const x = ( }} /> ); - " `; exports[`macros > 4. macros > 4. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = Trainers: { trainersCount, number }! + ↓ ↓ ↓ ↓ ↓ ↓ @@ -85,15 +90,16 @@ const x = ( }} /> ); - " `; exports[`macros > 5. macros > 5. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = Caught on { catchDate, date, short } + ↓ ↓ ↓ ↓ ↓ ↓ @@ -107,15 +113,16 @@ const x = ( }} /> ); - " `; exports[`macros > 6. macros > 6. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = Caught on { catchDate, date, short }! + ↓ ↓ ↓ ↓ ↓ ↓ @@ -129,15 +136,16 @@ const x = ( }} /> ); - " `; exports[`macros > 7. macros > 7. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -151,15 +159,16 @@ const x = ( }} /> ); - " `; exports[`macros > 8. macros > 8. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -174,15 +183,16 @@ const x = ( }} /> ); - " `; exports[`macros > 9. macros > 9. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -197,15 +207,16 @@ const x = ( }} /> ); - " `; exports[`macros > 10. macros > 10. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -219,16 +230,17 @@ const x = ( }} /> ); - " `; exports[`macros > 11. macros > 11. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const Link = ({to, children}) => ({children}) const x = This should be overridden by defaults + ↓ ↓ ↓ ↓ ↓ ↓ @@ -243,15 +255,16 @@ const x = ( components={[{catchDate}]} /> ); - " `; exports[`macros > 12. macros > 12. macros 1`] = ` " -import { Trans } from '../icu.macro' + +import { Trans } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -266,13 +279,13 @@ const x = ( components={[]} /> ); - " `; exports[`macros > 13. macros > 13. macros 1`] = ` " -import { Select } from '../icu.macro' + +import { Select } from '../../../icu.macro' const x = She avoids bugs.} other={They avoid bugs.} /> + ↓ ↓ ↓ ↓ ↓ ↓ @@ -322,13 +337,13 @@ const x = ( }} /> ); - " `; exports[`macros > 15. macros > 15. macros 1`] = ` " -import { Plural } from '../icu.macro' + +import { Plural } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -349,13 +365,13 @@ const x = ( }} /> ); - " `; exports[`macros > 16. macros > 16. macros 1`] = ` " -import { Plural } from '../icu.macro' + +import { Plural } from '../../../icu.macro' const x = There is # item.} other={There are # items.} /> + ↓ ↓ ↓ ↓ ↓ ↓ @@ -378,13 +395,13 @@ const x = ( }} /> ); - " `; exports[`macros > 17. macros > 17. macros 1`] = ` " -import { Plural } from '../icu.macro' + +import { Plural } from '../../../icu.macro' const x = There is # item on the {location}.} other={There are # items on the {location}.} /> + ↓ ↓ ↓ ↓ ↓ ↓ @@ -416,13 +434,13 @@ const x = ( }} /> ); - " `; exports[`macros > 18. macros > 18. macros 1`] = ` " -import { SelectOrdinal } from '../icu.macro' + +import { SelectOrdinal } from '../../../icu.macro' const x = + ↓ ↓ ↓ ↓ ↓ ↓ @@ -447,13 +466,13 @@ const x = ( }} /> ); - " `; exports[`macros > 19. macros > 19. macros 1`] = ` " -import { SelectOrdinal } from '../icu.macro' + +import { SelectOrdinal } from '../../../icu.macro' const x = You are #th in line} $0={You are #th in line} /> + ↓ ↓ ↓ ↓ ↓ ↓ @@ -484,15 +504,15 @@ const x = ( }} /> ); - " `; exports[`macros > 20. macros > 20. macros 1`] = ` " + import React from 'react' import { useTranslation } from 'react-i18next' -import { Plural, Select, SelectOrdinal, Trans } from '../icu.macro' +import { Plural, Select, SelectOrdinal, Trans } from '../../../icu.macro' const Link = ({to, children}) => ({children}) export default function TestPage({count = 1}) { @@ -596,6 +616,7 @@ export default function TestPage({count = 1}) { ) } + ↓ ↓ ↓ ↓ ↓ ↓ @@ -733,14 +754,14 @@ export default function TestPage({ count = 1 }) { ); } - " `; exports[`macros > 21. macros > 21. macros 1`] = ` " + import React from "react" -import { Trans, number, date, time, plural, select, selectOrdinal } from "../icu.macro"; +import { Trans, number, date, time, plural, select, selectOrdinal } from "../../../icu.macro"; function Component({ children, style }) { return
{children}
@@ -762,6 +783,7 @@ const x = ( }} \`}
); + ↓ ↓ ↓ ↓ ↓ ↓ @@ -797,15 +819,16 @@ const x = ( }} /> ); - " `; exports[`macros > 22. macros > 22. macros 1`] = ` " -import { Trans } from "../icu.macro"; + +import { Trans } from "../../../icu.macro"; const x = Welcome, "{ name }"! + ↓ ↓ ↓ ↓ ↓ ↓ @@ -819,829 +842,5 @@ const x = ( }} /> ); - -" -`; - -exports[`unknown plugin > 1. unknown plugin > 1. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = Welcome, { name }! - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 2. unknown plugin > 2. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = Welcome, { name }! - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - {name}]} - values={{ - name, - }} - /> -); - -" -`; - -exports[`unknown plugin > 3. unknown plugin > 3. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' -import { useTranslation } from 'react-i18next' - -const x = Trainers: { trainersCount, number } - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { useTranslation, Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 4. unknown plugin > 4. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = Trainers: { trainersCount, number }! - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - {trainersCount}]} - values={{ - trainersCount, - }} - /> -); - -" -`; - -exports[`unknown plugin > 5. unknown plugin > 5. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = Caught on { catchDate, date, short } - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 6. unknown plugin > 6. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = Caught on { catchDate, date, short }! - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - {catchDate}]} - values={{ - catchDate, - }} - /> -); - -" -`; - -exports[`unknown plugin > 7. unknown plugin > 7. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 8. unknown plugin > 8. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - {trainersCount}]} - values={{ - trainersCount, - }} - /> -); - -" -`; - -exports[`unknown plugin > 9. unknown plugin > 9. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 10. unknown plugin > 10. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - {catchDate}]} - values={{ - catchDate, - }} - /> -); - -" -`; - -exports[`unknown plugin > 11. unknown plugin > 11. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' -const Link = ({to, children}) => ({children}) - -const x = This should be overridden by defaults - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const Link = ({ to, children }) => {children}; -const x = ( - {catchDate}]} - /> -); - -" -`; - -exports[`unknown plugin > 12. unknown plugin > 12. unknown plugin 1`] = ` -" -import { Trans } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 13. unknown plugin > 13. unknown plugin 1`] = ` -" -import { Select } from '../icu.macro' - -const x = He avoids bugs.} - female={She avoids bugs.} - other={They avoid bugs.} -/> - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - He, She, They]} - values={{ - gender, - }} - /> -); - -" -`; - -exports[`unknown plugin > 15. unknown plugin > 15. unknown plugin 1`] = ` -" -import { Plural } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 16. unknown plugin > 16. unknown plugin 1`] = ` -" -import { Plural } from '../icu.macro' - -const x = There is no item.} - one={There is # item.} - other={There are # items.} -/> - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - no, #, #]} - values={{ - itemsCount3, - }} - /> -); - -" -`; - -exports[`unknown plugin > 17. unknown plugin > 17. unknown plugin 1`] = ` -" -import { Plural } from '../icu.macro' - -const x = There is no item on the {location}.} - one={There is # item on the {location}.} - other={There are # items on the {location}.} -/> - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - no, - {location}, - #, - {location}, - #, - {location}, - ]} - values={{ - itemsCount3, - location: 'table', - }} - /> -); - -" -`; - -exports[`unknown plugin > 18. unknown plugin > 18. unknown plugin 1`] = ` -" -import { SelectOrdinal } from '../icu.macro' - -const x = - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - -" -`; - -exports[`unknown plugin > 19. unknown plugin > 19. unknown plugin 1`] = ` -" -import { SelectOrdinal } from '../icu.macro' - -const x = You are #st in line} - two={You are #nd in line} - few={You are #rd in line} - other={You are #th in line} - $0={You are #th in line} -/> - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - #st in line, - #nd in line, - #rd in line, - #th in line, - #th in line, - ]} - values={{ - position, - }} - /> -); - -" -`; - -exports[`unknown plugin > 20. unknown plugin > 20. unknown plugin 1`] = ` -" -import React from 'react' -import { useTranslation } from 'react-i18next' -import { Plural, Select, SelectOrdinal, Trans } from '../icu.macro' -const Link = ({to, children}) => ({children}) - -export default function TestPage({count = 1}) { - const [t] = useTranslation() - const catchDate = Date.now() - const completion = 0.75 - const gender = Math.random() < 0.5 ? 'female' : 'male' - return ( - <> - {t('sample.text', 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', {word: 'interpolation', gender, count, catchDate, completion})} - Your cart is empty.} - one={You have # item in your cart.} - other={You have # items in your cart.} - /> - - - He - {' '} - avoids {type}. - - } - femalePerson={ - - - She - {' '} - avoids {type}. - - } - other={ - - - They - {' '} - avoid {type}. - - } - /> - - ) -} - - ↓ ↓ ↓ ↓ ↓ ↓ - -import React from 'react'; -import { useTranslation, Trans } from 'react-i18next'; -const Link = ({ to, children }) => {children}; -export default function TestPage({ count = 1 }) { - const [t] = useTranslation(); - const catchDate = Date.now(); - const completion = 0.75; - const gender = Math.random() < 0.5 ? 'female' : 'male'; - return ( - <> - {t( - 'sample.text', - 'Some sample text with {word} {gender} {count, number} {catchDate, date} {completion, number, percent}', - { - word: 'interpolation', - gender, - count, - catchDate, - completion, - }, - )} - Your cart, - empty, - # item, - your cart, - # items, - your cart, - ]} - values={{ - linkPath: '/item/' + count, - }} - /> - her items, - his items, - their items, - ]} - values={{ - gender, - }} - /> - - #st item - , - - #nd item - , - - #rd item - , - - #th item - , - ]} - values={{ - linkPath: '/item/' + itemIndex, - }} - /> - {completion} of your tasks]} - values={{ - completion, - }} - /> - {catchDate}]} - values={{ - catchDate, - }} - /> - - #st {type} - , - - #nd {type} - , - - #rd {type} - , - - #th {type} - , - ]} - values={{ - linkPath: \`/item/\${count}\`, - type: 'item', - prop, - }} - /> - - He - , - - She - , - - They - , - ]} - values={{ - selectKey: \`\${gender}Person\`, - linkPath: \`/users/\${number}\`, - type: 'bugs', - }} - /> - - ); -} - -" -`; - -exports[`unknown plugin > 21. unknown plugin > 21. unknown plugin 1`] = ` -" -import React from "react" -import { Trans, number, date, time, plural, select, selectOrdinal } from "../icu.macro"; - -function Component({ children, style }) { - return
{children}
-} - -const count = 2; -const numbers = 34; -const selectInput = "thing" -const now = new Date() -const x = ( - - exciting! - {plural\`\${count}, - =0 { hi there \${friend} } - other { woweee even supports nested \${number\`\${numbers}\`} } \`} and - {select\`\${selectInput}, - thing { another nested \${ - with regular text and a date:
{date\`\${now}\`}
-
}} \`} -
-); - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans, number, date, plural, select } from 'react-i18next'; -import React from 'react'; -function Component({ children, style }) { - return
{children}
; -} -const count = 2; -const numbers = 34; -const selectInput = 'thing'; -const now = new Date(); -const x = ( - exciting!, - friend, - - with regular text and a date:
{date\`\${now}\`}
-
, - ]} - values={{ - count, - numbers, - selectInput, - now, - }} - /> -); - -" -`; - -exports[`unknown plugin > 22. unknown plugin > 22. unknown plugin 1`] = ` -" -import { Trans } from "../icu.macro"; - -const x = Welcome, "{ name }"! - - ↓ ↓ ↓ ↓ ↓ ↓ - -import { Trans } from 'react-i18next'; -const x = ( - -); - " `; diff --git a/test/icu.macro.spec.js b/test/icu.macro.spec.js index b7082e9c7..4d1afb79a 100644 --- a/test/icu.macro.spec.js +++ b/test/icu.macro.spec.js @@ -19,81 +19,81 @@ pluginTester({ babelOptions: { filename: __filename, parserOpts: { plugins: ['jsx'] } }, tests: [ ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = Welcome, { name }! `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = Welcome, { name }! `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' import { useTranslation } from 'react-i18next' const x = Trainers: { trainersCount, number } `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = Trainers: { trainersCount, number }! `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = Caught on { catchDate, date, short } `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = Caught on { catchDate, date, short }! `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const x = `, ` - import { Trans } from '../icu.macro' + import { Trans } from '../../../icu.macro' const Link = ({to, children}) => ({children}) - + const x = This should be overridden by defaults `, ` - import { Trans } from '../icu.macro' - + import { Trans } from '../../../icu.macro' + const x = `, ` - import { Select } from '../icu.macro' + import { Select } from '../../../icu.macro' const x =