Skip to content

Commit

Permalink
added code style rules to project & generated files [issue#26](//issu…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewconnell committed Sep 8, 2015
1 parent 2eca8de commit 97d59f8
Show file tree
Hide file tree
Showing 61 changed files with 2,195 additions and 1,660 deletions.
74 changes: 74 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"excludeFiles": [
"node_modules/**",
"bower_components/**"
],
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"maximumLineLength": 120,
"validateIndentation": 2,
"validateQuoteMarks": "'",
"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowMultipleVarDecl": null,
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBinaryOperators": [
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
"&=", "|=", "^=", "+=",
"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
"|", "^", "&&", "||", "===", "==", ">=",
"<=", "<", ">", "!=", "!=="
],
"requireSpaceAfterLineComment": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": false,
"requireLineFeedAtFileEnd": true,
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": false,
"disallowSpacesInsideParentheses": true,
"jsDoc": {
"checkAnnotations": true,
"checkParamNames": true,
"requireParamTypes": true,
"checkReturnTypes": true,
"checkTypes": true
},
"disallowMultipleLineBreaks": false,
"disallowCommaBeforeLineBreak": null,
"disallowDanglingUnderscores": null,
"disallowEmptyBlocks": null,
"disallowTrailingComma": null,
"requireCommaBeforeLineBreak": null,
"requireDotNotation": null,
"requireMultipleVarDecl": null,
"requireParenthesesAroundIIFE": true
}
66 changes: 66 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"es3": false,
"forin": true,
"freeze": true,
"immed": true,
"indent": 2,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": false,
"strict": false,
"maxparams": 10,
"maxdepth": 5,
"maxstatements": 40,
"maxcomplexity": 8,
"maxlen": 120,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": true,
"loopfunc": true,
"maxerr": 50,
"moz": false,
"multistr": false,
"notypeof": false,
"proto": false,
"scripturl": false,
"shadow": false,
"sub": true,
"supernew": false,
"validthis": false,
"noyield": false,
"browser": true,
"node": true,
"globals": {
// vendors
"angular": false,
"jQuery": false,
"Office": false,
"app": false,
// tests
"describe": false,
"it": false,
"beforeEach": false,
"afterEach": false
}
}
18 changes: 13 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
If you would like to become an active contributor to this project please read the following guidelines.

## Reporting Bugs & Issues
If you have any bugs or issues with the generator. Please submit them in the Issues for this repo.
If you have any bugs or issues with the generator. Please submit them in the [Issues](/OfficeDev/generator-office/issues) for this repo.

## Submitting Feature Requests & Design Change Requests
Feature requests and Design Change Requests (DCRs) are an important part of the lifecycle of any software project. Please log these as Issues in the repo.
Feature requests and Design Change Requests (DCRs) are an important part of the lifecycle of any software project. Please log these as [Issues](/OfficeDev/generator-office/issues) in the repo.

When opening any feature requests, consider including as much information as possible, including:

Expand All @@ -16,8 +16,16 @@ When opening any feature requests, consider including as much information as pos
- A miniature test plan or list of test scenarios is always helpful.

## Contributing Code
We encourage contributions to the repo through Pull Requests. The first time you do this you will be prompted by our CLA bot at Microsoft to agree to our Contributor License Agreement. AFter this we will review your code and work with you on merging it into the repo.
As you can see from this repo, we are using unit tests to test the generator. We will only accept pull requests that have full unit test coverage & conform to the coding style guides.

As you can see from this repo, we are using unit tests to test the generator. We will only accept pull requests that have full unit test coverage.
Please feel free to reach out to the team if you have any questions on contributing. You can create an issue if you are having problems and @ mention [@jthake](/jthake) & [@andrewconnell](/andrewconnell).

Please feel free to reach out to the team if you have any questions on contributing. You can create an issue if you are having problems and at mention jthake and andrewconnell.
## Submitting Pull Requests
- Before submitting any significant pull requests, open an issue and explain your idea / suggestion before coding.
- Significant PR's submitted with no "heads up" will go through a slow review process and are not likely to be accepted.
- All code must meet the project's [Coding Conventions & Guidelines](docs/CODING.md) the covers:
- coding style
- testing
- documentation
- Send pull request **ONLY TO THE DEV BRANCH** of this repo.
- Please make sure you have included tests with your submission. *Pull requests without sufficient tests will not be accepted*.
57 changes: 57 additions & 0 deletions docs/CODING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Coding Conventions & Gudelines

Refer to the existing code & tests for examples of coding guidelines for this project.

All code must pass the [JSHint](http://www.jshint.com) & [JSCS](http://jscs.info) rules defined in this project which are defined in the following config files:

- JSHint Settings: [.jshintrc](../.jshint)
- JSCS Settings: [.jscsrc](../.jscsrc)

## Coding Style

Check all source files to ensure they meet these guidelines using the provided gulp task **vet**:

```
$ gulp vet
```

While coding, you can automatically run this using the **autovet** task:

```
$ gulp autovet
```

To simplify the task of formatting your code, you can use the **JSCS** command line NPM module provided in the developer dependencies. This does not do all code fixes, just the things that can be automatically fixed by the JSCS CLI

```
$ node_modules/jscs/bin/jscs [path-to-js-files] --fix
```

You can also pass multiple files in using the following:

```
$ node_modules/jscs/bin/jscs test/taskpane/*.js --fix
```

## Testing

- All code must have valid, **passing** unit tests
- All code should have 100% test coverage or good reasons why it doesn't meet 100% coverage

Run all tests using the provided gulp task **test**:

```
$ gulp test
```

While coding, you can automatically run this using the **autotest** task:

```
$ gulp autotest
```

To generate a code coverage report, after running tests, open the [code coverage report](../coverage/lcov-report/index.html) in a browser.

## Documentation

- All non-trival functions should have a [jsdoc](http://usejsdoc.org/) description

0 comments on commit 97d59f8

Please sign in to comment.