$ cnpm install @hint/hint-no-http-redirects
no-http-redirects)no-http-redirects checks if there are any HTTP redirects in the page
webhint is analyzing.
Consider the following simplified description of what happens when a user requests a URL within a browser:
When a redirect occurs, 3. contains the new URL the browser needs to
request, repeating the whole sequence of steps. DNS Lookup isn’t cheap,
neither is creating a TCP connection. The
impact of redirects is felt even more by mobile users, where the network
latency is usually higher.
As a rule of thumb, the more you can avoid redirects the better.
This hint checks:
webhint has any redirect. E.g.:
http://www.example.com --> http://example.comhttp://example.com/script.js --> https://example.com/script.jsand alerts if at least one is found.
webhint that redirects to another oneBy default, no redirects are allowed but you can change this behavior.
The following hint configuration used in the .hintrc
file will allow 3 redirects for resources and 1 for the main URL:
{
"connector": {...},
"formatters": [...],
"hints": {
"no-http-redirects": ["error", {
"max-resource-redirects": 3,
"max-html-redirects": 1
}],
...
},
...
}
This package is installed automatically by webhint:
npm install hint --save-dev
To use it, activate it via the .hintrc configuration file:
{
"connector": {...},
"formatters": [...],
"hints": {
"no-http-redirects": "error",
...
},
"parsers": [...],
...
}
Note: The recommended way of running webhint is as a devDependency of
your project.
Copyright 2013 - present © cnpmjs.org | Home |