Skip to content
Merged

1.6.2 #447

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
89893a1
Issue #430 the name of an angular component can be defined in a JS va…
EmmanuelDemey Dec 31, 2016
76b94f4
Update NPM packages
EmmanuelDemey Dec 31, 2016
f3b227b
Rewrite rule with the new ESLint rule module syntax
EmmanuelDemey Dec 31, 2016
b44575f
Wrong ` when linting controller-as test
EmmanuelDemey Dec 31, 2016
6843fc0
Move schema in a meta subobject. And add missing schema
EmmanuelDemey Dec 31, 2016
901f5ec
SOlve ESLint issues
EmmanuelDemey Dec 31, 2016
4a7bf82
Issue #223 and #413 no error when using config method from a dependency
EmmanuelDemey Dec 31, 2016
c68170b
Issue #425 array value throw exception
EmmanuelDemey Jan 1, 2017
0bef405
Solve ESLint issues
EmmanuelDemey Jan 1, 2017
3bf8c69
Remove travis ci semver locks node 7 support
amilajack Jan 2, 2017
818aedb
Merge pull request #433 from amilajack/patch-1
EmmanuelDemey Jan 2, 2017
aa78e48
issue 434 - $window support in timeout-service
Jan 15, 2017
564b060
issue 434 - remove not needed check
Jan 15, 2017
39d7da7
issue 434 - handle setTimeout on object which is not window or $window
Jan 15, 2017
f4c34dd
issue 434 - fix lint issues
Jan 15, 2017
f1106da
issue 434 - fix CRLF issues which caused extra lines in file
Jan 15, 2017
3b8152a
Merge pull request #435 from swar30/issue-434/support-$window-in-time…
EmmanuelDemey Jan 15, 2017
d4a390f
Update to 1.6.2
EmmanuelDemey Mar 5, 2017
df833e6
Revert "service-name warn only once if there is an oldBehavior=true"
EmmanuelDemey Mar 5, 2017
368ecb9
Merge pull request #448 from Gillespie59/revert-432-service-name-fix
EmmanuelDemey Mar 5, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- "6.0"
- "5.0"
- "4.2"
- 7
- 6
- 5
- 4
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
5 changes: 5 additions & 0 deletions docs/timeout-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ The following patterns are considered problems;
window.setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method

// invalid
$window.setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method

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

Expand Down
6 changes: 6 additions & 0 deletions examples/timeout-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ window.setTimeout(function() {
// ...
}, 1000)


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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-angular",
"version": "1.6.1",
"version": "1.6.2",
"description": "ESLint rules for AngularJS projects",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -29,10 +29,10 @@
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^2.2.0",
"gulp-mocha": "^3.0.1",
"istanbul": "^0.4.2",
"lodash": "^4.13.1",
"mocha": "^2.4.5",
"mocha": "^3.2.0",
"parse-comments": "^0.4.3",
"shelljs": "^0.7.1",
"shelljs-nodecli": "^0.1.1"
Expand Down
21 changes: 12 additions & 9 deletions rules/angularelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
*/
'use strict';

module.exports = function(context) {
return {
CallExpression: function(node) {
if (node.callee.name === '$' || node.callee.name === 'jQuery') {
context.report(node, 'You should use angular.element instead of the jQuery $ object', {});
module.exports = {
meta: {
schema: []
},
create: function(context) {
return {
CallExpression: function(node) {
if (node.callee.name === '$' || node.callee.name === 'jQuery') {
context.report(node, 'You should use angular.element instead of the jQuery $ object', {});
}
}
}
};
};
}
};

module.exports.schema = [];
63 changes: 33 additions & 30 deletions rules/component-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,39 @@
var angularRule = require('./utils/angular-rule');


module.exports = angularRule(function(context) {
var limit = context.options[0] || 1;
var count = 0;
var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}';
module.exports = {
meta: {
schema: [{
type: 'integer'
}]
},
create: angularRule(function(context) {
var limit = context.options[0] || 1;
var count = 0;
var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}';

function checkLimit(callee) {
count++;
if (count > limit) {
context.report(callee, msg, {
limit: limit,
component: limit === 1 ? 'component' : 'components',
number: count
});
function checkLimit(callee) {
count++;
if (count > limit) {
context.report(callee, msg, {
limit: limit,
component: limit === 1 ? 'component' : 'components',
number: count
});
}
}
}

return {
'angular:animation': checkLimit,
'angular:config': checkLimit,
'angular:controller': checkLimit,
'angular:directive': checkLimit,
'angular:factory': checkLimit,
'angular:filter': checkLimit,
'angular:provider': checkLimit,
'angular:run': checkLimit,
'angular:service': checkLimit,
'angular:component': checkLimit
};
});

module.exports.schema = [{
type: 'integer'
}];
return {
'angular:animation': checkLimit,
'angular:config': checkLimit,
'angular:controller': checkLimit,
'angular:directive': checkLimit,
'angular:factory': checkLimit,
'angular:filter': checkLimit,
'angular:provider': checkLimit,
'angular:run': checkLimit,
'angular:service': checkLimit,
'angular:component': checkLimit
};
})
};
67 changes: 37 additions & 30 deletions rules/component-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,51 @@

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

module.exports = function(context) {
if (context.settings.angular === 2) {
return {};
}
module.exports = {
meta: {
schema: [{
type: ['string', 'object']
}]
},
create: function(context) {
if (context.settings.angular === 2) {
return {};
}

return {
return {

CallExpression: function(node) {
var prefix = context.options[0];
var convertedPrefix; // convert string from JSON .eslintrc to regex
CallExpression: function(node) {
var prefix = context.options[0];
var convertedPrefix; // convert string from JSON .eslintrc to regex

if (prefix === undefined) {
return;
}
if (prefix === undefined) {
return;
}

convertedPrefix = utils.convertPrefixToRegex(prefix);
convertedPrefix = utils.convertPrefixToRegex(prefix);

if (utils.isAngularComponentDeclaration(node)) {
var name = node.arguments[0].value;
if (utils.isAngularComponentDeclaration(node)) {
var name = node.arguments[0].value;

if (name !== undefined && name.indexOf('ng') === 0) {
context.report(node, 'The {{component}} component should not start with "ng". This is reserved for AngularJS components', {
component: name
});
} else if (name !== undefined && !convertedPrefix.test(name)) {
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
context.report(node, 'The {{component}} component should be prefixed by {{prefix}}', {
component: name,
prefix: prefix
});
} else {
context.report(node, 'The {{component}} component should follow this pattern: {{prefix}}', {
component: name,
prefix: prefix.toString()
if (name !== undefined && name.indexOf('ng') === 0) {
context.report(node, 'The {{component}} component should not start with "ng". This is reserved for AngularJS components', {
component: name
});
} else if (name !== undefined && !convertedPrefix.test(name)) {
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
context.report(node, 'The {{component}} component should be prefixed by {{prefix}}', {
component: name,
prefix: prefix
});
} else {
context.report(node, 'The {{component}} component should follow this pattern: {{prefix}}', {
component: name,
prefix: prefix.toString()
});
}
}
}
}
}
};
};
}
};
71 changes: 40 additions & 31 deletions rules/constant-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,51 @@
var utils = require('./utils/utils');


module.exports = function(context) {
return {
module.exports = {
meta: {
schema: [{
type: ['string', 'object']
}, {
type: 'object'
}]
},
create: function(context) {
return {

CallExpression: function(node) {
var prefix = context.options[0];
var convertedPrefix; // convert string from JSON .eslintrc to regex
var isConstant;
CallExpression: function(node) {
var prefix = context.options[0];
var convertedPrefix; // convert string from JSON .eslintrc to regex
var isConstant;

if (prefix === undefined) {
return;
}
if (prefix === undefined) {
return;
}

convertedPrefix = utils.convertPrefixToRegex(prefix);
isConstant = utils.isAngularConstantDeclaration(node);

if (isConstant) {
var name = node.arguments[0].value;

if (name !== undefined && name.indexOf('$') === 0) {
context.report(node, 'The {{constant}} constant should not start with "$". This is reserved for AngularJS services', {
constant: name
});
} else if (name !== undefined && !convertedPrefix.test(name)) {
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
context.report(node, 'The {{constant}} constant should be prefixed by {{prefix}}', {
constant: name,
prefix: prefix
});
} else {
context.report(node, 'The {{constant}} constant should follow this pattern: {{prefix}}', {
constant: name,
prefix: prefix.toString()
convertedPrefix = utils.convertPrefixToRegex(prefix);
isConstant = utils.isAngularConstantDeclaration(node);

if (isConstant) {
var name = node.arguments[0].value;

if (name !== undefined && name.indexOf('$') === 0) {
context.report(node, 'The {{constant}} constant should not start with "$". This is reserved for AngularJS services', {
constant: name
});
} else if (name !== undefined && !convertedPrefix.test(name)) {
if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
context.report(node, 'The {{constant}} constant should be prefixed by {{prefix}}', {
constant: name,
prefix: prefix
});
} else {
context.report(node, 'The {{constant}} constant should follow this pattern: {{prefix}}', {
constant: name,
prefix: prefix.toString()
});
}
}
}
}
}
};
};
}
};
Loading