diff options
author | Dan <dan.d.wolff@gmail.com> | 2018-02-06 07:19:28 +0100 |
---|---|---|
committer | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-06 14:19:28 +0800 |
commit | c0b8f2a16d4804fe302e5db91995735ee7041c8d (patch) | |
tree | 97378e5dfe3f9665456276f74ea220f00ca09265 | |
parent | cb0257dbbfa9c71c20b2bb3a91b7bfdad7a1459e (diff) | |
download | tracifyjs-c0b8f2a16d4804fe302e5db91995735ee7041c8d.tar.gz tracifyjs-c0b8f2a16d4804fe302e5db91995735ee7041c8d.zip |
add information on testing and code style (#2885)
fixes #2884
-rw-r--r-- | CONTRIBUTING.md | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..dd281168 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,60 @@ +Contributing +============ + +## Documentation + +Every new feature and API change should be accompanied by a README additon. + +## Testing + +All features and bugs should have tests that verify the fix. You can run all +tests using `npm test`. + +The most common type of test are tests that verify input and output of the +Uglify transforms. These tests exist in `test/compress`. New tests can be added +either to an existing file or in a new file `issue-xxx.js`. + +Tests that cannot be expressed as a simple AST can be found in `test/mocha`. + +## Code style + +- `LF` is always used as a line ending. +- Statements end with semicolons. +- Indentation uses 4 spaces, switch `case` 2 spaces. +- Identifiers use `snake_case`. +- Strings use double quotes (`"`). +- Use a trailing comma for multiline array and object literals to minimize diffs. +- The Uglify code only uses ES5, even in the `harmony` branch. +- Line length should be at most 80 cols, except when it is easier to read a + longer line. +- If both sides of a comparison are of the same type, `==` and `!=` are used. +- Multiline conditions place `&&` and `||` first on the line. + +**Example feature** + +```js +OPT(AST_Debugger, function(self, compressor) { + if (compressor.option("drop_debugger")) + return make_node(AST_EmptyStatement, self); + return self; +}); +``` + +**Example test case** + +```js +drop_debugger: { + options = { + drop_debugger: true, + } + input: { + debugger; + if (foo) debugger; + } + expect: { + if (foo); + } +} +``` + + |