princejwesley / ng-attr-hint

A static linting tool for angular ng directives

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ng-attr-hint

npm version license npm

A static linting tool for angular ng directives.

Usage

Install from npm

npm install ng-attr-hint

var ngAttrHint = require('ng-attr-hint');

// callback
ngAttrHint({
	files: ['./*.html']
}, function(err, res) {
	if(err) console.error(err);
	else  {
		ngAttrHint.format(data).forEach(function(o) {
			console.log(o)
		});
	}
});

// promise
ngAttrHint({
	files: ['./*.html']
}).then(function(data) {
	ngAttrHint.format(data).forEach(function(o) {
		console.log(o)
	});
}, function(err) {
	console.error(err)
});

Output of Gulp task

ng-attr-hint

API

function(options, callback)

Constructor which takes options and an optional callback. if callback is not provided, function will return a promise instance.

Parameters:

options
  {
    files: "glob filename-pattern" || [glob filename-pattern],
		data: "content"
  }

callback
  Optional function which will be used to return the array of hint object.

function format(hints, formatPattern)

format the hint object to array of strings

Parameters:

hints
  Output of ngAttrHint (An array of hint objects)
formatPattern
  Optional Paramater. formatPattern, if provided, will be used for formatting.
  Use '{field}' to interpolate hint object.
  Default pattern : '[{file}:{line}] [{type}] ({attrs}) {message}'

ngAttrHint object format:

{
  file: string,
  line: number,
  type: string,
  attrs: [string],
  message: string
}

Plugins

Gulp task

Grunt Plugin

Atom Package

atom-ng-attr-hint

TODOs

  • Unit tests
  • demo page

License

This plugin is licensed under the MIT license.

Copyright (c) 2015 Prince John Wesley

About

A static linting tool for angular ng directives

License:MIT License


Languages

Language:JavaScript 100.0%