Skip to content

Commit dd988bd

Browse files
Merge pull request #447 from Gillespie59/development
1.6.2
2 parents 1e1bedb + 368ecb9 commit dd988bd

Some content is hidden

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

69 files changed

+2325
-2089
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22
node_js:
3-
- "6.0"
4-
- "5.0"
5-
- "4.2"
3+
- 7
4+
- 6
5+
- 5
6+
- 4
67
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

docs/timeout-service.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ The following patterns are considered problems;
2626
window.setTimeout(function() {
2727
// ...
2828
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
29+
30+
// invalid
31+
$window.setTimeout(function() {
32+
// ...
33+
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
2934

3035
The following patterns are **not** considered problems;
3136

examples/timeout-service.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ window.setTimeout(function() {
1515
// ...
1616
}, 1000)
1717

18+
19+
// example - valid: false, errorMessage: "You should use the $timeout service instead of the default window.setTimeout method"
20+
$window.setTimeout(function() {
21+
// ...
22+
}, 1000)
23+

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-angular",
3-
"version": "1.6.1",
3+
"version": "1.6.2",
44
"description": "ESLint rules for AngularJS projects",
55
"main": "index.js",
66
"scripts": {
@@ -29,10 +29,10 @@
2929
"gulp": "^3.9.1",
3030
"gulp-eslint": "^3.0.1",
3131
"gulp-istanbul": "^1.0.0",
32-
"gulp-mocha": "^2.2.0",
32+
"gulp-mocha": "^3.0.1",
3333
"istanbul": "^0.4.2",
3434
"lodash": "^4.13.1",
35-
"mocha": "^2.4.5",
35+
"mocha": "^3.2.0",
3636
"parse-comments": "^0.4.3",
3737
"shelljs": "^0.7.1",
3838
"shelljs-nodecli": "^0.1.1"

rules/angularelement.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
*/
1111
'use strict';
1212

13-
module.exports = function(context) {
14-
return {
15-
CallExpression: function(node) {
16-
if (node.callee.name === '$' || node.callee.name === 'jQuery') {
17-
context.report(node, 'You should use angular.element instead of the jQuery $ object', {});
13+
module.exports = {
14+
meta: {
15+
schema: []
16+
},
17+
create: function(context) {
18+
return {
19+
CallExpression: function(node) {
20+
if (node.callee.name === '$' || node.callee.name === 'jQuery') {
21+
context.report(node, 'You should use angular.element instead of the jQuery $ object', {});
22+
}
1823
}
19-
}
20-
};
24+
};
25+
}
2126
};
22-
23-
module.exports.schema = [];

rules/component-limit.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,39 @@
1818
var angularRule = require('./utils/angular-rule');
1919

2020

21-
module.exports = angularRule(function(context) {
22-
var limit = context.options[0] || 1;
23-
var count = 0;
24-
var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}';
21+
module.exports = {
22+
meta: {
23+
schema: [{
24+
type: 'integer'
25+
}]
26+
},
27+
create: angularRule(function(context) {
28+
var limit = context.options[0] || 1;
29+
var count = 0;
30+
var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}';
2531

26-
function checkLimit(callee) {
27-
count++;
28-
if (count > limit) {
29-
context.report(callee, msg, {
30-
limit: limit,
31-
component: limit === 1 ? 'component' : 'components',
32-
number: count
33-
});
32+
function checkLimit(callee) {
33+
count++;
34+
if (count > limit) {
35+
context.report(callee, msg, {
36+
limit: limit,
37+
component: limit === 1 ? 'component' : 'components',
38+
number: count
39+
});
40+
}
3441
}
35-
}
3642

37-
return {
38-
'angular:animation': checkLimit,
39-
'angular:config': checkLimit,
40-
'angular:controller': checkLimit,
41-
'angular:directive': checkLimit,
42-
'angular:factory': checkLimit,
43-
'angular:filter': checkLimit,
44-
'angular:provider': checkLimit,
45-
'angular:run': checkLimit,
46-
'angular:service': checkLimit,
47-
'angular:component': checkLimit
48-
};
49-
});
50-
51-
module.exports.schema = [{
52-
type: 'integer'
53-
}];
43+
return {
44+
'angular:animation': checkLimit,
45+
'angular:config': checkLimit,
46+
'angular:controller': checkLimit,
47+
'angular:directive': checkLimit,
48+
'angular:factory': checkLimit,
49+
'angular:filter': checkLimit,
50+
'angular:provider': checkLimit,
51+
'angular:run': checkLimit,
52+
'angular:service': checkLimit,
53+
'angular:component': checkLimit
54+
};
55+
})
56+
};

rules/component-name.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,51 @@
1313

1414
var utils = require('./utils/utils');
1515

16-
module.exports = function(context) {
17-
if (context.settings.angular === 2) {
18-
return {};
19-
}
16+
module.exports = {
17+
meta: {
18+
schema: [{
19+
type: ['string', 'object']
20+
}]
21+
},
22+
create: function(context) {
23+
if (context.settings.angular === 2) {
24+
return {};
25+
}
2026

21-
return {
27+
return {
2228

23-
CallExpression: function(node) {
24-
var prefix = context.options[0];
25-
var convertedPrefix; // convert string from JSON .eslintrc to regex
29+
CallExpression: function(node) {
30+
var prefix = context.options[0];
31+
var convertedPrefix; // convert string from JSON .eslintrc to regex
2632

27-
if (prefix === undefined) {
28-
return;
29-
}
33+
if (prefix === undefined) {
34+
return;
35+
}
3036

31-
convertedPrefix = utils.convertPrefixToRegex(prefix);
37+
convertedPrefix = utils.convertPrefixToRegex(prefix);
3238

33-
if (utils.isAngularComponentDeclaration(node)) {
34-
var name = node.arguments[0].value;
39+
if (utils.isAngularComponentDeclaration(node)) {
40+
var name = node.arguments[0].value;
3541

36-
if (name !== undefined && name.indexOf('ng') === 0) {
37-
context.report(node, 'The {{component}} component should not start with "ng". This is reserved for AngularJS components', {
38-
component: name
39-
});
40-
} else if (name !== undefined && !convertedPrefix.test(name)) {
41-
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
42-
context.report(node, 'The {{component}} component should be prefixed by {{prefix}}', {
43-
component: name,
44-
prefix: prefix
45-
});
46-
} else {
47-
context.report(node, 'The {{component}} component should follow this pattern: {{prefix}}', {
48-
component: name,
49-
prefix: prefix.toString()
42+
if (name !== undefined && name.indexOf('ng') === 0) {
43+
context.report(node, 'The {{component}} component should not start with "ng". This is reserved for AngularJS components', {
44+
component: name
5045
});
46+
} else if (name !== undefined && !convertedPrefix.test(name)) {
47+
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
48+
context.report(node, 'The {{component}} component should be prefixed by {{prefix}}', {
49+
component: name,
50+
prefix: prefix
51+
});
52+
} else {
53+
context.report(node, 'The {{component}} component should follow this pattern: {{prefix}}', {
54+
component: name,
55+
prefix: prefix.toString()
56+
});
57+
}
5158
}
5259
}
5360
}
54-
}
55-
};
61+
};
62+
}
5663
};

rules/constant-name.js

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,51 @@
1515
var utils = require('./utils/utils');
1616

1717

18-
module.exports = function(context) {
19-
return {
18+
module.exports = {
19+
meta: {
20+
schema: [{
21+
type: ['string', 'object']
22+
}, {
23+
type: 'object'
24+
}]
25+
},
26+
create: function(context) {
27+
return {
2028

21-
CallExpression: function(node) {
22-
var prefix = context.options[0];
23-
var convertedPrefix; // convert string from JSON .eslintrc to regex
24-
var isConstant;
29+
CallExpression: function(node) {
30+
var prefix = context.options[0];
31+
var convertedPrefix; // convert string from JSON .eslintrc to regex
32+
var isConstant;
2533

26-
if (prefix === undefined) {
27-
return;
28-
}
34+
if (prefix === undefined) {
35+
return;
36+
}
2937

30-
convertedPrefix = utils.convertPrefixToRegex(prefix);
31-
isConstant = utils.isAngularConstantDeclaration(node);
32-
33-
if (isConstant) {
34-
var name = node.arguments[0].value;
35-
36-
if (name !== undefined && name.indexOf('$') === 0) {
37-
context.report(node, 'The {{constant}} constant should not start with "$". This is reserved for AngularJS services', {
38-
constant: name
39-
});
40-
} else if (name !== undefined && !convertedPrefix.test(name)) {
41-
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
42-
context.report(node, 'The {{constant}} constant should be prefixed by {{prefix}}', {
43-
constant: name,
44-
prefix: prefix
45-
});
46-
} else {
47-
context.report(node, 'The {{constant}} constant should follow this pattern: {{prefix}}', {
48-
constant: name,
49-
prefix: prefix.toString()
38+
convertedPrefix = utils.convertPrefixToRegex(prefix);
39+
isConstant = utils.isAngularConstantDeclaration(node);
40+
41+
if (isConstant) {
42+
var name = node.arguments[0].value;
43+
44+
if (name !== undefined && name.indexOf('$') === 0) {
45+
context.report(node, 'The {{constant}} constant should not start with "$". This is reserved for AngularJS services', {
46+
constant: name
5047
});
48+
} else if (name !== undefined && !convertedPrefix.test(name)) {
49+
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
50+
context.report(node, 'The {{constant}} constant should be prefixed by {{prefix}}', {
51+
constant: name,
52+
prefix: prefix
53+
});
54+
} else {
55+
context.report(node, 'The {{constant}} constant should follow this pattern: {{prefix}}', {
56+
constant: name,
57+
prefix: prefix.toString()
58+
});
59+
}
5160
}
5261
}
5362
}
54-
}
55-
};
63+
};
64+
}
5665
};

0 commit comments

Comments
 (0)