Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@jetbrains/eslint-plugin-angular
Advanced tools
ESLint rules for your angular project with checks for best-practices, conventions or potential errors.
This repository will give access to new rules for the ESLint tool. You should use it only if you are developing an AngularJS application.
Since the 0.0.4 release, some rules defined in John Papa's Guideline have been implemented. In the description below, you will have a link to the corresponding part of the guideline, in order to have more information.
Install eslint
as a dev-dependency:
npm install --save-dev eslint
Install eslint-plugin-angular
as a dev-dependency:
npm install --save-dev eslint-plugin-angular
Use the shareable config by adding it to your .eslintrc
:
extends: plugin:angular/johnpapa
Install eslint
as a dev-dependency:
npm install --save-dev eslint
Install eslint-plugin-angular
as a dev-dependency:
npm install --save-dev eslint-plugin-angular
Enable the plugin by adding it to your .eslintrc
:
plugins:
- angular
You can also configure these rules in your .eslintrc
. All rules defined in this plugin have to be prefixed by 'angular/'
plugins:
- angular
rules:
- angular/controller_name: 0
Rules in eslint-plugin-angular are divided into several categories to help you better understand their value.
The following rules detect patterns that can lead to errors.
angular.module('myModule')
(y022)These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns..
this
in controllers (y032)$scope
in controllers (y031)$q(function(resolve, reject){})
instead of $q.deferred
$http
for controllers, filters and directives)$on
and $watch
deregistration callbacks to be saved in a variableThese rules prevent you from using deprecated angular features.
$cookies
instead of $cookieStore
$http
methods success()
and error()
These rules help you to specify several naming conventions.
Angular often provide multi ways to to something. These rules help you to define convention for your project.
inject
functions should only consist of assignments from injected values to describe block variablesfactory()
instead of service()
(y040)$scope.digest()
or $scope.apply()
These rules help you to enforce the usage of angular wrappers.
angular.element
instead of $
or jQuery
angular.isDefined
and angular.isUndefined
instead of other undefined checks$document
instead of document
(y180)angular.forEach
instead of native Array.prototype.forEach
$interval
instead of setInterval
(y181)angular.fromJson
and 'angular.toJson' instead of JSON.parse
and JSON.stringify
$log
service instead of the console
methodsangular.mock
methods directlyangular.element
objects with jQuery
or $
$timeout
instead of setTimeout
(y181)angular.isArray
instead of typeof
comparisonsangular.isDate
instead of typeof
comparisonsangular.isFunction
instead of typeof
comparisonsangular.isNumber
instead of typeof
comparisonsangular.isObject
instead of typeof
comparisonsangular.isString
instead of typeof
comparisons$window
instead of window
(y180)These rules help you avoiding misspellings.
It is an opensource project. Any help will be very useful. You can :
All development happens on the development
branch. This means all pull requests should be made to the development
branch.
If it is time to release, @Gillespie59 will bump the version in package.json
, create a Git tag and merge the development
branch into master
. @Gillespie59 will then publish the new release to the npm registry.
We appreciate contributions and the following notes will help you before you open a Pull Request.
Have a look at the existing issues. There may exist similar issues with useful information.
There are some useful references for creating new rules. Specificly useful are:
context.getScope()
.rules/<your-rule>.js
<your-rule>
is exactly the usage name in eslint configs angular/<your-rule>
angularRule
wrapper and the utils
(both in rules/utils/
) - they probably make things easier for yougulp docs
tasktest/<your-rule>.js
gulp test
coverage/lcov-report/index.html
examples/<your-rule>.js
gulp docs
task to test the examples and update the markdown documentationdocs/<your-rule>.md
gulp docs
taskindex.js
rulesConfiguration.addRule('<your-rule>', [0, {someConfig: 'someValue'}])
gulp
task is workingREADME.md
and docs/<your-rule>.md
development
branch NOT master
We can use a property, defined in the ESLint configuration file, in order to know which version is used : Angular 1 or Angular 2. based on this property, you can create rules for each version.
plugins:
- angular
rules:
angular/controller-name:
- 2
- '/[A-Z].*Controller$/'
globals:
angular: true
settings:
angular: 2
And in your rule, you can access to this property thanks to the context
object :
//If Angular 2 is used, we disabled the rule
if(context.settings.angular === 2){
return {};
}
return {
'CallExpression': function(node) {
}
};
Here is the basic configuration for the rules defined in the ESLint plugin, in order to be compatible with the guideline provided by @johnpapa :
rules:
no-use-before-define:
- 0
Emmanuel Demey | Tilman Potthof | Remco Haszing |
FAQs
ESLint rules for AngularJS projects
We found that @jetbrains/eslint-plugin-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.