-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kent C. Dodds
committed
Jan 13, 2017
0 parents
commit 3c34335
Showing
22 changed files
with
873 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"projectName": "prettier-eslint", | ||
"projectOwner": "kentcdodds", | ||
"files": [ | ||
"README.md" | ||
], | ||
"imageSize": 100, | ||
"commit": false, | ||
"contributors": [ | ||
{ | ||
"login": "kentcdodds", | ||
"name": "Kent C. Dodds", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1500684?v=3", | ||
"profile": "https://kentcdodds.com", | ||
"contributions": [ | ||
"code", | ||
"doc", | ||
"infra", | ||
"test" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["latest", "stage-2"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.nyc_output | ||
coverage | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
*.js text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
.nyc_output | ||
coverage | ||
dist | ||
.opt-in | ||
.opt-out | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
registry=http://registry.npmjs.org/ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sudo: false | ||
language: node_js | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- '6' | ||
before_script: | ||
- npm prune | ||
script: | ||
- npm start validate | ||
after_success: | ||
- npm start report-coverage | ||
- npm start release | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Contributing | ||
|
||
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] | ||
|
||
## Project setup | ||
|
||
1. Fork and clone the repo | ||
2. `$ npm install` to install dependencies | ||
3. `$ npm start validate` to validate you've got it working | ||
4. Create a branch for your PR | ||
|
||
This project uses [`p-s`][p-s] and you can run `npm start` to see what scripts are available. | ||
|
||
## 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 start addContributor <YOUR_GITHUB_USERNAME> | ||
``` | ||
|
||
Follow the prompt. 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. | ||
|
||
## Committing and Pushing changes | ||
|
||
This project uses [`semantic-release`][semantic-release] to do automatic releases and generate a changelog based on the | ||
commit history. So we follow [a convention][convention] for commit messages. Please follow this convention for your | ||
commit messages. | ||
|
||
You can use `commitizen` to help you to follow [the convention][convention] | ||
|
||
Once you are ready to commit the changes, please use the below commands | ||
|
||
1. `git add <files to be comitted>` | ||
2. `$ npm start commit` | ||
|
||
... and follow the instruction of the interactive prompt. | ||
|
||
### 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: | ||
|
||
``` | ||
commit-msg | ||
pre-commit | ||
``` | ||
|
||
## Help needed | ||
|
||
Please checkout the [ROADMAP.md][ROADMAP] and raise an issue to discuss | ||
any of the items in the want to do or might do list. | ||
|
||
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 | ||
[semantic-release]: https://npmjs.com/package/semantic-release | ||
[convention]: https://github.com/conventional-changelog/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md | ||
[all-contributors]: https://github.com/kentcdodds/all-contributors | ||
[ROADMAP]: ./ROADMAP.md | ||
[p-s]: https://npmjs.com/package/p-s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2016 Kent C. Dodds | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# prettier-eslint | ||
|
||
Formats your JavaScript using [`prettier`][prettier] followed by [`eslint --fix`][eslint] | ||
|
||
[![Build Status][build-badge]][build] | ||
[![Code Coverage][coverage-badge]][coverage] | ||
[![Dependencies][dependencyci-badge]][dependencyci] | ||
[![version][version-badge]][package] | ||
[![downloads][downloads-badge]][npm-stat] | ||
[![MIT License][license-badge]][LICENSE] | ||
|
||
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) | ||
[![PRs Welcome][prs-badge]][prs] | ||
[![Donate][donate-badge]][donate] | ||
[![Code of Conduct][coc-badge]][coc] | ||
[![Roadmap][roadmap-badge]][roadmap] | ||
[![Examples][examples-badge]][examples] | ||
|
||
[![Watch on GitHub][github-watch-badge]][github-watch] | ||
[![Star on GitHub][github-star-badge]][github-star] | ||
[![Tweet][twitter-badge]][twitter] | ||
|
||
## The problem | ||
|
||
[`prettier`][prettier] can do some really fantastic automatic formatting. And one of the nice things about it is how | ||
opinionated it is. Unfortunately it's either not opinionated enough in some respects and other opinions differ from my | ||
own. | ||
|
||
## This solution | ||
|
||
This formats your code via `prettier`, and then passes the result of that to `eslint --fix`. This way you can get the | ||
benefits of `prettier`'s superior formatting capabilities, but also benefit from the configuration capabilities of | ||
`eslint`. | ||
|
||
## Installation | ||
|
||
This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your | ||
project's `devDependencies`: | ||
|
||
``` | ||
npm install --save-dev prettier-eslint | ||
``` | ||
|
||
## Usage | ||
|
||
### Example | ||
|
||
``` | ||
const format = require('prettier-eslint') | ||
// notice, no semicolon in the original text | ||
const sourceCode = 'const {foo} = bar' | ||
const options = { | ||
text: sourceCode, | ||
eslintConfig: { | ||
rules: { | ||
semi: ['error', 'never'], | ||
}, | ||
}, | ||
prettierOptions: { | ||
bracketSpacing: true, | ||
}, | ||
} | ||
const formatted = format(options) | ||
// notice no semicolon in the formatted text | ||
formatted // const { foo } = bar | ||
``` | ||
|
||
### options | ||
|
||
#### text (String) | ||
|
||
The source code to format. | ||
|
||
#### filePath (?String) | ||
|
||
The path of the file being formatted can be used in leu of `eslintConfig` (eslint will be used to find the relevant | ||
config for the file). | ||
|
||
#### eslintConfig (?Object) | ||
|
||
The config to use for formatting with ESLint. If this is provided, then `filePath` is not necessary. | ||
|
||
#### prettierOptions (?Object) | ||
|
||
The options to pass for formatting with `prettier`. If not provided, `prettier-eslint` will attempt to create the | ||
options based on the `eslintConfig` (whether that's provided or derived via `filePath`. | ||
|
||
## Inspiration | ||
|
||
- [`prettier`][prettier] | ||
- [`eslint`][eslint] | ||
|
||
## Other Solutions | ||
|
||
None that I'm aware of. Feel free to file a PR if you know of any other solutions. | ||
|
||
## Contributors | ||
|
||
Thanks goes to these people ([emoji key][emojis]): | ||
|
||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/prettier-eslint/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/prettier-eslint/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/prettier-eslint/commits?author=kentcdodds) | | ||
| :---: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
|
||
This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome! | ||
|
||
## LICENSE | ||
|
||
MIT | ||
|
||
[prettier]: https://github.com/jlongster/prettier | ||
[eslint]: http://eslint.org/ | ||
[npm]: https://www.npmjs.com/ | ||
[node]: https://nodejs.org | ||
[build-badge]: https://img.shields.io/travis/kentcdodds/prettier-eslint.svg?style=flat-square | ||
[build]: https://travis-ci.org/kentcdodds/prettier-eslint | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/prettier-eslint.svg?style=flat-square | ||
[coverage]: https://codecov.io/github/kentcdodds/prettier-eslint | ||
[dependencyci-badge]: https://dependencyci.com/github/kentcdodds/prettier-eslint/badge?style=flat-square | ||
[dependencyci]: https://dependencyci.com/github/kentcdodds/prettier-eslint | ||
[version-badge]: https://img.shields.io/npm/v/prettier-eslint.svg?style=flat-square | ||
[package]: https://www.npmjs.com/package/prettier-eslint | ||
[downloads-badge]: https://img.shields.io/npm/dm/prettier-eslint.svg?style=flat-square | ||
[npm-stat]: http://npm-stat.com/charts.html?package=prettier-eslint&from=2016-04-01 | ||
[license-badge]: https://img.shields.io/npm/l/prettier-eslint.svg?style=flat-square | ||
[license]: https://github.com/kentcdodds/prettier-eslint/blob/master/other/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]: https://github.com/kentcdodds/prettier-eslint/blob/master/other/CODE_OF_CONDUCT.md | ||
[roadmap-badge]: https://img.shields.io/badge/%F0%9F%93%94-roadmap-CD9523.svg?style=flat-square | ||
[roadmap]: https://github.com/kentcdodds/prettier-eslint/blob/master/other/ROADMAP.md | ||
[examples-badge]: https://img.shields.io/badge/%F0%9F%92%A1-examples-8C8E93.svg?style=flat-square | ||
[examples]: https://github.com/kentcdodds/prettier-eslint/blob/master/other/EXAMPLES.md | ||
[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/prettier-eslint.svg?style=social | ||
[github-watch]: https://github.com/kentcdodds/prettier-eslint/watchers | ||
[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/prettier-eslint.svg?style=social | ||
[github-star]: https://github.com/kentcdodds/prettier-eslint/stargazers | ||
[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20prettier-eslint!%20https://github.com/kentcdodds/prettier-eslint%20%F0%9F%91%8D | ||
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/prettier-eslint.svg?style=social | ||
[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key | ||
[all-contributors]: https://github.com/kentcdodds/all-contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
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. | ||
|
||
## 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 | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* 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 | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
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. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
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. | ||
|
||
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 | ||
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] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Project Roadmap | ||
|
||
## Want to do | ||
|
||
## Might do | ||
|
||
## Wont do |
Oops, something went wrong.