Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit a471f76

Browse files
committed
v0.8.3
1 parent 2757346 commit a471f76

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

dist/hint.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require('angular-hint');
99

1010
angular.hint.onAny(function (data, severity) {
1111
window.postMessage({
12+
__fromBatarang: true,
1213
module: this.event.split(':')[0],
1314
event: this.event,
1415
data: data,
@@ -1363,12 +1364,17 @@ module.exports = function(str) {
13631364
return true;
13641365
}
13651366

1366-
if(str.toLowerCase() === str || str.charAt(0).toUpperCase() === str.charAt(0)) {
1367+
if(str.charAt(0).toUpperCase() === str.charAt(0)) {
13671368
angular.hint.emit(MODULE_NAME, 'The best practice for' +
1368-
' module names is to use lowerCamelCase. Check the name of "' + str + '".',
1369+
' module names is to use dot.case or lowerCamelCase. Check the name of "' + str + '".',
13691370
SEVERITY_SUGGESTION);
13701371
return false;
13711372
}
1373+
if(str.toLowerCase() === str && str.indexOf('.') === -1) {
1374+
angular.hint.emit(MODULE_NAME, 'Module names should be namespaced' +
1375+
' with a dot (app.dashboard) or lowerCamelCase (appDashboard). Check the name of "' + str + '".', SEVERITY_SUGGESTION);
1376+
return false;
1377+
}
13721378
return true;
13731379
};
13741380

@@ -1627,18 +1633,43 @@ angular.module = function() {
16271633
var ngEventAttributes = require('../lib/event-directives'),
16281634
MODULE_NAME = 'Events';
16291635

1636+
/*
1637+
* Remove string expressions except property accessors.
1638+
* ex. abc["def"] = "gef"; // `removeStringExp` will remove "gef" but not "def".
1639+
*/
1640+
function removeStringExp(str) {
1641+
return str.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
1642+
function(match, pos, full) {
1643+
// this is our lookaround code so that our regex doesn't become so
1644+
// complicated.
1645+
if (pos !== 0 && (match.length + pos) !== full.length &&
1646+
full[pos - 1] === '[' && full[pos + match.length] === ']') {
1647+
return match;
1648+
}
1649+
return '';
1650+
});
1651+
}
16301652

16311653
var getFunctionNames = function(str) {
16321654
if (typeof str !== 'string') {
16331655
return [];
16341656
}
1635-
var results = str.replace(/\s+/g, '').split(/[\+\-\/\|\<\>\^=&!%~;]/g).map(function(x) {
1636-
if (isNaN(+x)) {
1637-
if (x.match(/\w+\(.*\)$/)){
1638-
return x.substr(0, x.indexOf('('));
1657+
// There are still a bunch of corner cases here where we aren't going to be able to handle
1658+
// but we shouldn't break the user's app and we should handle most common cases.
1659+
// example of corner cases: we can't check for properties inside of function
1660+
// arguments like `move(a.b.c)` with the current implementation
1661+
// or property accessors with parentheses in them
1662+
// like `prop["hello (world)"] = "test";`.
1663+
// To fully fix these issues we would need a full blown expression parser.
1664+
var results = removeStringExp(str.replace(/\s+/g, ''))
1665+
.replace(/\(.*?\)/g, '')
1666+
.split(/[\+\-\/\|\<\>\^=&!%~;]/g).map(function(x) {
1667+
if (isNaN(+x)) {
1668+
if (x.match(/\w+\(.*\)$/)){
1669+
return x.substr(0, x.indexOf('('));
1670+
}
1671+
return x;
16391672
}
1640-
return x;
1641-
}
16421673
}).filter(function(x){
16431674
return x;
16441675
});

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AngularJS Batarang",
3-
"version": "0.8.2",
3+
"version": "0.8.3",
44
"description": "Extends the Developer Tools, adding tools for debugging and profiling AngularJS applications.",
55
"devtools_page": "devtoolsBackground.html",
66
"manifest_version": 2,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-batarang",
3-
"version": "0.8.2",
3+
"version": "0.8.3",
44
"description": "chrome extension for inspecting angular apps",
55
"main": "hint.js",
66
"devDependencies": {

0 commit comments

Comments
 (0)