eslint-plugin-mso-conditionals
ESLint plugin for validating MSO (Outlook) conditional comments in HTML email.
Extracts <!--[if mso]> … <![endif]--> blocks from HTML files and lints them for valid syntax and matched pairs using a custom processor and AST parser.
Installation
npm install eslint-plugin-mso-conditionals --save-dev
Requires ESLint 9+ (flat config) and Node.js 18+.
Quick Start
import msoConditionals from 'eslint-plugin-mso-conditionals';
export default [
...msoConditionals.configs.recommended,
];
This lints MSO conditional comments inside **/*.html, **/*.amp, and **/*.ampscript files.
VS Code Setup
To see eslint(mso-conditionals/...) diagnostics inline in VS Code, the ESLint extension must be configured to validate HTML files:
{
"eslint.validate": ["html", "javascript"]
}
The MSO Conditional Comments VS Code extension provides the same diagnostics without requiring ESLint. Use this plugin when you want linting in CI or in editors other than VS Code.
Rules
Processor
mso-conditionals/html | **/*.html, **/*.amp, **/*.ampscript | Extracts MSO conditional comment strings for linting |
The processor emits a virtual .mso file per source file containing one MSO comment per line, preserving line offsets so reported locations map back to the original file.
Config
msoConditionals.configs.recommended
An array of two flat config objects:
- Processor config — registers
mso-conditionals/html on HTML/AMP files.
- Rules config — applies
valid-mso-condition and matching-mso-endif at error severity on the extracted .mso virtual files.
Spread it in your config:
export default [
...msoConditionals.configs.recommended,
];
To adjust severity, override individual rules after spreading:
export default [
...msoConditionals.configs.recommended,
{
rules: {
'mso-conditionals/matching-mso-endif': 'warn',
},
},
];
License
MIT