https://github.com/barzik/eslint-plugin-angular-component-api
Eslint rule for Angular 1.X components API enforcement
https://github.com/barzik/eslint-plugin-angular-component-api
eslint-plugin node-js
Last synced: about 2 months ago
JSON representation
Eslint rule for Angular 1.X components API enforcement
- Host: GitHub
- URL: https://github.com/barzik/eslint-plugin-angular-component-api
- Owner: barzik
- License: mit
- Created: 2017-10-22T08:41:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T11:35:10.000Z (over 8 years ago)
- Last Synced: 2025-09-21T22:44:01.979Z (9 months ago)
- Topics: eslint-plugin, node-js
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-angular-component-api [](https://travis-ci.org/barzik/eslint-plugin-angular-component-api)
API tester for Angular components. Making sure that Angular V 1.X has the API that we want to use.
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm i eslint --save-dev
```
Next, install `eslint-plugin-angular-component-api`:
```
$ npm install eslint-plugin-angular-component-api --save-dev
```
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-angular-component-api` globally.
## Usage
Add `angular-component-api` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": [
"angular-component-api"
]
}
```
Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"angular-component-api/angular-component-api-name": [2, {musthaves: ["nameOfAPIAttribute"]}]
}
}
```
## Supported Rules
* angular-component-api-name - Making sure that `options` is included in the component API. Or any other attributes listed in the `musthaves`. For example in component defintion The linter wukk oass if options is defined.
Examples of incorrect code for this rule with the default { "musthaves": ["nameOfAPIAttribute] } option:
```
import controller from './some-controller.js';
export default {
bindings: {
name: '@',
ngModel: '=',
ngFieldRequired: '=',
},
controller,
template: require('./some.html'),
...
};
```
```
import controller from './some-controller.js';
export default {
controller,
template: require('./some.html'),
...
};
```
Examples of correct code for this rule with the default { "musthaves": ["nameOfAPIAttribute] } option:
```
import controller from './some-controller.js';
export default {
bindings: {
name: '@',
ngModel: '=',
ngFieldRequired: '=',
options: '=',
},
controller,
template: require('./some.html'),
...
};
```
```
import controller from './some-controller.js';
export default {
bindings: {
options: '=',
},
...
};
```
# License
Licensed under the terms of the MIT license. See LICENSE file in component-api-linter for terms.