diff --git a/.all-contributorsrc b/.all-contributorsrc index 47389641..fb862695 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -98,6 +98,15 @@ "contributions": [ "code" ] + }, + { + "login": "chitoku-k", + "name": "Chitoku", + "avatar_url": "https://avatars1.githubusercontent.com/u/6535425?v=4", + "profile": "https://chitoku.jp/", + "contributions": [ + "code" + ] } ], "repoType": "github" diff --git a/.eslintrc b/.eslintrc index 4a391f8c..3764fbd2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,3 +1,13 @@ { - "extends": "precure/oss" + "extends": "precure/oss", + "overrides": [ + { + "files": ["src/*.ts"], + "parser": "typescript-eslint-parser", + "plugins": ["typescript"], + "rules": { + "no-unused-vars": "off" + } + } + ] } diff --git a/package.json b/package.json index 6879beab..d5d90740 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "babel-plugin-react-intl-auto", "version": "1.4.0", "main": "lib/index.js", + "types": "lib/types.d.ts", "description": "i18n for the component age. Auto management react-intl ID", "license": "MIT", "repository": "akameco/babel-plugin-react-intl-auto", @@ -14,10 +15,10 @@ "add-contributor": "all-contributors add", "precommit": "yarn flow && lint-staged", "build": "babel src -d lib --ignore __tests__,__fixtures__", - "prepack": "yarn build", + "prepack": "yarn build && cp src/*.d.ts lib", "flow": "flow", - "fmt": "prettier --write '**/*.{js,json,md}'", - "lint": "eslint src", + "fmt": "prettier --write '**/*.{js,json,ts,md}'", + "lint": "eslint src --ext js,ts", "add:coveralls": "cat ./coverage/lcov.info | coveralls", "test": "jest", "test:watch": "jest --watch", @@ -25,7 +26,7 @@ "test:ci": "yarn flow && yarn lint && yarn test:coverage" }, "lint-staged": { - "*.js": [ + "*.{js,ts}": [ "prettier --write", "eslint", "git add" @@ -56,6 +57,7 @@ "murmurhash3js": "^3.0.1" }, "devDependencies": { + "@types/react-intl": "^2.3.15", "all-contributors-cli": "^5.4.0", "babel-cli": "^6.26.0", "babel-core": "^6.26.3", @@ -69,10 +71,14 @@ "coveralls": "^3.0.2", "eslint": "^4.19.1", "eslint-config-precure": "^2.7.0", + "eslint-plugin-typescript": "^0.14.0", "flow-bin": "^0.79.1", "husky": "^0.14.3", "jest": "^23.5.0", "lint-staged": "^7.2.2", - "prettier": "^1.14.2" + "prettier": "^1.14.2", + "react-intl": "^2.7.2", + "typescript": "~3.1.1", + "typescript-eslint-parser": "^21.0.2" } } diff --git a/readme.md b/readme.md index 0f01708d..5c171f46 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,7 @@ [![Coverage Status](https://coveralls.io/repos/github/akameco/babel-plugin-react-intl-auto/badge.svg?branch=master)](https://coveralls.io/github/akameco/babel-plugin-react-intl-auto?branch=master) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) -[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors) > i18n for the component age. Auto management react-intl ID. @@ -271,8 +271,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
akameco](http://akameco.github.io)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=akameco "Code") [⚠️](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=akameco "Tests") [👀](#review-akameco "Reviewed Pull Requests") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=akameco "Documentation") | [
Aleksander Heintz](http://alxandr.me)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=Alxandr "Code") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=Alxandr "Documentation") | [
Ryan Leckey](https://github.com/mehcode)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=mehcode "Code") | [
Adam](https://github.com/adam-26)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=adam-26 "Code") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=adam-26 "Documentation") | [
Guylian Cox](https://ephys.github.io)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=Ephys "Code") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=Ephys "Documentation") [⚠️](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=Ephys "Tests") | [
Carl Grundberg](http://carlgrundberg.github.io/)
[💡](#example-carlgrundberg "Examples") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=carlgrundberg "Documentation") | [
bradbarrow](http://bradbarrow.com)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=bradbarrow "Code") [📖](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=bradbarrow "Documentation") [⚠️](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=bradbarrow "Tests") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Mauro Gabriel Titimoli](https://github.com/mgtitimoli)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=mgtitimoli "Code") [⚠️](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=mgtitimoli "Tests") | [
Stanislav Ermakov](https://github.com/stanislav-ermakov)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=stanislav-ermakov "Code") | - +| [
Mauro Gabriel Titimoli](https://github.com/mgtitimoli)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=mgtitimoli "Code") [⚠️](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=mgtitimoli "Tests") | [
Stanislav Ermakov](https://github.com/stanislav-ermakov)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=stanislav-ermakov "Code") | [
Chitoku](https://chitoku.jp/)
[💻](https://github.com/akameco/babel-plugin-react-intl-auto/commits?author=chitoku-k "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 00000000..73795478 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,11 @@ +import { FormattedMessage } from 'react-intl' + +declare module 'react-intl' { + interface ExtractableMessage { + [key: string]: string + } + + export function defineMessages( + messages: T + ): { [K in keyof T]: FormattedMessage.MessageDescriptor } +} diff --git a/yarn.lock b/yarn.lock index d4f91edc..9645a0b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -187,6 +187,11 @@ dependencies: any-observable "^0.3.0" +"@types/react-intl@^2.3.15": + version "2.3.15" + resolved "https://registry.yarnpkg.com/@types/react-intl/-/react-intl-2.3.15.tgz#4768425b6a9bd680c1076761244b2b96a337dfa7" + integrity sha512-a2D0gSDdj9lJjEZ/tGP+lS489uaJSuBxzlW1A/1JqVnadbB+/5ZbFK3QkWaesR/ROcSsLTJxAfPorhT4jn6CUA== + abab@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.0.tgz#aba0ab4c5eee2d4c79d3487d85450fb2376ebb0f" @@ -1996,6 +2001,13 @@ eslint-plugin-react@^7.7.0: jsx-ast-utils "^2.0.1" prop-types "^15.6.0" +eslint-plugin-typescript@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-typescript/-/eslint-plugin-typescript-0.14.0.tgz#068549c3f4c7f3f85d88d398c29fa96bf500884c" + integrity sha512-2u1WnnDF2mkWWgU1lFQ2RjypUlmRoBEvQN02y9u+IL12mjWlkKFGEBnVsjs9Y8190bfPQCvWly1c2rYYUSOxWw== + dependencies: + requireindex "~1.1.0" + eslint-plugin-unicorn@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-4.0.3.tgz#7e9998711bf237809ed1881a51a77000b2f40586" @@ -2018,6 +2030,14 @@ eslint-scope@3.7.1, eslint-scope@^3.7.1, eslint-scope@~3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" +eslint-scope@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" + integrity sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA== + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + eslint-visitor-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" @@ -2729,6 +2749,11 @@ hoek@2.x.x: resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" integrity sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0= +hoist-non-react-statics@^2.5.5: + version "2.5.5" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" + integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw== + home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -2889,20 +2914,44 @@ inquirer@^4.0.0: strip-ansi "^4.0.0" through "^2.3.6" -invariant@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" - integrity sha1-nh9WrArNtr8wMwbzOL47IErmA2A= +intl-format-cache@^2.0.5: + version "2.1.0" + resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-2.1.0.tgz#04a369fecbfad6da6005bae1f14333332dcf9316" + integrity sha1-BKNp/sv61tpgBbrh8UMzMy3PkxY= + +intl-messageformat-parser@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-1.4.0.tgz#b43d45a97468cadbe44331d74bb1e8dea44fc075" + integrity sha1-tD1FqXRoytvkQzHXS7Ho3qRPwHU= + +intl-messageformat@^2.0.0, intl-messageformat@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-2.2.0.tgz#345bcd46de630b7683330c2e52177ff5eab484fc" + integrity sha1-NFvNRt5jC3aDMwwuUhd/9eq0hPw= dependencies: - loose-envify "^1.0.0" + intl-messageformat-parser "1.4.0" -invariant@^2.2.2, invariant@^2.2.4: +intl-relativeformat@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/intl-relativeformat/-/intl-relativeformat-2.1.0.tgz#010f1105802251f40ac47d0e3e1a201348a255df" + integrity sha1-AQ8RBYAiUfQKxH0OPhogE0iiVd8= + dependencies: + intl-messageformat "^2.0.0" + +invariant@^2.1.1, invariant@^2.2.2, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== dependencies: loose-envify "^1.0.0" +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + integrity sha1-nh9WrArNtr8wMwbzOL47IErmA2A= + dependencies: + loose-envify "^1.0.0" + invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -3952,6 +4001,11 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= +lodash.unescape@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" + integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= + lodash.upperfirst@^4.2.0: version "4.3.1" resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce" @@ -4836,6 +4890,17 @@ rc@^1.1.7, rc@^1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-intl@^2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-2.7.2.tgz#efe97e3fc0e99b4e88a6e6150854d3d1852a4381" + integrity sha512-3dcNGLqEw2FKkX+1L2WYLgjP0MVJkvWuVd1uLcnwifIQe8JQvnd9Bss4hb4Gvg/YhBIRcs4LM6C2bAgyklucjw== + dependencies: + hoist-non-react-statics "^2.5.5" + intl-format-cache "^2.0.5" + intl-messageformat "^2.1.0" + intl-relativeformat "^2.1.0" + invariant "^2.1.1" + read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -5088,6 +5153,11 @@ require-uncached@^1.0.3: caller-path "^0.1.0" resolve-from "^1.0.0" +requireindex@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162" + integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI= + resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" @@ -5235,6 +5305,11 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== +semver@5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== + set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -5793,6 +5868,28 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typescript-eslint-parser@^21.0.2: + version "21.0.2" + resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-21.0.2.tgz#270af10e4724528677fbcf34ea495284bec3a894" + integrity sha512-u+pj4RVJBr4eTzj0n5npoXD/oRthvfUCjSKndhNI714MG0mQq2DJw5WP7qmonRNIFgmZuvdDOH3BHm9iOjIAfg== + dependencies: + eslint-scope "^4.0.0" + eslint-visitor-keys "^1.0.0" + typescript-estree "5.3.0" + +typescript-estree@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/typescript-estree/-/typescript-estree-5.3.0.tgz#fb6c977b5e21073eb16cbdc0338a7f752da99ff5" + integrity sha512-Vu0KmYdSCkpae+J48wsFC1ti19Hq3Wi/lODUaE+uesc3gzqhWbZ5itWbsjylLVbjNW4K41RqDzSfnaYNbmEiMQ== + dependencies: + lodash.unescape "4.0.1" + semver "5.5.0" + +typescript@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.1.tgz#3362ba9dd1e482ebb2355b02dfe8bcd19a2c7c96" + integrity sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ== + ua-parser-js@^0.7.9: version "0.7.14" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca"