Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
angular-enforcer
Advanced tools
Command line script to lint style rules in Angular templates and automatically correct them
Command line script to lint style rules in Angular templates and automatically correct them. Can be used on any HTML file, not just Angular templates.
from:
<div>
<div>
<span>
<img>
to:
<div>
<div>
<span>
<img>
</span>
</div>
</div>
from:
<B>BOLD TEXT</B>
to:
<b>
BOLD TEXT
</b>
npm install angular-enforcer -g
enforce [file path] [options]
where [file path] is a path to a file to enforce
cat [file path] | enforce -i
Simply pipe some file into the enforce command
enforce -g [glob string] [options]
where [glob string] node-glob is a string to search for files using
Ex: enforce -g src/folder/**/*.tpl
enforce -g [options]
This will run the angular-enforcer program on every html file in this folder and all child folders
You can also import angular-enforcer and use it as you want.
import ngEnforcer from 'angular-enforcer';
import 'fs';
const file = fs.readFileSync('file');
const output = ngEnforcer(file, {
lineLength: 150
});
The ngEnforce function takes a string of HTML and options and returns formatted HTML. Linting is not available when using this method.
Formatting options:
--tab-length : the number of spaces to consider a tab. Default is 4.
--spaces : If true (default), converts spaces to tabs, using the specified tab length. Otherwise it does the reverse, converting tabs to spaces.
--line-length : max line length. Default is 100.
--closing-slash : if true, convert
to
. Default is false.
--short-tags : comma separated list of additional tags that have no associated end tag
--expr-padding : add a space before and after angular expressions (and a space after the "::" in one-time binded expressions). Default is true.
--attr-newline : If an html start tag is over the specified line-length, start each attribute on it's own line, indenting by one. Default is true.
--empty-tag-same-line : Empty DOM nodes will end their tags on the same line if it's within the max line length.
--short-text-nodes : DOM nodes with just text that can fit on one line will do so. Default is true. If this is false, the text nodes will be indented.
--attr-obj-indent: Indent JS objects inside attributes, ex: inside ng-class. True by default.
--double-quotes : If true, use double quotes for attributes, otherwise use single quotes.
--reorder-attrs : If true, alphabetize HTML attributes in each tag
--block-spacing : If true, add an empty line in between each HTML block
--text-wrap : If true, break long text nodes so that indentation + length of text <= line-length. Defaults to true.
--wrap-ignored-tags : comma separated list of tags to ignore long text nodes inside
--remove-comments : if true, enforcer will remove all HTML comments
CLI-only options: --config -c : path to the formatting config file. Default is .enforcer.json --save -S : report and correct all problems, overwriting all affected files --glob -g : Glob strings to look for files --stdin -i : read from STDIN instead of giving a file path. --verbose -v : more verbose reporting, including locations of problems. --quite -q : silences all output, even when using --diff or --verbose. --diff -d : print a colored diff of the changes
All options can be specified in an .enforcer.json file. All options are in camelCase.
{
"tabLength": 2,
"lineLength": 120
}
<input class="foobar"
bar="baz">
FAQs
Command line script to lint style rules in Angular templates and automatically correct them
The npm package angular-enforcer receives a total of 2 weekly downloads. As such, angular-enforcer popularity was classified as not popular.
We found that angular-enforcer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.