nginx-linter
nginx-linter copied to clipboard
More style related warnings
These are just suggestions. Feel free to close or disregard if it's invalid.
Currently the linter warns about incorrect indentation levels and trailing spaces. I've been looking at example configurations from nginx to see if there is some common style guidelines that could be added.
1. One space before the opening brace.
events {
worker_connections 4096; ## Default: 1024
}
Warn when it isn't.
events{
2. One space between if parameters.
if ($true) {
add_header X-First 1;
}
Warn when there are multiple spaces.
if ($true) {
add_header X-First 1;
}
3. Comments uses space.
# A comment.
Warn when it itsn't
#A comment.
4. One newline between blocks
upstream big_server_com {
server 127.0.0.3:8000 weight=5;
}
server { # simple load balancing
listen 80;
}
Warn when there are none or multiple:
upstream big_server_com {
server 127.0.0.3:8000 weight=5;
}
server { # simple load balancing
listen 80;
}
upstream big_server_com {
server 127.0.0.3:8000 weight=5;
}
server { # simple load balancing
listen 80;
}
5. location regexes should use space between modifier and regex.
location ~* ^/if-and-alias/
Warn:
location ~*^/if-and-alias/
The example without space currently produces another warning, see #24