diff --git a/package-lock.json b/package-lock.json index e02d393e..bb62cc43 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", @@ -3498,6 +3498,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", @@ -3511,6 +3513,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" } @@ -3520,6 +3524,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" @@ -3530,20 +3536,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", @@ -3643,12 +3641,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", @@ -4655,22 +4647,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": { @@ -14483,6 +14486,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", @@ -14496,6 +14501,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" } @@ -14505,6 +14512,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" @@ -14515,20 +14524,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", @@ -14621,12 +14622,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", @@ -15373,17 +15368,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 065bfae6..689a510c 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 8b37f89c..5f6794d5 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 b7082e9c..4d1afb79 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 =