{"id":41591,"library":"nginx-linter","title":"nginx-linter","description":"A CLI tool for linting and formatting Nginx configuration files, version 0.7.0. It validates style and common pitfalls with built-in rules such as 'if-is-evil', indentation enforcement, line-ending consistency, location ordering, and trailing whitespace checks. Requires Node 18+. Designed for DevOps workflows, it offers opinionated defaults but is configurable. Compared to alternatives like gixy, it focuses on style and best practices rather than security analysis.","status":"active","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/jhinch/nginx-linter","tags":["javascript","nginx","linter"],"install":[{"cmd":"npm install nginx-linter","lang":"bash","label":"npm"},{"cmd":"yarn add nginx-linter","lang":"bash","label":"yarn"},{"cmd":"pnpm add nginx-linter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v0.7.0. Named export.","wrong":"const Linter = require('nginx-linter').Linter","symbol":"Linter","correct":"import { Linter } from 'nginx-linter'"},{"note":"Default export is available in ESM, but not CommonJS.","wrong":"const nginxLinter = require('nginx-linter')","symbol":"default","correct":"import nginxLinter from 'nginx-linter'"},{"note":"CLI function for programmatic use when not using the command line.","wrong":null,"symbol":"cli","correct":"import { cli } from 'nginx-linter'"},{"note":"Type-only import for TypeScript users.","wrong":"import { LinterOptions } from 'nginx-linter'","symbol":"LinterOptions","correct":"import type { LinterOptions } from 'nginx-linter'"}],"quickstart":{"code":"# Install globally\nnpm install -g nginx-linter\n\n# Lint default Nginx config\nnginx-linter /path/to/nginx.conf\n\n# With options: indentation 2 spaces, line-ending lf\nnginx-linter --indentation 2 --line-ending lf /etc/nginx/nginx.conf","lang":"bash","description":"Installation and basic usage of nginx-linter to lint an Nginx configuration file."},"warnings":[{"fix":"Upgrade to Node 18 or later.","message":"v0.7.0 drops Node 16 support; requires Node 18+","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Always specify a path or use custom config via --config-file.","message":"Default config path is /etc/nginx/ which may not exist on non-Linux systems","severity":"gotcha","affected_versions":"<0.7.0"},{"fix":"Set if-is-evil rule to 'none' or adjust mode in .nginx-linterrc.","message":"If-is-evil rule may reject perfectly safe 'if' usage in rewrites or named locations","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use 'trailing-whitespace: warning' or remove from config.","message":"Trailing whitespace rule deprecated in favor of general style rules starting v0.6.0","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.7.0':15 '18':47 'altern':61 'analysi':74 'best':69 'built':24 'built-in':23 'check':44 'cli':5 'common':20 'compar':59 'configur':12,58 'consist':38 'default':55 'design':48 'devop':50 'end':37 'enforc':34 'evil':32 'file':13 'focus':65 'format':10 'gixi':63 'if-is-evil':29 'indent':33 'javascript':75 'like':62 'line':36 'line-end':35 'lint':8 'linter':3,77 'locat':39 'nginx':2,11,76 'nginx-lint':1 'node':46 'offer':53 'opinion':54 'order':40 'pitfal':21 'practic':70 'rather':71 'requir':45 'rule':26 'secur':73 'style':18,67 'tool':6 'trail':42 'valid':17 'version':14 'whitespac':43 'workflow':51","created_at":"2026-06-04T18:53:09.492465+00:00","updated_at":"2026-06-04T18:53:09.492465+00:00","problems":[{"fix":"Run 'npm install -g nginx-linter' or add to project dependencies.","cause":"Package not installed or not in NODE_PATH","error":"Error: Cannot find module 'nginx-linter'"},{"fix":"Add 'type': 'module' to package.json or use dynamic import.","cause":"ESM export used in CommonJS context without type: module","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Use '--indentation' instead of '--indent'.","cause":"Wrong option name, correct is --indentation","error":"nginx-linter: error: unknown option '--indent'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jhinch/nginx-linter#readme","github":"https://github.com/jhinch/nginx-linter","docs":null,"changelog":null,"pypi":null,"npm":"nginx-linter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}