From 3e01c006fbb3c8bf871b14eb2a85bab390912bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 23 Mar 2020 20:53:06 +0100 Subject: [PATCH 1/5] Update dependencies BREAKING CHANGE: Requires Node 10+ --- .all-contributorsrc | 12 ++--- .gitattributes | 3 +- .gitignore | 6 ++- .huskyrc.js | 1 + .npmrc | 2 +- .prettierignore | 7 ++- .prettierrc.js | 1 + .travis.yml | 34 +++++++-------- CONTRIBUTING.md | 58 +++++++----------------- README.md | 104 ++++++++++++++++++++++++++++---------------- package.json | 38 ++++++++-------- 11 files changed, 134 insertions(+), 132 deletions(-) create mode 100644 .huskyrc.js create mode 100644 .prettierrc.js diff --git a/.all-contributorsrc b/.all-contributorsrc index ca19176..d52f9ac 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,12 +1,15 @@ { "projectName": "babel-plugin-macros", "projectOwner": "kentcdodds", + "imageSize": 100, + "commit": false, + "contributorsPerLine": 7, + "repoHost": "https://github.com", "repoType": "github", + "skipCi": false, "files": [ "README.md" ], - "imageSize": 100, - "commit": false, "contributors": [ { "login": "kentcdodds", @@ -235,8 +238,5 @@ "doc" ] } - ], - "contributorsPerLine": 7, - "repoHost": "https://github.com", - "skipCi": true + ] } diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 416a4a9..8e0c70c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ node_modules coverage dist -.opt-in -.opt-out +.DS_Store + +# these cause more harm than good +# when working with contributors package-lock.json yarn.lock diff --git a/.huskyrc.js b/.huskyrc.js new file mode 100644 index 0000000..5e45c45 --- /dev/null +++ b/.huskyrc.js @@ -0,0 +1 @@ +module.exports = require('kcd-scripts/husky') diff --git a/.npmrc b/.npmrc index a57cc9e..1e23fdf 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -registry=http://registry.npmjs.org/ +registry=http://registry.npmjs.org diff --git a/.prettierignore b/.prettierignore index ffbb8a3..9c62828 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ -node_modules/ -coverage/ -dist/ -package.json +node_modules +coverage +dist diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..4679d9b --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require('kcd-scripts/prettier') diff --git a/.travis.yml b/.travis.yml index e82954d..30fa818 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,22 @@ -sudo: false language: node_js cache: npm notifications: email: false -node_js: '10' +node_js: + - 10.0.0 + - 12 + - node +install: npm install +script: + - npm run validate + - npx codecov@3 +branches: + only: + - master + - beta + jobs: include: - - stage: test - name: test on windows - os: windows - install: npm install - script: npm run validate - # Travis does not support secrets on Windows yet so we test only external PRs where the secrets are not exposed - # https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264 - if: type = pull_request AND head_repo != repo - - stage: test and publish - name: test on linux and publish - os: linux - install: npm install - script: npm run validate - after_success: kcd-scripts travis-after-success -branches: - only: master + - stage: release + node_js: 12 + script: kcd-scripts travis-release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3aa097a..bcf79a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,63 +2,36 @@ Thanks for being willing to contribute! -**Working on your first Pull Request?** You can learn how from this _free_ series -[How to Contribute to an Open Source Project on GitHub][egghead] +**Working on your first Pull Request?** You can learn how from this _free_ +series [How to Contribute to an Open Source Project on GitHub][egghead] ## Project setup 1. Fork and clone the repo -2. Run `npm run setup -s` to install dependencies and run validation -3. Create a branch for your PR with `git checkout -b pr/your-branch-name` +2. `$ npm install` to install dependencies +3. `$ npm run validate` to validate you've got it working +4. Create a branch for your PR > Tip: Keep your `master` branch pointing at the original repository and make > pull requests from branches on your fork. To do this, run: > > ``` -> git remote add upstream https://github.com/kentcdodds/babel-plugin-macros.git +> git remote add upstream https://github.com/kentcdodds/babel-plugin-macros > git fetch upstream > git branch --set-upstream-to=upstream/master master > ``` > -> This will add the original repository as a "remote" called "upstream," -> Then fetch the git information from that remote, then set your local `master` -> branch to use the upstream master branch whenever you run `git pull`. -> Then you can make all of your pull request branches based on this `master` -> branch. Whenever you want to update your version of `master`, do a regular -> `git pull`. - -## Add yourself as a contributor - -This project follows the [all contributors][all-contributors] specification. -To add yourself to the table of contributors on the `README.md`, please use the -automated script as part of your PR: - -```console -npm run add-contributor -``` - -Follow the prompt and commit `.all-contributorsrc` and `README.md` in the PR. -If you've already added yourself to the list and are making -a new type of contribution, you can run it again and select the added -contribution type. +> This will add the original repository as a "remote" called "upstream," Then +> fetch the git information from that remote, then set your local `master` +> branch to use the upstream master branch whenever you run `git pull`. Then you +> can make all of your pull request branches based on this `master` branch. +> Whenever you want to update your version of `master`, do a regular `git pull`. ## Committing and Pushing changes Please make sure to run the tests before you commit your changes. You can run -`npm run test:update` which will update any snapshots that need updating. -Make sure to include those changes (if they exist) in your commit. - -### opt into git hooks - -There are git hooks set up with this project that are automatically installed -when you install dependencies. They're really handy, but are turned off by -default (so as to not hinder new contributors). You can opt into these by -creating a file called `.opt-in` at the root of the project and putting this -inside: - -``` -pre-commit -``` +`npm run test:update` which will update any snapshots that need updating. Make +sure to include those changes (if they exist) in your commit. ## Help needed @@ -67,6 +40,7 @@ Please checkout the [the open issues][issues] Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks! + [egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github -[all-contributors]: https://github.com/kentcdodds/all-contributors -[issues]: https://github.com/kentcdodds/babel-plugin-macros/issues +[issues]: https://github.com/kentcdodds/generator-kcd-oss/issues + diff --git a/README.md b/README.md index b7a9e22..209f34e 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,31 @@

babel-plugin-macros 🎣

-Allows you to build simple compile-time libraries - +

Allows you to build simple compile-time libraries

-
+--- + [![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] [![version][version-badge]][package] -[![downloads][downloads-badge]][npmchart] +[![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] + [![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors) + [![PRs Welcome][prs-badge]][prs] -[![Donate][donate-badge]][donate] [![Code of Conduct][coc-badge]][coc] - -[![Watch on GitHub][github-watch-badge]][github-watch] -[![Star on GitHub][github-star-badge]][github-star] -[![Tweet][twitter-badge]][twitter] + ## The problem -Check out this guest post on the Babel.js blog for a complete write up on the problem, motivation, and solution. +Check out +this +guest post on the Babel.js blog for a complete write up on the problem, +motivation, and solution. Currently, each babel plugin in the babel ecosystem requires that you configure it individually. This is fine for things like language features, but can be @@ -119,10 +120,12 @@ you could use `babel-plugin-macros` for, like: - [In what order are macros executed?](#in-what-order-are-macros-executed) - [Does it work with function calls only?](#does-it-work-with-function-calls-only) - [How about implicit optimizations at compile time?](#how-about-implicit-optimizations-at-compile-time) - - [Should macros be dependencies or devDependencies?](#should-macros-be-dependencies-or-devdependencies) - [Inspiration](#inspiration) - [Other Solutions](#other-solutions) -- [Contributors](#contributors) +- [Issues](#issues) + - [🐛 Bugs](#-bugs) + - [💡 Feature Requests](#-feature-requests) +- [Contributors ✨](#contributors-) - [LICENSE](#license) @@ -149,9 +152,9 @@ Are you trying to use `babel-plugin-macros`? Go to ### Author docs -Are you trying to make your own macros that works with `babel-plugin-macros`? Go to -[`other/docs/author.md`](other/docs/author.md). -(you should probably read the user docs too). +Are you trying to make your own macros that works with `babel-plugin-macros`? Go +to [`other/docs/author.md`](other/docs/author.md). (you should probably read the +user docs too). ### Caveats @@ -159,9 +162,16 @@ Are you trying to make your own macros that works with `babel-plugin-macros`? Go > **Note:** This issue is not present when used in Create React App. -Most of the time you'll probably be using this with the babel cache enabled in webpack to rebuild faster. If your macro function is **not pure** which gets different output with same code (e.g., IO side effects) it will cause recompile mechanism fail. Unfortunately you'll also experience this problem while developing your macro as well. If there's not a change to the source code that's being transpiled, then babel will use the cache rather than running your macro again. +Most of the time you'll probably be using this with the babel cache enabled in +webpack to rebuild faster. If your macro function is **not pure** which gets +different output with same code (e.g., IO side effects) it will cause recompile +mechanism fail. Unfortunately you'll also experience this problem while +developing your macro as well. If there's not a change to the source code that's +being transpiled, then babel will use the cache rather than running your macro +again. -For now, to force recompile the code you can simply add a cache busting comment in the file: +For now, to force recompile the code you can simply add a cache busting comment +in the file: ```diff import macro from 'non-pure.macro'; @@ -171,10 +181,14 @@ import macro from 'non-pure.macro'; macro('parameters'); ``` -This problem is still being worked on and is not unique to `babel-plugin-macros`. For more details and workarounds, please check related issues below: +This problem is still being worked on and is not unique to +`babel-plugin-macros`. For more details and workarounds, please check related +issues below: -- babel-plugin-preval: [How to force recompile? #19](https://github.com/kentcdodds/babel-plugin-preval/issues/19) -- graphql.macro: [Recompile problem (babel cache) #6](https://github.com/evenchange4/graphql.macro/issues/6) +- babel-plugin-preval: + [How to force recompile? #19](https://github.com/kentcdodds/babel-plugin-preval/issues/19) +- graphql.macro: + [Recompile problem (babel cache) #6](https://github.com/evenchange4/graphql.macro/issues/6) ## FAQ @@ -182,7 +196,8 @@ This problem is still being worked on and is not unique to `babel-plugin-macros` You can write your own without publishing them to `npm`, but if you'd like to see existing macros you can add to your project, then take a look at the -[Awesome babel macros](https://github.com/jgierer12/awesome-babel-macros) repository. +[Awesome babel macros](https://github.com/jgierer12/awesome-babel-macros) +repository. Please add any you don't see listed! @@ -305,7 +320,8 @@ const val = 7 * 6 Really, anything... -See the [testing snapshot](src/__tests__/__snapshots__/index.js.snap) for more examples. +See the [testing snapshot](src/__tests__/__snapshots__/index.js.snap) for more +examples. ### How about implicit optimizations at compile time? @@ -333,7 +349,25 @@ Thank you to [@phpnode](https://github.com/phpnode) for donating the npm package - [sweetjs](http://sweetjs.org/) -## Contributors +## Issues + +_Looking to contribute? Look for the [Good First Issue][good-first-issue] +label._ + +### 🐛 Bugs + +Please file an issue for bugs, missing documentation, or unexpected behavior. + +[**See Bugs**][bugs] + +### 💡 Feature Requests + +Please file an issue to suggest new features. Vote on feature requests by adding +a 👍. This helps maintainers prioritize what to work on. + +[**See Feature Requests**][requests] + +## Contributors ✨ Thanks goes to these people ([emoji key][emojis]): @@ -377,6 +411,7 @@ Thanks goes to these people ([emoji key][emojis]): + This project follows the [all-contributors][all-contributors] specification. @@ -386,7 +421,8 @@ Contributions of any kind welcome! MIT -[npm]: https://www.npmjs.com/ + +[npm]: https://www.npmjs.com [node]: https://nodejs.org [build-badge]: https://img.shields.io/travis/kentcdodds/babel-plugin-macros.svg?style=flat-square [build]: https://travis-ci.org/kentcdodds/babel-plugin-macros @@ -395,23 +431,17 @@ MIT [version-badge]: https://img.shields.io/npm/v/babel-plugin-macros.svg?style=flat-square [package]: https://www.npmjs.com/package/babel-plugin-macros [downloads-badge]: https://img.shields.io/npm/dm/babel-plugin-macros.svg?style=flat-square -[npmchart]: http://npmcharts.com/compare/babel-plugin-macros +[npmtrends]: http://www.npmtrends.com/babel-plugin-macros [license-badge]: https://img.shields.io/npm/l/babel-plugin-macros.svg?style=flat-square -[license]: LICENSE +[license]: https://github.com/kentcdodds/babel-plugin-preval/blob/master/LICENSE [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [prs]: http://makeapullrequest.com -[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square -[donate]: http://kcd.im/donate [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square -[coc]: other/CODE_OF_CONDUCT.md -[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/babel-plugin-macros.svg?style=social -[github-watch]: https://github.com/kentcdodds/babel-plugin-macros/watchers -[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/babel-plugin-macros.svg?style=social -[github-star]: https://github.com/kentcdodds/babel-plugin-macros/stargazers -[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20babel-plugin-macros!%20https://github.com/kentcdodds/babel-plugin-macros%20%F0%9F%91%8D -[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/babel-plugin-macros.svg?style=social -[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key -[all-contributors]: https://github.com/kentcdodds/all-contributors +[coc]: https://github.com/kentcdodds/babel-plugin-preval/blob/master/other/CODE_OF_CONDUCT.md +[emojis]: https://github.com/all-contributors/all-contributors#emoji-key +[all-contributors]: https://github.com/all-contributors/all-contributors + [preval]: https://github.com/kentcdodds/babel-plugin-preval [cra]: https://github.com/facebookincubator/create-react-app [cra-issue]: https://github.com/facebookincubator/create-react-app/issues/2730 + diff --git a/package.json b/package.json index 9acfcb8..f557531 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,12 @@ "description": "Allows you to build compile-time libraries", "main": "dist/index.js", "scripts": { - "add-contributor": "kcd-scripts contributors add", "build": "kcd-scripts build", "lint": "kcd-scripts lint", + "setup": "npm install && npm run validate -s", "test": "kcd-scripts test", - "test:update": "npm test -- --updateSnapshot", - "validate": "kcd-scripts validate", - "setup": "npm install && npm run validate -s" - }, - "husky": { - "hooks": { - "pre-commit": "kcd-scripts pre-commit" - } + "test:update": "npm test -- --updateSnapshot --coverage", + "validate": "kcd-scripts validate" }, "files": [ "dist" @@ -29,22 +23,22 @@ "babel-macros", "babel-plugin-macros" ], - "author": "Kent C. Dodds (http://kentcdodds.com/)", + "author": "Kent C. Dodds (https://kentcdodds.com)", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.7.2", + "@babel/runtime": "^7.9.2", "cosmiconfig": "^6.0.0", - "resolve": "^1.12.0" + "resolve": "^1.15.1" }, "devDependencies": { - "@babel/core": "^7.7.2", - "@babel/parser": "^7.7.3", - "@babel/types": "^7.7.2", + "@babel/core": "^7.9.0", + "@babel/parser": "^7.9.3", + "@babel/types": "^7.9.0", "ast-pretty-print": "^2.0.1", - "babel-plugin-tester": "^7.0.4", + "babel-plugin-tester": "^9.0.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", - "cpy": "^7.3.0", - "kcd-scripts": "^1.11.0" + "cpy": "^8.1.0", + "kcd-scripts": "^5.6.0" }, "eslintConfig": { "extends": "./node_modules/kcd-scripts/eslint.js" @@ -61,10 +55,14 @@ }, "repository": { "type": "git", - "url": "https://github.com/kentcdodds/babel-plugin-macros.git" + "url": "https://github.com/kentcdodds/babel-plugin-macros" }, "bugs": { "url": "https://github.com/kentcdodds/babel-plugin-macros/issues" }, - "homepage": "https://github.com/kentcdodds/babel-plugin-macros#readme" + "homepage": "https://github.com/kentcdodds/babel-plugin-macros#readme", + "engines": { + "node": ">=10", + "npm": ">=6" + } } From 6e4c2fbbf2b6f7ab201353db70877dd356d5a8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 23 Mar 2020 21:03:04 +0100 Subject: [PATCH 2/5] Run Prettier on full codebase --- .github/ISSUE_TEMPLATE.md | 6 +- CHANGELOG.md | 5 +- other/CODE_OF_CONDUCT.md | 45 +++++------ other/MAINTAINING.md | 77 ++++++++++--------- other/docs/author.md | 92 ++++++++++++---------- other/docs/user.md | 56 ++++++++------ other/manual-releases.md | 9 ++- src/__tests__/__snapshots__/index.js.snap | 94 +++++++++++++++-------- src/__tests__/fixtures/emotion.macro.js | 7 +- src/__tests__/index.js | 4 +- src/index.js | 2 +- 11 files changed, 227 insertions(+), 170 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b75c0e2..036aa28 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -11,9 +11,9 @@ never done that before, that's great! Check this free short video tutorial to learn how: http://kcd.im/pull-request --> -* `babel-plugin-macros` version: -* `node` version: -* `npm` (or `yarn`) version: +- `babel-plugin-macros` version: +- `node` version: +- `npm` (or `yarn`) version: Relevant code or config diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d221a..2a67529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # CHANGELOG -The changelog is automatically updated using [semantic-release](https://github.com/semantic-release/semantic-release). -You can see it on the [releases page](../../releases). +The changelog is automatically updated using +[semantic-release](https://github.com/semantic-release/semantic-release). You +can see it on the [releases page](../../releases). diff --git a/other/CODE_OF_CONDUCT.md b/other/CODE_OF_CONDUCT.md index afe2432..070cb5f 100644 --- a/other/CODE_OF_CONDUCT.md +++ b/other/CODE_OF_CONDUCT.md @@ -5,30 +5,30 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +size, disability, ethnicity, gender identity and expression, level of +experience, nationality, personal appearance, race, religion, or sexual identity +and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or +- The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities @@ -37,11 +37,11 @@ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. ## Scope @@ -58,8 +58,9 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kent+coc@doddsfamily.us. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +obligated to maintain confidentiality with regard to the reporter of an +incident. Further details of specific enforcement policies may be posted +separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other @@ -67,8 +68,8 @@ members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ diff --git a/other/MAINTAINING.md b/other/MAINTAINING.md index 025b673..703126d 100644 --- a/other/MAINTAINING.md +++ b/other/MAINTAINING.md @@ -4,60 +4,67 @@ This is documentation for maintainers of this project. ## Code of Conduct -Please review, understand, and be an example of it. Violations of the code of conduct are -taken seriously, even (especially) for maintainers. +Please review, understand, and be an example of it. Violations of the code of +conduct are taken seriously, even (especially) for maintainers. ## Issues -We want to support and build the community. We do that best by helping people learn to solve -their own problems. We have an issue template and hopefully most folks follow it. If it's -not clear what the issue is, invite them to create a minimal reproduction of what they're trying -to accomplish or the bug they think they've found. +We want to support and build the community. We do that best by helping people +learn to solve their own problems. We have an issue template and hopefully most +folks follow it. If it's not clear what the issue is, invite them to create a +minimal reproduction of what they're trying to accomplish or the bug they think +they've found. Once it's determined that a code change is necessary, point people to -[makeapullrequest.com](http://makeapullrequest.com) and invite them to make a pull request. -If they're the one who needs the feature, they're the one who can build it. If they need -some hand holding and you have time to lend a hand, please do so. It's an investment into -another human being, and an investment into a potential maintainer. +[makeapullrequest.com](http://makeapullrequest.com) and invite them to make a +pull request. If they're the one who needs the feature, they're the one who can +build it. If they need some hand holding and you have time to lend a hand, +please do so. It's an investment into another human being, and an investment +into a potential maintainer. -Remember that this is open source, so the code is not yours, it's ours. If someone needs a change -in the codebase, you don't have to make it happen yourself. Commit as much time to the project -as you want/need to. Nobody can ask any more of you than that. +Remember that this is open source, so the code is not yours, it's ours. If +someone needs a change in the codebase, you don't have to make it happen +yourself. Commit as much time to the project as you want/need to. Nobody can ask +any more of you than that. ## Pull Requests -As a maintainer, you're fine to make your branches on the main repo or on your own fork. Either -way is fine. +As a maintainer, you're fine to make your branches on the main repo or on your +own fork. Either way is fine. -When we receive a pull request, a travis build is kicked off automatically (see the `.travis.yml` -for what runs in the travis build). We avoid merging anything that breaks the travis build. +When we receive a pull request, a travis build is kicked off automatically (see +the `.travis.yml` for what runs in the travis build). We avoid merging anything +that breaks the travis build. -Please review PRs and focus on the code rather than the individual. You never know when this is -someone's first ever PR and we want their experience to be as positive as possible, so be -uplifting and constructive. +Please review PRs and focus on the code rather than the individual. You never +know when this is someone's first ever PR and we want their experience to be as +positive as possible, so be uplifting and constructive. When you merge the pull request, 99% of the time you should use the -[Squash and merge](https://help.github.com/articles/merging-a-pull-request/) feature. This keeps -our git history clean, but more importantly, this allows us to make any necessary changes to the -commit message so we release what we want to release. See the next section on Releases for more -about that. +[Squash and merge](https://help.github.com/articles/merging-a-pull-request/) +feature. This keeps our git history clean, but more importantly, this allows us +to make any necessary changes to the commit message so we release what we want +to release. See the next section on Releases for more about that. ## Release -Our releases are automatic. They happen whenever code lands into `master`. A travis build gets -kicked off and if it's successful, a tool called -[`semantic-release`](https://github.com/semantic-release/semantic-release) is used to -automatically publish a new release to npm as well as a changelog to GitHub. It is only able to -determine the version and whether a release is necessary by the git commit messages. With this -in mind, **please brush up on [the commit message convention][commit] which drives our releases.** +Our releases are automatic. They happen whenever code lands into `master`. A +travis build gets kicked off and if it's successful, a tool called +[`semantic-release`](https://github.com/semantic-release/semantic-release) is +used to automatically publish a new release to npm as well as a changelog to +GitHub. It is only able to determine the version and whether a release is +necessary by the git commit messages. With this in mind, **please brush up on +[the commit message convention][commit] which drives our releases.** -> One important note about this: Please make sure that commit messages do NOT contain the words -> "BREAKING CHANGE" in them unless we want to push a major version. I've been burned by this -> more than once where someone will include "BREAKING CHANGE: None" and it will end up releasing -> a new major version. Not a huge deal honestly, but kind of annoying... +> One important note about this: Please make sure that commit messages do NOT +> contain the words "BREAKING CHANGE" in them unless we want to push a major +> version. I've been burned by this more than once where someone will include +> "BREAKING CHANGE: None" and it will end up releasing a new major version. Not +> a huge deal honestly, but kind of annoying... ## Thanks! Thank you so much for helping to maintain this project! -[commit]: https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md +[commit]: + https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md diff --git a/other/docs/author.md b/other/docs/author.md index ef62bb2..b46c25a 100644 --- a/other/docs/author.md +++ b/other/docs/author.md @@ -1,18 +1,24 @@ # `babel-plugin-macros` Usage for macros authors -> See also: [the `user` docs](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md). +> See also: +> [the `user` docs](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md). Is this your first time working with ASTs? Here are some resources: -- [Writing custom Babel and ESLint plugins with ASTs](https://youtu.be/VBscbcm2Mok?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf): A 53 minute talk by [@kentcdodds](https://twitter.com/kentcdodds) -- [babel-handbook](https://github.com/thejameskyle/babel-handbook): A guided handbook on how to use Babel and how to create plugins for Babel by [@thejameskyle](https://twitter.com/thejameskyle) -- [Code Transformation and Linting](https://kentcdodds.com/workshops/#code-transformation-and-linting): A workshop (recording available on Frontend Masters) with exercises of making custom Babel and ESLint plugins +- [Writing custom Babel and ESLint plugins with ASTs](https://youtu.be/VBscbcm2Mok?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf): + A 53 minute talk by [@kentcdodds](https://twitter.com/kentcdodds) +- [babel-handbook](https://github.com/thejameskyle/babel-handbook): A guided + handbook on how to use Babel and how to create plugins for Babel by + [@thejameskyle](https://twitter.com/thejameskyle) +- [Code Transformation and Linting](https://kentcdodds.com/workshops/#code-transformation-and-linting): + A workshop (recording available on Frontend Masters) with exercises of making + custom Babel and ESLint plugins ## Writing a macro > You might appreciate -> [this example repo](https://github.com/kentcdodds/cra-macro-example) -> which shows how to write and use macros in a create-react-app application. +> [this example repo](https://github.com/kentcdodds/cra-macro-example) which +> shows how to write and use macros in a create-react-app application. A macro is a JavaScript module that exports a function. Here's a simple example: @@ -48,9 +54,9 @@ There are two parts to the `babel-plugin-macros` API: ### Filename -The way that `babel-plugin-macros` determines whether to run a macro is based on the -source string of the `import` or `require` statement. It must match this regex: -`/[./]macro(\.js)?$/` for example: +The way that `babel-plugin-macros` determines whether to run a macro is based on +the source string of the `import` or `require` statement. It must match this +regex: `/[./]macro(\.js)?$/` for example: _matches_: @@ -74,9 +80,9 @@ _does not match_: > which would work fine. **If you're going to publish this to npm,** the most ergonomic thing would be to -name it something that ends in `.macro`. If it's part of a larger package, -then calling the file `macro.js` or placing it in `macro/index.js` is a great -way to go as well. Then people could do: +name it something that ends in `.macro`. If it's part of a larger package, then +calling the file `macro.js` or placing it in `macro/index.js` is a great way to +go as well. Then people could do: ```js import Nice from 'nice.macro' @@ -86,8 +92,9 @@ import Sweet from 'sweet/macro' In addition, please publish your macro with the [`keyword`][keyword] of `babel-plugin-macros` (note the "s"). That way folks can easily find macros by -searching for the [`babel-plugin-macros` keyword on npm][npm-babel-plugin-macros]. In -addition, and you can add this badge to the top of your README: +searching for the [`babel-plugin-macros` keyword on +npm][npm-babel-plugin-macros]. In addition, and you can add this badge to the +top of your README: [![Babel Macro](https://img.shields.io/badge/babel--macro-%F0%9F%8E%A3-f5da55.svg?style=flat-square)](https://github.com/kentcdodds/babel-plugin-macros) @@ -102,19 +109,19 @@ parameter which is an object with the following properties: #### state -The state of the file being traversed. It's the second argument -you receive in a visitor function in a normal babel plugin. +The state of the file being traversed. It's the second argument you receive in a +visitor function in a normal babel plugin. #### babel -This is the same thing you get as an argument to normal babel plugins. -It is also the same thing you get if you `require('babel-core')`. +This is the same thing you get as an argument to normal babel plugins. It is +also the same thing you get if you `require('babel-core')`. #### references -This is an object that contains arrays of all the references to -things imported from macro keyed based on the name of the import. The items -in each array are the paths to the references. +This is an object that contains arrays of all the references to things imported +from macro keyed based on the name of the import. The items in each array are +the paths to the references.
@@ -159,8 +166,8 @@ import {foo as FooMacro} from './my.macro' From here, it's just a matter of doing doing stuff with the `BabelPath`s that you're given. For that check out [the babel handbook][babel-handbook]. -> One other thing to note is that after your macro has run, babel-plugin-macros will -> remove the import/require statement for you. +> One other thing to note is that after your macro has run, babel-plugin-macros +> will remove the import/require statement for you. #### source @@ -170,10 +177,11 @@ This is a string used as import declaration's source - i.e. `'./my.macro'`. There is a feature that allows users to configure your macro. -To specify that your plugin is configurable, you pass a `configName` to `createMacro`. +To specify that your plugin is configurable, you pass a `configName` to +`createMacro`. -A configuration is created from data combined from two sources: -We use [`cosmiconfig`][cosmiconfig] to read a `babel-plugin-macros` configuration which +A configuration is created from data combined from two sources: We use +[`cosmiconfig`][cosmiconfig] to read a `babel-plugin-macros` configuration which can be located in any of the following files up the directories from the importing file: @@ -185,36 +193,40 @@ importing file: - `babel-plugin-macros.config.js` - `babelMacros` in `package.json` -The content of the config will be merged with the content of the babel macros plugin -options. Config options take priority. +The content of the config will be merged with the content of the babel macros +plugin options. Config options take priority. All together specifying and using the config might look like this: ```javascript // .babel-plugin-macros.config.js module.exports = { - taggedTranslations: { locale: 'en_US' } + taggedTranslations: {locale: 'en_US'}, } // .babel.config.js module.exports = { plugins: [ - ['macros': { - taggedTranslations: { locale: 'en_GB' } - }] - ] + [ + ('macros': { + taggedTranslations: {locale: 'en_GB'}, + }), + ], + ], } // taggedTranslations.macro.js const {createMacro} = require('babel-plugin-macros') -module.exports = createMacro(taggedTranslationsMacro, {configName: 'taggedTranslations'}) +module.exports = createMacro(taggedTranslationsMacro, { + configName: 'taggedTranslations', +}) function taggedTranslationsMacro({references, state, babel, config}) { - const { locale = 'en' } = config; + const {locale = 'en'} = config } ``` -Note that in the above example if both files were sepcified the final locale value would -be `en_US`, since that is the value in the plugin config file. +Note that in the above example if both files were sepcified the final locale +value would be `en_US`, since that is the value in the plugin config file. ### Keeping imports @@ -292,8 +304,10 @@ If you want code coverage, you'll have to call your macro yourself. Contributions to improve this experience are definitely welcome! [preval]: https://github.com/kentcdodds/babel-plugin-preval -[babel-handbook]: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md +[babel-handbook]: + https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md [tester]: https://github.com/babel-utils/babel-plugin-tester [keyword]: https://docs.npmjs.com/files/package.json#keywords -[npm-babel-plugin-macros]: https://www.npmjs.com/browse/keyword/babel-plugin-macros +[npm-babel-plugin-macros]: + https://www.npmjs.com/browse/keyword/babel-plugin-macros [cosmiconfig]: https://www.npmjs.com/package/cosmiconfig diff --git a/other/docs/user.md b/other/docs/user.md index 32605d8..060d865 100644 --- a/other/docs/user.md +++ b/other/docs/user.md @@ -1,6 +1,7 @@ # `babel-plugin-macros` Usage for users -> See also: [the `author` docs](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/author.md). +> See also: +> [the `author` docs](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/author.md). ## Adding the plugin to your config @@ -42,10 +43,10 @@ require('babel-core').transform('code', { ## Using a macro -With the `babel-plugin-macros` plugin added to your config, we can now use a macro -that works with the `babel-plugin-macros` API. Let's assume we have such a module -in our project called `eval.macro.js`. To use it, we `import` or `require` -the macro module in our code like so: +With the `babel-plugin-macros` plugin added to your config, we can now use a +macro that works with the `babel-plugin-macros` API. Let's assume we have such a +module in our project called `eval.macro.js`. To use it, we `import` or +`require` the macro module in our code like so: ```javascript import MyEval from './eval.macro' @@ -54,29 +55,37 @@ const MyEval = require('./eval.macro') ``` Then we use that variable however the documentation for the macro says. -Incidentally, `eval.macro.js` actually exists in the tests for `babel-plugin-macros` -[here][eval-macro] and you can see how it transforms our code in -[the `babel-plugin-macros` snapshots][eval-snapshots]. +Incidentally, `eval.macro.js` actually exists in the tests for +`babel-plugin-macros` [here][eval-macro] and you can see how it transforms our +code in [the `babel-plugin-macros` snapshots][eval-snapshots]. > Note here that the real benefit is that we don't need to configure anything -> for every macro you add. We simply configure `babel-plugin-macros`, then we can -> use any macro available. This is part of the benefit of using `babel-plugin-macros`. +> for every macro you add. We simply configure `babel-plugin-macros`, then we +> can use any macro available. This is part of the benefit of using +> `babel-plugin-macros`. -[eval-macro]: https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/__tests__/fixtures/eval.macro.js -[eval-snapshots]: https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/__tests__/__snapshots__/index.js.snap +[eval-macro]: + https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/__tests__/fixtures/eval.macro.js +[eval-snapshots]: + https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/__tests__/__snapshots__/index.js.snap ### Using with create-react-app > [Checkout the CRA Macro Example repo](https://github.com/kentcdodds/cra-macro-example) -`babel-plugin-macros` ships with `react-scripts` 2.0! This is awesome because it allows for babel to be configured in a nice way without having to eject from `create-react-app`! +`babel-plugin-macros` ships with `react-scripts` 2.0! This is awesome because it +allows for babel to be configured in a nice way without having to eject from +`create-react-app`! Before deciding to use this however you should be aware of a few things: 1. Features may be broken or not work as expected -2. Documentation for new features is still sparse, so look through the pull requests for how they're expected to work +2. Documentation for new features is still sparse, so look through the pull + requests for how they're expected to work -With that being said you can use all the awesomeness of `babel-plugin-macros` inside `create-react-app` by running one of the following commands based on your situation. +With that being said you can use all the awesomeness of `babel-plugin-macros` +inside `create-react-app` by running one of the following commands based on your +situation. ``` $ # Create a new application @@ -92,15 +101,16 @@ There is a feature that allows you to configure your macro. We use can be located in any of the following files up the directories from the importing file: -* `.babel-plugin-macrosrc` -* `.babel-plugin-macrosrc.json` -* `.babel-plugin-macrosrc.yaml` -* `.babel-plugin-macrosrc.yml` -* `.babel-plugin-macrosrc.js` -* `babel-plugin-macros.config.js` -* `babelMacros` in `package.json` +- `.babel-plugin-macrosrc` +- `.babel-plugin-macrosrc.json` +- `.babel-plugin-macrosrc.yaml` +- `.babel-plugin-macrosrc.yml` +- `.babel-plugin-macrosrc.js` +- `babel-plugin-macros.config.js` +- `babelMacros` in `package.json` -You need to specify your `configName`. EG: For configuring [styled-components macro][styled-components], the `configName` is `"styledComponents"`: +You need to specify your `configName`. EG: For configuring [styled-components +macro][styled-components], the `configName` is `"styledComponents"`: ```js // babel-plugin-macros.config.js diff --git a/other/manual-releases.md b/other/manual-releases.md index f4c5b11..154fc8a 100644 --- a/other/manual-releases.md +++ b/other/manual-releases.md @@ -1,9 +1,10 @@ # manual-releases -This project has an automated release set up. So things are only released when there are -useful changes in the code that justify a release. But sometimes things get messed up one way or another -and we need to trigger the release ourselves. When this happens, simply bump the number below and commit -that with the following commit message based on your needs: +This project has an automated release set up. So things are only released when +there are useful changes in the code that justify a release. But sometimes +things get messed up one way or another and we need to trigger the release +ourselves. When this happens, simply bump the number below and commit that with +the following commit message based on your needs: **Major** diff --git a/src/__tests__/__snapshots__/index.js.snap b/src/__tests__/__snapshots__/index.js.snap index 0e4ff69..6f996ba 100644 --- a/src/__tests__/__snapshots__/index.js.snap +++ b/src/__tests__/__snapshots__/index.js.snap @@ -8,7 +8,12 @@ const bar = Wrap(

); ↓ ↓ ↓ ↓ ↓ ↓ -const bar = Wrap(

); +const bar = Wrap( +
+

+
, +) + `; @@ -26,9 +31,10 @@ const Div = STYLED.div\` ↓ ↓ ↓ ↓ ↓ ↓ -const red = "background-color: red;"; +const red = 'background-color: red;' const Div = STYLED.div\`composes: background-color: red; - color: blue;\`; + color: blue;\` + `; @@ -39,7 +45,8 @@ const x = 34 + 45 ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; @@ -73,7 +80,8 @@ const bar = 42; ↓ ↓ ↓ ↓ ↓ ↓ -const bar = 42; +const bar = 42 + `; @@ -98,7 +106,8 @@ configured\`stuff\` ↓ ↓ ↓ ↓ ↓ ↓ // eslint-disable-next-line babel/no-unused-expressions -configured\`stuff\`; +configured\`stuff\` + `; @@ -109,8 +118,9 @@ const red = macro('noop'); ↓ ↓ ↓ ↓ ↓ ↓ -import macro from './fixtures/keep-imports.macro'; -const red = macro('noop'); +import macro from './fixtures/keep-imports.macro' +const red = macro('noop') + `; @@ -121,9 +131,10 @@ const red = macro('noop'); ↓ ↓ ↓ ↓ ↓ ↓ -const macro = require('./fixtures/keep-imports.macro'); +const macro = require('./fixtures/keep-imports.macro') + +const red = macro('noop') -const red = macro('noop'); `; @@ -134,15 +145,18 @@ const red = macro('noop') ↓ ↓ ↓ ↓ ↓ ↓ -"use strict"; +'use strict' -var _keepImports = require("./fixtures/keep-imports.macro"); +var _keepImports = require('./fixtures/keep-imports.macro') -var _keepImports2 = _interopRequireDefault(_keepImports); +var _keepImports2 = _interopRequireDefault(_keepImports) -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj} +} + +const red = (0, _keepImports2.default)('noop') -const red = (0, _keepImports2.default)('noop'); `; @@ -184,11 +198,12 @@ const Div = styled.div\` const red = css\` background-color: red; -\`; +\` const Div = styled.div\` composes: \${red} color: blue; -\`; +\` + `; @@ -199,7 +214,8 @@ fakeMacro('hi') ↓ ↓ ↓ ↓ ↓ ↓ -fakeMacro('hi'); +fakeMacro('hi') + `; @@ -221,7 +237,8 @@ const x = myEval\`34 + 45\` ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; @@ -232,7 +249,8 @@ const x = evaler\`34 + 45\` ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; @@ -246,8 +264,9 @@ global.result = result ↓ ↓ ↓ ↓ ↓ ↓ -const result = ("foobar", 42); -global.result = result; +const result = ('foobar', 42) +global.result = result + `; @@ -261,7 +280,8 @@ configured\`stuff\` ↓ ↓ ↓ ↓ ↓ ↓ // eslint-disable-next-line babel/no-unused-expressions -configured\`stuff\`; +configured\`stuff\` + `; @@ -275,7 +295,8 @@ configured\`stuff\` ↓ ↓ ↓ ↓ ↓ ↓ // eslint-disable-next-line babel/no-unused-expressions -configured\`stuff\`; +configured\`stuff\` + `; @@ -289,7 +310,8 @@ configured\`stuff\` ↓ ↓ ↓ ↓ ↓ ↓ // eslint-disable-next-line babel/no-unused-expressions -configured\`stuff\`; +configured\`stuff\` + `; @@ -335,7 +357,8 @@ configured\`stuff\` ↓ ↓ ↓ ↓ ↓ ↓ // eslint-disable-next-line babel/no-unused-expressions -configured\`stuff\`; +configured\`stuff\` + `; @@ -346,7 +369,8 @@ const x = myEval('34 + 45') ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; @@ -357,7 +381,8 @@ const x = myEval\`34 + 45\` ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; @@ -375,9 +400,10 @@ const Div = STYLED.div\` ↓ ↓ ↓ ↓ ↓ ↓ -const red = "background-color: red;"; +const red = 'background-color: red;' const Div = STYLED.div\`composes: background-color: red; - color: blue;\`; + color: blue;\` + `; @@ -395,9 +421,10 @@ const Div = styled.div\` ↓ ↓ ↓ ↓ ↓ ↓ -const red = "background-color: red;"; +const red = 'background-color: red;' const Div = styled.div\`composes: background-color: red; - color: blue;\`; + color: blue;\` + `; @@ -408,6 +435,7 @@ const x = evaler\`34 + 45\` ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const x = 79 + `; diff --git a/src/__tests__/fixtures/emotion.macro.js b/src/__tests__/fixtures/emotion.macro.js index 72e50cd..21cc8fa 100644 --- a/src/__tests__/fixtures/emotion.macro.js +++ b/src/__tests__/fixtures/emotion.macro.js @@ -9,12 +9,7 @@ function emotionMacro({references, babel}) { references.css.forEach(cssRef => { if (cssRef.parentPath.type === 'TaggedTemplateExpression') { cssRef.parentPath.replaceWith( - t.stringLiteral( - cssRef.parentPath - .get('quasi') - .evaluate() - .value.trim(), - ), + t.stringLiteral(cssRef.parentPath.get('quasi').evaluate().value.trim()), ) } }) diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 9c4222d..0ef561c 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -67,9 +67,9 @@ pluginTester({ title: 'does nothing to code that does not import macro', snapshot: false, code: ` - import foo from "./some-file-without-macro"; + import foo from './some-file-without-macro' - const bar = require("./some-other-file-without-macro"); + const bar = require('./some-other-file-without-macro') `, }, { diff --git a/src/index.js b/src/index.js index 3e21b8f..162dfe1 100644 --- a/src/index.js +++ b/src/index.js @@ -67,7 +67,7 @@ function nodeResolvePath(source, basedir) { basedir, // This is here to support the package being globally installed // read more: https://github.com/kentcdodds/babel-plugin-macros/pull/138 - paths: [p.resolve(__dirname, '../../')] + paths: [p.resolve(__dirname, '../../')], }) } From 1c17a7c5e271ce4861a3f5b01a71f7399355a2e3 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Wed, 25 Mar 2020 15:57:23 -0600 Subject: [PATCH 3/5] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bcf79a7..0932077 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,5 +42,5 @@ requests! Thanks! [egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github -[issues]: https://github.com/kentcdodds/generator-kcd-oss/issues +[issues]: https://github.com/kentcdodds/babel-plugin-macros/issues From b4080d972fa82510cf806ad5eab31850decc086c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 26 Mar 2020 10:59:39 +0100 Subject: [PATCH 4/5] Add tests on Windows --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 30fa818..52ffdf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,12 @@ node_js: - 10.0.0 - 12 - node +os: + - linux + - windows +# Travis does not support secrets on Windows yet so we test only external PRs where the secrets are not exposed +# https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264 +if: os = linux OR (type = pull_request AND head_repo != repo) install: npm install script: - npm run validate @@ -19,4 +25,6 @@ jobs: include: - stage: release node_js: 12 + # Build release on linux + os: linux script: kcd-scripts travis-release From a7adb9cf2a9d1d563602fe149d8d9e711e009b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 26 Mar 2020 11:00:22 +0100 Subject: [PATCH 5/5] Update --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 209f34e..6484a81 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ ## The problem Check out -this -guest post on the Babel.js blog for a complete write up on the problem, -motivation, and solution. +[this guest post](https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros) +on the Babel.js blog for a complete write up on the problem, motivation, and +solution. Currently, each babel plugin in the babel ecosystem requires that you configure it individually. This is fine for things like language features, but can be @@ -433,11 +433,11 @@ MIT [downloads-badge]: https://img.shields.io/npm/dm/babel-plugin-macros.svg?style=flat-square [npmtrends]: http://www.npmtrends.com/babel-plugin-macros [license-badge]: https://img.shields.io/npm/l/babel-plugin-macros.svg?style=flat-square -[license]: https://github.com/kentcdodds/babel-plugin-preval/blob/master/LICENSE +[license]: https://github.com/kentcdodds/babel-plugin-macros/blob/master/LICENSE [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [prs]: http://makeapullrequest.com [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square -[coc]: https://github.com/kentcdodds/babel-plugin-preval/blob/master/other/CODE_OF_CONDUCT.md +[coc]: https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/CODE_OF_CONDUCT.md [emojis]: https://github.com/all-contributors/all-contributors#emoji-key [all-contributors]: https://github.com/all-contributors/all-contributors