Socket
Socket
Sign inDemoInstall

eslint-plugin-angular

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-angular - npm Package Compare versions

Comparing version 3.0.0 to 3.0.2

backup/component-limit.js

4

gulpfile.js

@@ -30,8 +30,8 @@ 'use strict';

gulp.task('docs', function(cb) {
gulp.task('docs', function() {
docs.updateReadme('README.md');
docs.createDocFiles();
docs.testDocs(cb);
// docs.testDocs(cb);
});
gulp.task('default', ['quality', 'docs', 'test']);
{
"name": "eslint-plugin-angular",
"version": "3.0.0",
"version": "3.0.2",
"description": "ESLint rules for AngularJS projects",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -95,6 +95,6 @@ # eslint plugin angular [![Npm version](https://img.shields.io/npm/v/eslint-plugin-angular.svg)](https://www.npmjs.com/package/eslint-plugin-angular) [![Npm downloads per month](https://img.shields.io/npm/dm/eslint-plugin-angular.svg)](https://www.npmjs.com/package/eslint-plugin-angular)

* [avoid-scope-typos](docs/avoid-scope-typos.md) - Avoid mistakes when naming methods defined on the scope object
* [module-getter](docs/module-getter.md) - disallow to reference modules with variables and require to use the getter syntax instead `angular.module('myModule')` ([y022](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y022))
* [module-setter](docs/module-setter.md) - disallow to assign modules to variables (linked to [module-getter](docs/module-getter.md) ([y021](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y021))
* [no-private-call](docs/no-private-call.md) - disallow use of internal angular properties prefixed with $$
* [avoid-scope-typos](docs/rules/avoid-scope-typos.md) - Avoid mistakes when naming methods defined on the scope object
* [module-getter](docs/rules/module-getter.md) - disallow to reference modules with variables and require to use the getter syntax instead `angular.module('myModule')` ([y022](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y022))
* [module-setter](docs/rules/module-setter.md) - disallow to assign modules to variables (linked to [module-getter](docs/module-getter.md) ([y021](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y021))
* [no-private-call](docs/rules/no-private-call.md) - disallow use of internal angular properties prefixed with $$

@@ -105,16 +105,16 @@ ### Best Practices

* [component-limit](docs/component-limit.md) - limit the number of angular components per file ([y001](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y001))
* [controller-as-route](docs/controller-as-route.md) - require the use of controllerAs in routes or states ([y031](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y031))
* [controller-as-vm](docs/controller-as-vm.md) - require and specify a capture variable for `this` in controllers ([y032](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y032))
* [controller-as](docs/controller-as.md) - disallow assignments to `$scope` in controllers ([y031](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y031))
* [deferred](docs/deferred.md) - use `$q(function(resolve, reject){})` instead of `$q.deferred`
* [di-unused](docs/di-unused.md) - disallow unused DI parameters
* [directive-restrict](docs/directive-restrict.md) - disallow any other directive restrict than 'A' or 'E' ([y074](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y074))
* [empty-controller](docs/empty-controller.md) - disallow empty controllers
* [no-controller](docs/no-controller.md) - disallow use of controllers (according to the component first pattern)
* [no-inline-template](docs/no-inline-template.md) - disallow the use of inline templates
* [no-run-logic](docs/no-run-logic.md) - keep run functions clean and simple ([y171](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y171))
* [no-services](docs/no-services.md) - disallow DI of specified services for other angular components (`$http` for controllers, filters and directives)
* [on-watch](docs/on-watch.md) - require `$on` and `$watch` deregistration callbacks to be saved in a variable
* [prefer-component](docs/prefer-component.md) -
* [component-limit](docs/rules/component-limit.md) - limit the number of angular components per file ([y001](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y001))
* [controller-as-route](docs/rules/controller-as-route.md) - require the use of controllerAs in routes or states ([y031](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y031))
* [controller-as-vm](docs/rules/controller-as-vm.md) - require and specify a capture variable for `this` in controllers ([y032](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y032))
* [controller-as](docs/rules/controller-as.md) - disallow assignments to `$scope` in controllers ([y031](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y031))
* [deferred](docs/rules/deferred.md) - use `$q(function(resolve, reject){})` instead of `$q.deferred`
* [di-unused](docs/rules/di-unused.md) - disallow unused DI parameters
* [directive-restrict](docs/rules/directive-restrict.md) - disallow any other directive restrict than 'A' or 'E' ([y074](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y074))
* [empty-controller](docs/rules/empty-controller.md) - disallow empty controllers
* [no-controller](docs/rules/no-controller.md) - disallow use of controllers (according to the component first pattern)
* [no-inline-template](docs/rules/no-inline-template.md) - disallow the use of inline templates
* [no-run-logic](docs/rules/no-run-logic.md) - keep run functions clean and simple ([y171](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y171))
* [no-services](docs/rules/no-services.md) - disallow DI of specified services for other angular components (`$http` for controllers, filters and directives)
* [on-watch](docs/rules/on-watch.md) - require `$on` and `$watch` deregistration callbacks to be saved in a variable
* [prefer-component](docs/rules/prefer-component.md) -

@@ -125,5 +125,5 @@ ### Deprecated Angular Features

* [no-cookiestore](docs/no-cookiestore.md) - use `$cookies` instead of `$cookieStore`
* [no-directive-replace](docs/no-directive-replace.md) - disallow the deprecated directive replace property
* [no-http-callback](docs/no-http-callback.md) - disallow the `$http` methods `success()` and `error()`
* [no-cookiestore](docs/rules/no-cookiestore.md) - use `$cookies` instead of `$cookieStore`
* [no-directive-replace](docs/rules/no-directive-replace.md) - disallow the deprecated directive replace property
* [no-http-callback](docs/rules/no-http-callback.md) - disallow the `$http` methods `success()` and `error()`

@@ -134,13 +134,13 @@ ### Naming

* [component-name](docs/component-name.md) - require and specify a prefix for all component names
* [constant-name](docs/constant-name.md) - require and specify a prefix for all constant names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [controller-name](docs/controller-name.md) - require and specify a prefix for all controller names ([y123](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y123), [y124](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y124))
* [directive-name](docs/directive-name.md) - require and specify a prefix for all directive names ([y073](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y073), [y126](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y126))
* [factory-name](docs/factory-name.md) - require and specify a prefix for all factory names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [file-name](docs/file-name.md) - require and specify a consistent component name pattern ([y120](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y120), [y121](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y121))
* [filter-name](docs/filter-name.md) - require and specify a prefix for all filter names
* [module-name](docs/module-name.md) - require and specify a prefix for all module names ([y127](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y127))
* [provider-name](docs/provider-name.md) - require and specify a prefix for all provider names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [service-name](docs/service-name.md) - require and specify a prefix for all service names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [value-name](docs/value-name.md) - require and specify a prefix for all value names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [component-name](docs/rules/component-name.md) - require and specify a prefix for all component names
* [constant-name](docs/rules/constant-name.md) - require and specify a prefix for all constant names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [controller-name](docs/rules/controller-name.md) - require and specify a prefix for all controller names ([y123](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y123), [y124](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y124))
* [directive-name](docs/rules/directive-name.md) - require and specify a prefix for all directive names ([y073](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y073), [y126](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y126))
* [factory-name](docs/rules/factory-name.md) - require and specify a prefix for all factory names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [file-name](docs/rules/file-name.md) - require and specify a consistent component name pattern ([y120](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y120), [y121](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y121))
* [filter-name](docs/rules/filter-name.md) - require and specify a prefix for all filter names
* [module-name](docs/rules/module-name.md) - require and specify a prefix for all module names ([y127](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y127))
* [provider-name](docs/rules/provider-name.md) - require and specify a prefix for all provider names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [service-name](docs/rules/service-name.md) - require and specify a prefix for all service names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))
* [value-name](docs/rules/value-name.md) - require and specify a prefix for all value names ([y125](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y125))

@@ -151,11 +151,11 @@ ### Conventions

* [di-order](docs/di-order.md) - require DI parameters to be sorted alphabetically
* [di](docs/di.md) - require a consistent DI syntax
* [dumb-inject](docs/dumb-inject.md) - unittest `inject` functions should only consist of assignments from injected values to describe block variables
* [function-type](docs/function-type.md) - require and specify a consistent function style for components ('named' or 'anonymous') ([y024](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y024))
* [module-dependency-order](docs/module-dependency-order.md) - require a consistent order of module dependencies
* [no-service-method](docs/no-service-method.md) - use `factory()` instead of `service()` ([y040](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y040))
* [one-dependency-per-line](docs/one-dependency-per-line.md) - require all DI parameters to be located in their own line
* [rest-service](docs/rest-service.md) - disallow different rest service and specify one of '$http', '$resource', 'Restangular'
* [watchers-execution](docs/watchers-execution.md) - require and specify consistent use `$scope.digest()` or `$scope.apply()`
* [di-order](docs/rules/di-order.md) - require DI parameters to be sorted alphabetically
* [di](docs/rules/di.md) - require a consistent DI syntax
* [dumb-inject](docs/rules/dumb-inject.md) - unittest `inject` functions should only consist of assignments from injected values to describe block variables
* [function-type](docs/rules/function-type.md) - require and specify a consistent function style for components ('named' or 'anonymous') ([y024](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y024))
* [module-dependency-order](docs/rules/module-dependency-order.md) - require a consistent order of module dependencies
* [no-service-method](docs/rules/no-service-method.md) - use `factory()` instead of `service()` ([y040](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y040))
* [one-dependency-per-line](docs/rules/one-dependency-per-line.md) - require all DI parameters to be located in their own line
* [rest-service](docs/rules/rest-service.md) - disallow different rest service and specify one of '$http', '$resource', 'Restangular'
* [watchers-execution](docs/rules/watchers-execution.md) - require and specify consistent use `$scope.digest()` or `$scope.apply()`

@@ -166,19 +166,19 @@ ### Angular Wrappers

* [angularelement](docs/angularelement.md) - use `angular.element` instead of `$` or `jQuery`
* [definedundefined](docs/definedundefined.md) - use `angular.isDefined` and `angular.isUndefined` instead of other undefined checks
* [document-service](docs/document-service.md) - use `$document` instead of `document` ([y180](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y180))
* [foreach](docs/foreach.md) - use `angular.forEach` instead of native `Array.prototype.forEach`
* [interval-service](docs/interval-service.md) - use `$interval` instead of `setInterval` ([y181](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y181))
* [json-functions](docs/json-functions.md) - use `angular.fromJson` and 'angular.toJson' instead of `JSON.parse` and `JSON.stringify`
* [log](docs/log.md) - use the `$log` service instead of the `console` methods
* [no-angular-mock](docs/no-angular-mock.md) - require to use `angular.mock` methods directly
* [no-jquery-angularelement](docs/no-jquery-angularelement.md) - disallow to wrap `angular.element` objects with `jQuery` or `$`
* [timeout-service](docs/timeout-service.md) - use `$timeout` instead of `setTimeout` ([y181](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y181))
* [typecheck-array](docs/typecheck-array.md) - use `angular.isArray` instead of `typeof` comparisons
* [typecheck-date](docs/typecheck-date.md) - use `angular.isDate` instead of `typeof` comparisons
* [typecheck-function](docs/typecheck-function.md) - use `angular.isFunction` instead of `typeof` comparisons
* [typecheck-number](docs/typecheck-number.md) - use `angular.isNumber` instead of `typeof` comparisons
* [typecheck-object](docs/typecheck-object.md) - use `angular.isObject` instead of `typeof` comparisons
* [typecheck-string](docs/typecheck-string.md) - use `angular.isString` instead of `typeof` comparisons
* [window-service](docs/window-service.md) - use `$window` instead of `window` ([y180](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y180))
* [angularelement](docs/rules/angularelement.md) - use `angular.element` instead of `$` or `jQuery`
* [definedundefined](docs/rules/definedundefined.md) - use `angular.isDefined` and `angular.isUndefined` instead of other undefined checks
* [document-service](docs/rules/document-service.md) - use `$document` instead of `document` ([y180](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y180))
* [foreach](docs/rules/foreach.md) - use `angular.forEach` instead of native `Array.prototype.forEach`
* [interval-service](docs/rules/interval-service.md) - use `$interval` instead of `setInterval` ([y181](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y181))
* [json-functions](docs/rules/json-functions.md) - use `angular.fromJson` and 'angular.toJson' instead of `JSON.parse` and `JSON.stringify`
* [log](docs/rules/log.md) - use the `$log` service instead of the `console` methods
* [no-angular-mock](docs/rules/no-angular-mock.md) - require to use `angular.mock` methods directly
* [no-jquery-angularelement](docs/rules/no-jquery-angularelement.md) - disallow to wrap `angular.element` objects with `jQuery` or `$`
* [timeout-service](docs/rules/timeout-service.md) - use `$timeout` instead of `setTimeout` ([y181](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y181))
* [typecheck-array](docs/rules/typecheck-array.md) - use `angular.isArray` instead of `typeof` comparisons
* [typecheck-date](docs/rules/typecheck-date.md) - use `angular.isDate` instead of `typeof` comparisons
* [typecheck-function](docs/rules/typecheck-function.md) - use `angular.isFunction` instead of `typeof` comparisons
* [typecheck-number](docs/rules/typecheck-number.md) - use `angular.isNumber` instead of `typeof` comparisons
* [typecheck-object](docs/rules/typecheck-object.md) - use `angular.isObject` instead of `typeof` comparisons
* [typecheck-string](docs/rules/typecheck-string.md) - use `angular.isString` instead of `typeof` comparisons
* [window-service](docs/rules/window-service.md) - use `$window` instead of `window` ([y180](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y180))

@@ -189,3 +189,3 @@ ### Misspelling

* [on-destroy](docs/on-destroy.md) - Check for common misspelling $on('destroy', ...).
* [on-destroy](docs/rules/on-destroy.md) - Check for common misspelling $on('destroy', ...).

@@ -192,0 +192,0 @@

@@ -16,2 +16,4 @@ /**

const scope = ['scope', '$scope', '$rootScope'];
module.exports = {

@@ -23,3 +25,3 @@ meta: {

function check(node, name) {
if (bad.indexOf(name) >= 0) {
if (bad.indexOf(name) >= 0 && scope.indexOf(node.parent.object.name) >= 0) {
context.report(node, `The ${name} method should be replaced by $${name}, or you should rename it in order to avoid confusions`, {});

@@ -26,0 +28,0 @@ }

@@ -56,2 +56,20 @@ /**

});
if (!directiveNode) {
// Try to find an ancestor function used as definition for one of the found directives
context.getAncestors().some(function(ancestor) {
if (isFunctionDeclaration(ancestor)) {
var fnName = ancestor.id.name;
var correspondingDirective = foundDirectives.find(function(directive) {
var directiveFnName = getDirectiveFunctionName(directive);
return directiveFnName === fnName;
});
directiveNode = correspondingDirective;
return true;
}
});
}
// The restrict property was not defined inside of a directive.

@@ -75,2 +93,30 @@ if (!directiveNode) {

function isFunctionDeclaration(node) {
return node.type === 'FunctionDeclaration';
}
function getDirectiveFunctionName(node) {
var directiveArg = node.arguments[1];
// Three ways of creating a directive function: function expression,
// variable name that references a function, and an array with a function
// as the last item
if (utils.isFunctionType(directiveArg)) {
return directiveArg.id.name;
}
if (utils.isArrayType(directiveArg)) {
directiveArg = directiveArg.elements[directiveArg.elements.length - 1];
if (utils.isIdentifierType(directiveArg)) {
return directiveArg.name;
}
return directiveArg.id.name;
}
if (utils.isIdentifierType(directiveArg)) {
return directiveArg.name;
}
}
return {

@@ -77,0 +123,0 @@ CallExpression: function(node) {

@@ -7,3 +7,7 @@ /**

* You can not prefix your services by "$" (reserved keyword for AngularJS services) ("service-name": [2, "ng"])
**
*
* If the oldBehavior is true (default value), this rule will check the name of all services defined with the different methods
* provided by the framework : provider, service, factory, ... If this parameter is false, only services defined with the
* service method will be checked.
*
* @styleguideReference {johnpapa} `y125` Naming - Factory and Service Names

@@ -10,0 +14,0 @@ * @version 0.1.0

@@ -8,3 +8,3 @@ 'use strict';

ruleSourcePath: _.template('rules/<%= ruleName %>.js'),
ruleDocumentationPath: _.template('docs/<%= ruleName %>.md'),
ruleDocumentationPath: _.template('docs/rules/<%= ruleName %>.md'),
ruleExamplesPath: _.template('examples/<%= ruleName %>.js'),

@@ -11,0 +11,0 @@ styleguide: _.template('[<%= name %> by <%= type %> - <%= description %>](<%= link %>)'),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc