UNPKG

8.97 kBMarkdownView Raw
1## Welcome!
2
3We’re so glad you’re thinking about contributing to a Technology Transformation Services (TTS) open source project! If you’re unsure about anything, just ask — or submit your issue or pull request anyway. The worst that can happen is we’ll politely ask you to change something. We appreciate all friendly contributions.
4
5TTS is committed to building a safe, welcoming, harassment-free culture for everyone. We expect everyone on the TTS team and everyone within TTS spaces, including contributors to our projects, to follow the [TTS Code of Conduct](https://github.com/18F/code-of-conduct/blob/master/code-of-conduct.md).
6
7We encourage you to read this project’s CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), [README](README.md) and its [Workflow](https://github.com/uswds/uswds/wiki/Workflow) process.
8
9If you have any questions or want to read more, check out the [18F Open Source Policy GitHub repository]( https://github.com/18f/open-source-policy), or [send us an email](mailto:18f@gsa.gov).
10
11## Guidelines
12
13### Contributor Guidelines for Design
14
15We have provided some guidelines for folks that would like to submit new components to the U.S. Web Design System and the lifecycle those new components will go through. For more detail, please visit the [guidelines on our wiki](https://github.com/uswds/uswds/wiki/Contribution-Guidelines:-Design).
16
17### Submitting an issue
18
19To help us get a better understanding of the issue you’re submitting, follow our ISSUE TEMPLATE and the guidelines it describes.
20
21### Submitting a pull request
22
23Here are a few guidelines to follow when submitting a pull request:
24
251. Create a GitHub account or sign in to your existing account.
261. Fork this repo into your GitHub account (or just clone it if you’re an 18F team member). Read more about forking a repo here on GitHub:
27[https://help.github.com/articles/fork-a-repo/](https://help.github.com/articles/fork-a-repo/)
281. Create a branch from `develop` that lightly defines what you’re working on (for example, add-styles).
291. Ensure that your contribution works via `npm`, if applicable.
301. Once you’re ready to submit a pull request, fill out the PULL REQUEST template provided.
311. Submit your pull request against the `develop` branch.
32
33[Open an issue](https://github.com/uswds/uswds/issues/new) if you have questions or need help with setup.
34
35### Running locally
36
37The U.S. Web Design System `uswds` package (the zip download and the
38files needed to use the Design System on your project) is built primarily with
39two [Node.js] tools: [Fractal] and [Gulp]. Once you've cloned this
40repository, you'll need to install its dependencies:
41
42```sh
43npm install
44```
45
46**ProTip**: You can also use [Yarn], which tends to install dependencies more quickly than npm.
47
48To start the [Fractal] live reload server, run:
49
50```sh
51npm start
52```
53
54Then, visit [localhost:3000](http://localhost:3000) in a web browser to
55peruse the component library. While the server is running, any changes that
56you make to the component templates or configurations will reload the page
57automatically.
58
59If you're working on the JavaScript or CSS, you can run the "watch" task in
60another shell to automatically rebuild the distribution files that Fractal
61references with:
62
63```sh
64npm run watch
65```
66
67### Testing
68
69To run the component unit tests, run:
70
71```sh
72npm test
73```
74
75This will also run [eslint] and [stylelint] to ensure that the JavaScript
76and SCSS source files meet our coding standards along with [snyk test] to check for package dependency vulnerabilities. To lint without the unit
77tests, you'll need [Gulp][]. Install it globally (`npm install -g
78gulp-cli`), then run:
79
80```sh
81gulp eslint
82gulp stylelint
83```
84
85(Or, if you don't want to install Gulp globally, you can run `$(npm
86bin)/gulp` instead of `gulp`.)
87
88Note that running the tests also requires an installation of
89Chrome v59 or higher (v60 if you're on Windows).
90
91If you want to run a single test file, run `npm run mocha ${path/to/spec-file}`,
92substituting the actual path to the spec. Only javascript files can be executed by the `mocha` runner,
93and only those js files in the `spec` directory ending with a `.spec.js`.
94
95Alternatively, you can add an `.only` to a `describe` or `it` block (i.e. `describe.only('my spec')`)
96and run the `npm run test` command. Keep in mind that this will also run linters and aXe accessibility tests.
97
98To run all of the unit tests, run `npm run test:unit`.
99
100**For non-OSX users**:
101Before running the tests, if you are developing on a machine running an operating system other than OSX,
102you'll need to export a `CHROME_PATH` environment variable that points to Chrome's binary location. This ensures `chrome-launcher`
103can find a version of Chrome for our aXe visual acceptence tests. A table of the locations of the binary
104for each OS can [be found here](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver#requirements).
105
106#### Visual regression testing
107
108The Design System comes with optional tooling for detecting visual regressions,
109which can be especially useful if you're refactoring CSS.
110
111These tests work by comparing current screenshots of the Design System's Fractal
112components to "golden" screenshots that represent what the components are
113supposed to look like.
114
115Golden screenshots are stored on your local development system *only*;
116they're not version controlled. This means that after making changes to a branch,
117you can switch to the branch you'd like to compare it to (e.g. the `develop`
118branch) to generate your golden screenshots.
119
120To generate the golden screenshots, run:
121
122```
123npm run test:visual:update
124```
125
126Then, make any CSS refactorings (or switch to a branch that has them).
127
128To compare the current state of your CSS to the golden screenshots, run:
129
130```
131npm run test:visual
132```
133
134If the current screenshots don't match their golden counterparts, you will
135be directed to an HTML file that visually shows the differences between
136any conflicting screenshots.
137
138### Building
139
140To build the `uswds` package in preparation for releases, run:
141
142```sh
143npm run release
144```
145
146## Coding guidelines
147
148The purpose of our coding styleguides are to create consistent coding practices across 18F. The styleguide should be treated as a guide — rules can be modified according to project needs.
149
150This project follows the 18F Front End Guide [CSS](https://pages.18f.gov/frontend/#css) and [JavaScript](https://pages.18f.gov/frontend/#javascript). Please use this guide for your reference.
151
152### Code coverage
153
154We use [code coverage](https://en.wikipedia.org/wiki/Code_coverage) tools to understand how much of our JavaScript is tested by our [unit test suite](spec/unit). Code coverage is one way (among many) of measuring code _quality_ more generally. Here's how it works for contributions:
155
1561. Each pull request creates a new coverage report on [Code Climate](https://codeclimate.com/).
1571. Code Climate then posts a status message back to GitHub that lists the coverage percentage on that branch, and the difference between that number and the one last reported on our default branch.
158
159For JavaScript contributions, we will review the code coverage percentage and change to ensure that the quality of our code is not dramatically affected.
160
161High code coverage numbers are generally good, and we would prefer that our coverage increases over time. We will not categorically reject contributions that reduce code coverage, but we may ask contributors to refactor their code, add new unit tests, or modify existing tests to avoid significant reductions in coverage.
162
163## Browser support
164See [browser support](https://designsystem.digital.gov/getting-started/developers/#browser-support) in the “Getting started: Developers” guidelines.
165
166## Our use of branches
167
168See the [release documentation](https://github.com/uswds/uswds/wiki/Release-process) for more information on our git/GitHub release workflow.
169
170## Licenses and attribution
171
172### A few parts of this project are not in the public domain
173
174For complete attribution and licensing information for parts of the project that are not in the public domain, see the [LICENSE](LICENSE.md).
175
176### The rest of this project is in the public domain
177
178The rest of this project is in the worldwide [public domain](https://github.com/uswds/uswds/blob/develop/LICENSE.md).
179
180This project is in the public domain within the United States, and
181copyright and related rights in the work worldwide are waived through
182the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
183
184### Contributions will be released into the public domain
185
186All contributions to this project will be released under the CC0
187dedication. By submitting a pull request, you are agreeing to comply
188with this waiver of copyright interest.
189
190[Node.js]: https://nodejs.org
191[Fractal]: http://fractal.build
192[Gulp]: http://gulpjs.com/
193[Yarn]: https://yarnpkg.com/
194[eslint]: http://eslint.org/
195[stylelint]: https://stylelint.io/