Swc Config Validator

Other

Validate SWC config files (.swcrc, package.json#swc) for parser settings, transform conflicts, module type issues, and best practices. Use when validating SWC transpiler configs, auditing Next.js/Turbopack build setups, or linting swc config files.

Install

openclaw skills install swc-config-validator

SWC Config Validator

Validate .swcrc and package.json#swc for parser errors, invalid targets, transform conflicts, module type issues, minification problems, and best practices. Supports text, JSON, and summary output formats with CI-friendly exit codes.

Commands

# Full validation (all 22+ rules)
python3 scripts/swc_config_validator.py validate .swcrc

# Quick syntax/structure check only
python3 scripts/swc_config_validator.py check .swcrc

# Explain config in human-readable form
python3 scripts/swc_config_validator.py explain .swcrc

# Suggest improvements
python3 scripts/swc_config_validator.py suggest .swcrc

# JSON output (CI-friendly)
python3 scripts/swc_config_validator.py validate .swcrc --format json

# Summary only (pass/fail + counts)
python3 scripts/swc_config_validator.py validate .swcrc --format summary

# Strict mode (warnings become errors)
python3 scripts/swc_config_validator.py validate .swcrc --strict

# Validate from package.json#swc
python3 scripts/swc_config_validator.py validate package.json

Rules (22+)

#CategorySeverityRule
S1StructureErrorFile not found or unreadable
S2StructureErrorEmpty config
S3StructureErrorInvalid JSON syntax
S4StructureWarningUnknown top-level keys
S5StructureWarningMissing jsc key (most configs need it)
J1JSC ConfigErrorInvalid parser syntax (must be ecmascript or typescript)
J2JSC ConfigWarningJSX enabled in parser without React transform
J3JSC ConfigWarningDeprecated loose mode in jsc.transform
J4JSC ConfigWarningMissing target (no compilation target specified)
J5JSC ConfigErrorInvalid target value (not es3/es5/es2015-es2024/esnext)
M1ModulesErrorUnknown module type
M2ModulesWarningisModule: false with ESM module type
M3ModulesWarningCommonJS module with ESM-only parser features
T1TransformErrorReact transform without parser.jsx enabled
T2TransformWarningLegacy decorators without decoratorsBeforeExport
T3TransformWarningConflicting useDefineForClassFields with TypeScript
T4TransformWarningDeprecated constModules in jsc.experimental
N1MinificationWarningMinification enabled with compress: false
N2MinificationWarningMangle enabled without compress
N3MinificationWarningDrop console in development config
B1Best PracticesWarningsourceMaps not configured
B2Best PracticesInfoNo env config for different environments

Output Formats

  • text (default): Human-readable with severity icons
  • json: Machine-parseable JSON array of findings
  • summary: Pass/fail with error/warning counts

Exit Codes

  • 0: No errors (warnings/info only or clean)
  • 1: One or more errors found
  • 2: File not found or invalid input

Requirements

  • Python 3.8+
  • No external dependencies (pure stdlib)

Supported Targets

es3, es5, es2015 through es2024, esnext

Supported Module Types

es6, commonjs, umd, amd, nodenext, systemjs

Valid Top-Level Keys

$schema, jsc, module, minify, env, isModule, sourceMaps, inlineSourcesContent, emitSourceMapColumns, inputSourceMap, test, exclude, filename