Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 8aa7ca6

Browse files
author
vikasrohit
committed
Merge branch 'dev' into feature/sup-2839-invite-only-challenge-card
* dev: (23 commits) Delete unneeded folder and files Add better examples Update command in readme Change command Update readme for linting Enforce linting and fail early with travis scripts Try travis command Try different error and travis command test lint error Enforce linting Remove unused code Update version Too many semicolons Put back after fix Test Refactor for clarification and remove unneeded code Add detect encoding to production Move mangle options outside webpack config repo Put back webpack version for new release Remove old karma browsers ...
2 parents 9e5a4d9 + b31b0ec commit 8aa7ca6

File tree

180 files changed

+5379
-21149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+5379
-21149
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/*
2+
assets/*
3+
report/*

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"env": {
1010
"es6": true,
1111
"browser": true,
12-
"node": true
12+
"node": true,
13+
"mocha": true,
14+
"jquery": true
1315
},
1416
"extends": "eslint:recommended",
1517
"ecmaFeatures": {

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ node_js:
33
- 5.5.0
44
install:
55
- npm install
6-
before_script:
7-
- export DISPLAY=:99.0
8-
- sh -e /etc/init.d/xvfb start
9-
- sleep 3 # give xvfb some time to start
106
script:
11-
- npm test
12-
- webpack --bail --progress --build --tc
7+
- npm run lint && npm test && npm run build
138
sudo: false
149
deploy:
1510
- provider: s3
@@ -34,6 +29,7 @@ deploy:
3429
branch: qa-integration
3530
- provider: s3
3631
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
32+
detect_encoding: true
3733
access_key_id: $MASTER_AWS_KEY
3834
secret_access_key: $MASTER_AWS_SECRET
3935
bucket: app.topcoder.com

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#### Dev [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=dev)](https://travis-ci.org/appirio-tech/topcoder-app) Master [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=master)](https://travis-ci.org/appirio-tech/topcoder-app)
1+
#### Dev [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=dev)](https://travis-ci.org/appirio-tech/topcoder-app) QA [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=qa-integration)](https://travis-ci.org/appirio-tech/topcoder-app) Master [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=master)](https://travis-ci.org/appirio-tech/topcoder-app)
22
# Topcoder-App
33

44
This repository houses any new topcoder pages or refactored Angular apps/pages from the tc-site repository.
@@ -13,11 +13,12 @@ Install dependencies by running the following in the root of the project:
1313
- `npm i`
1414
- **Note:** You must use npm 3. Type `npm -v` to ensure you have a 3.x version.
1515

16-
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/sample/` to `http://local.topcoder-dev.com:3000/sample/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
16+
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/login/` to `http://local.topcoder-dev.com:3000/login/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
1717

1818
## NPM Commands
19-
- To run locally: `npm run dev` and head to `local.topcoder-dev.com:3000/my-dashboard`
19+
- To run locally: `npm start` and head to `local.topcoder-dev.com:3000/login`
2020
- To create the build: `npm run build`
21+
- To run code linting: `npm run lint`
2122
- To run the tests: `npm test`
2223

2324
## Recommended Developer Tools
@@ -47,15 +48,16 @@ JavaScript linting
4748
- For new projects, you can create a local `.eslintrc.json` file by running `eslint --init`
4849
- **Note:** If you're using ES6, make sure you add `"modules": true` to `"ecmaFeatures"` and `"node": true` to `"env"` in your `.eslintrc.json` file
4950
- **Note:** If you are using React, make sure you have `eslint` and `eslint-plugin-react` as `devDependencies` in your `package.json` file
50-
- **Optional**: Add `"lint": "eslint ."` to your `package.json` file to run linting at any time via `npm run lint`
5151

5252
Automatic JavaScript linting in Sublime Text
5353
- Install [SublimeLinter](http://sublimelinter.readthedocs.org/en/latest/installation.html) following the instructions under "Installing via Package Control"
5454
- Install [SublimeLinter-eslint](https://github.com/roadhump/SublimeLinter-eslint) with the package manager. The package is called `SublimeLinter-contrib-eslint`
5555

5656
### Testing
5757

58-
To read about the file and folder structure of tests, read [this section](https://github.com/appirio-tech/topcoder-app#tests)
58+
The tests folder contains mock data (`tests/test-helpers/mock-data.js`). To run tests, use `npm test`.
59+
60+
Spec files live alongside the code they are testing. For example, in peer-review you have `review-status.controller.js` and `review-status.spec.js` in the same review-status folder.
5961

6062
### Description of Files and Folders
6163

@@ -73,11 +75,6 @@ Services live in their own folder. All services are part of the tc.services modu
7375
- Scripts
7476
- This folder contains our analytics, e.g. Google, New Relic, etc.
7577

76-
#### tests
77-
The tests folder contains mock data (`tests/test-helpers/mock-data.js`). To run tests, use `npm test`.
78-
79-
Spec files live alongside the code they are testing. For example, in peer-review you have `review-status.controller.js` and `review-status.spec.js` in the same review-status folder.
80-
8178
## UI-Router and States
8279
See any `*.routes.js` file as an example.
8380

@@ -87,8 +84,8 @@ See any `*.routes.js` file as an example.
8784

8885
### Style Guide and Naming Conventions
8986

87+
- Our travis build runs `npm run lint` and `npm test`, so make sure your code adheres to the code style enforced by our linters
9088
- Please use ES2015 syntax whenever possible
91-
- Do not use semicolons
9289
- Use the Angular style guide mentioned below
9390

9491
In general, follow this [AngularJS style guide](https://github.com/johnpapa/angular-styleguide), which covers JavaScript code style, JavaScript variable naming, and file naming conventions. One deviation is in the naming of services, where we follow the same pattern as controllers, e.g. UserService, ProfileService.

app/account/login/login.controller.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ import angular from 'angular'
115115
return Helpers.redirectPostLogin($stateParams.next)
116116
})
117117
.catch(function(resp) {
118+
/*eslint no-fallthrough:0*/
118119
switch (resp.status) {
119-
case "ACCOUNT_INACTIVE":
120-
window.location.href = "https://www." + CONSTANTS.domain + "/account-inactive/"
121-
case "USER_NOT_REGISTERED":
122-
default:
123-
vm.socialLoginError = 401
124-
vm.loginErrors.SOCIAL_LOGIN_ERROR = true
125-
break
120+
case 'ACCOUNT_INACTIVE':
121+
window.location.href = 'https://www.' + CONSTANTS.domain + '/account-inactive/'
122+
case 'USER_NOT_REGISTERED':
123+
default:
124+
vm.socialLoginError = 401
125+
vm.loginErrors.SOCIAL_LOGIN_ERROR = true
126+
break
126127
}
127128
})
128129
}

app/account/login/login.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Login Controller', function() {
33
var controller
44
var scope

app/account/logout/logout.controller.spec.js renamed to app/account/logout/logout.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
/*eslint no-undef:0*/
12
import angular from 'angular'
23

3-
/* jshint -W117, -W030 */
44
describe('Logout Controller', function() {
55
var controller
66
var fakeWindow = {

app/account/register/register.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Register Controller', function() {
33
var controller
44

@@ -16,7 +16,7 @@ describe('Register Controller', function() {
1616
beforeEach(function() {
1717
var helperService = {
1818
getCountyObjFromIP: function() {
19-
return $q.when({name: "United States", alpha2: "US", alpha3: "USA", code: "840"})
19+
return $q.when({name: 'United States', alpha2: 'US', alpha3: 'USA', code: '840'})
2020
}
2121
}
2222

app/account/reset-password/reset-password.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Reset Password Controller', function() {
33
var controller
4-
var apiUrl = 'https://api.topcoder-dev.com/v3'
54

65
beforeEach(function() {
76
bard.appModule('topcoder')
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import angular from 'angular'
2+
13
// Include in index.html so that app level exceptions are handled.
24
// Exclude from testRunner.html which should run exactly what it wants to run
35
(function () {
4-
'use strict';
6+
'use strict'
57

68
angular
79
.module('blocks.exception')
810
.provider('exceptionHandler', exceptionHandlerProvider)
9-
.config(config);
11+
.config(config)
1012

1113
/**
1214
* Must configure the exception handling
@@ -16,18 +18,18 @@
1618
/* jshint validthis:true */
1719
this.config = {
1820
appErrorPrefix: undefined
19-
};
21+
}
2022

2123
this.configure = function (appErrorPrefix) {
22-
this.config.appErrorPrefix = appErrorPrefix;
23-
};
24+
this.config.appErrorPrefix = appErrorPrefix
25+
}
2426

2527
this.$get = function () {
26-
return {config: this.config};
27-
};
28+
return {config: this.config}
29+
}
2830
}
2931

30-
config.$inject = ['$provide'];
32+
config.$inject = ['$provide']
3133

3234
/**
3335
* Configure by setting an optional string value for appErrorPrefix.
@@ -37,10 +39,10 @@
3739
* @ngInject
3840
*/
3941
function config($provide) {
40-
$provide.decorator('$exceptionHandler', extendExceptionHandler);
42+
$provide.decorator('$exceptionHandler', extendExceptionHandler)
4143
}
4244

43-
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', 'logger'];
45+
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', 'logger']
4446

4547
/**
4648
* Extend the $exceptionHandler service to also display a toast.
@@ -51,20 +53,20 @@
5153
*/
5254
function extendExceptionHandler($delegate, exceptionHandler, logger) {
5355
return function (exception, cause) {
54-
var appErrorPrefix = exceptionHandler.config.appErrorPrefix || '';
55-
var errorData = {exception: exception, cause: cause};
56-
exception.message = appErrorPrefix + exception.message;
57-
$delegate(exception, cause);
56+
var appErrorPrefix = exceptionHandler.config.appErrorPrefix || ''
57+
var errorData = {exception: exception, cause: cause}
58+
exception.message = appErrorPrefix + exception.message
59+
$delegate(exception, cause)
5860
/**
5961
* Could add the error to a service's collection,
6062
* add errors to $rootScope, log errors to remote web server,
6163
* or log locally. Or throw hard. It is entirely up to you.
62-
* throw exception;
64+
* throw exception
6365
*
6466
* @example
65-
* throw { message: 'error message we added' };
67+
* throw { message: 'error message we added' }
6668
*/
67-
logger.error(exception.message, errorData);
68-
};
69+
logger.error(exception.message, errorData)
70+
}
6971
}
70-
})();
72+
})()

app/blocks/exception/exception-handler.provider.spec.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/blocks/exception/exception.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1+
import angular from 'angular'
2+
13
(function () {
2-
'use strict';
4+
'use strict'
35

4-
angular
5-
.module('blocks.exception')
6-
.factory('exception', exception);
6+
angular.module('blocks.exception').factory('exception', exception)
77

8-
exception.$inject = ['logger'];
8+
exception.$inject = ['logger']
99

10-
/* @ngInject */
1110
function exception(logger) {
1211
var service = {
1312
catcher: catcher
14-
};
15-
return service;
13+
}
14+
return service
1615

1716
function catcher(message) {
1817
return function (reason) {
19-
logger.error(message, reason);
20-
};
18+
logger.error(message, reason)
19+
}
2120
}
2221
}
23-
})();
22+
})()
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import angular from 'angular'
2+
13
(function () {
2-
'use strict';
4+
'use strict'
35

4-
angular.module('blocks.exception', ['blocks.logger']);
5-
})();
6+
angular.module('blocks.exception', ['blocks.logger'])
7+
})()

0 commit comments

Comments
 (0)