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

Commit a46a7b5

Browse files
committed
refactor
1 parent 81452ba commit a46a7b5

31 files changed

+3814
-55
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ install:
1515
- mkdir -p $LOGS_DIR
1616
- ./scripts/sauce_connect_setup.sh
1717
- npm install
18-
- npm install -g bower
19-
- ./bower-install.sh
18+
- ./npm-install.sh
2019
- ./scripts/wait_for_browser_provider.sh
2120

2221
script:

bower-install.sh

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

config/karma.sauce.conf.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* karma.conf.js and karma.es5.conf.js optionally load this
3+
*/
4+
5+
var CUSTOM_LAUNCHERS = {
6+
'SL_Chrome': {
7+
base: 'SauceLabs',
8+
browserName: 'chrome',
9+
version: '35'
10+
},
11+
'SL_Firefox': {
12+
base: 'SauceLabs',
13+
browserName: 'firefox',
14+
version: '26'
15+
},
16+
'SL_Safari': {
17+
base: 'SauceLabs',
18+
browserName: 'safari',
19+
platform: 'OS X 10.9',
20+
version: '7'
21+
}
22+
};
23+
24+
module.exports = function(options) {
25+
options.sauceLabs = {
26+
testName: 'Angular Router Unit Tests',
27+
startConnect: true
28+
};
29+
options.customLaunchers = CUSTOM_LAUNCHERS;
30+
options.browsers = Object.keys(CUSTOM_LAUNCHERS);
31+
options.reporters = ['dots', 'saucelabs'];
32+
};

config/karma.travis.conf.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* karma.conf.js and karma.es5.conf.js optionally load this
3+
*/
4+
5+
module.exports = function(options) {
6+
if (!isTravis()) {
7+
return;
8+
} else if (!options.sauceLabs) {
9+
throw new Error('This should be loaded after karma.sauce config');
10+
}
11+
options.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
12+
options.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
13+
options.sauceLabs.startConnect = false;
14+
15+
// TODO(vojta): remove once SauceLabs supports websockets.
16+
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
17+
options.transports = ['xhr-polling'];
18+
19+
options.singleRun = true;
20+
};
21+
22+
function isTravis() {
23+
return !!process.env.TRAVIS;
24+
}

config/protractor.travis.conf.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
module.exports = function (options) {
4+
options.sauceUser = process.env.SAUCE_USERNAME;
5+
options.sauceKey = process.env.SAUCE_ACCESS_KEY;
6+
7+
options.multiCapabilities = [{
8+
'browserName': 'chrome',
9+
'platform': 'OS X 10.9',
10+
'name': 'Angular Hint E2E',
11+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
12+
'build': process.env.TRAVIS_BUILD_NUMBER,
13+
'version': '34'
14+
}, {
15+
'browserName': 'firefox',
16+
'name': 'Angular Hint E2E',
17+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
18+
'build': process.env.TRAVIS_BUILD_NUMBER,
19+
'version': '28'
20+
}, {
21+
browserName: 'safari',
22+
'platform': 'OS X 10.9',
23+
'version': '7',
24+
'name': 'Angular Hint E2E',
25+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
26+
'build': process.env.TRAVIS_BUILD_NUMBER
27+
}];
28+
};
File renamed without changes.
File renamed without changes.

example/index.html renamed to examples/broken-example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ <h1> Angular Best Practices </h1>
5858
</ul>
5959
</div>
6060
<script src="../bower_components/angular/angular.js"></script>
61-
<script src="../dist/hint.js"></script>
6261
<script>
6362
angular.module('bpAppModule', []);
6463
/**
@@ -137,6 +136,7 @@ <h1> Angular Best Practices </h1>
137136
replace: true
138137
};
139138
});
139+
angular.version.minor = 1;
140140
</script>
141141
</body>
142142

examples/correct-example/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Example
2+
3+
This application is a corrected version of the `broken-example` application that was created to
4+
show off hints generated by AngularHint. This application loads AngularHint but generates no
5+
hints because it adheres to best practices.
File renamed without changes.
File renamed without changes.

hint.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
'use strict';
22

33
// Create pipe for all hint messages from different modules
4-
window.angular.hint = require('angular-hint-log');
4+
require('./lib/modules/log');
55

66
// Load angular hint modules
7-
require('angular-hint-controllers');
8-
require('angular-hint-directives');
9-
//require('angular-hint-dom');
10-
require('angular-hint-events');
11-
//require('angular-hint-interpolation');
12-
require('angular-hint-modules');
13-
require('angular-hint-scopes');
7+
require('./lib/modules/controllers');
8+
// require('./lib/modules/directives');
9+
// require('./lib/modules/dom');
10+
// require('./lib/modules/events');
11+
// require('./lib/modules/interpolation');
12+
// require('./lib/modules/modules');
13+
require('./lib/modules/scopes');
1414

1515
// List of all possible modules
1616
// The default ng-hint behavior loads all modules
1717
var allModules = [
1818
'ngHintControllers',
19-
'ngHintDirectives',
19+
// 'ngHintDirectives',
2020
// 'ngHintDom',
21-
'ngHintEvents',
21+
// 'ngHintEvents',
2222
// 'ngHintInterpolation',
23-
'ngHintModules',
23+
// 'ngHintModules',
2424
'ngHintScopes'
2525
];
2626

@@ -73,7 +73,7 @@ function loadModules() {
7373
} else if (document.querySelector('[ng-hint]')) {
7474
modules = allModules;
7575
} else {
76-
angular.hint.logMessage('General', 'ngHint is included on the page, but is not active because ' +
76+
angular.hint.log('General', 'ngHint is included on the page, but is not active because ' +
7777
'there is no `ng-hint` attribute present', SEVERITY_WARNING);
7878
}
7979
return modules;
@@ -91,7 +91,7 @@ function hintModulesFromElement (elt) {
9191

9292
return selectedModules.map(hintModuleName).filter(function (name) {
9393
return (allModules.indexOf(name) > -1) ||
94-
angular.hint.logMessage('General', 'Module ' + name + ' could not be found', SEVERITY_WARNING);
94+
angular.hint.log('General', 'Module ' + name + ' could not be found', SEVERITY_WARNING);
9595
});
9696
}
9797

karma.conf.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
var sauceConfig = require('./config/karma.sauce.conf');
4+
var travisConfig = require('./config/karma.travis.conf');
5+
//var fs = require('fs');
6+
7+
//fs.readdirSync(__dirname + '/lib/modules').filter
8+
9+
module.exports = function(config) {
10+
var options = {
11+
frameworks: ['browserify', 'jasmine'],
12+
files: [
13+
'node_modules/angular/angular.js',
14+
'node_modules/angular-mocks/angular-mocks.js',
15+
'lib/modules/log.js',
16+
'lib/modules/*.js'
17+
],
18+
preprocessors: {
19+
'lib/modules/controllers.js': ['browserify'],
20+
'lib/modules/events.js': ['browserify'],
21+
'lib/modules/scopes.js': ['browserify']
22+
},
23+
browsers: ['Chrome'],
24+
browserify: {
25+
debug: true
26+
}
27+
};
28+
29+
if (process.argv.indexOf('--sauce') > -1) {
30+
sauceConfig(options);
31+
travisConfig(options);
32+
}
33+
34+
config.set(options);
35+
};

lib/addSuggestions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
var getValidProps = require('./getValidProps'),
4+
suggest = require('suggest-it');
5+
6+
module.exports = function addSuggestions(messages) {
7+
messages.forEach(function(messageObj) {
8+
var dictionary = getValidProps(messageObj.scope),
9+
suggestion = suggest(dictionary)(messageObj.boundFunc);
10+
messageObj['match'] = suggestion;
11+
});
12+
return messages;
13+
};

lib/consts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
SEVERITY: {
3+
4+
}
5+
};

0 commit comments

Comments
 (0)