ITADN

v6.x: code-complexity rule crashes with Ajv schema compilation error

#758OpenSvenMeyer 创建于 2026-03-22
S
SvenMeyercommented
## Description Solhint 6.x (tested with 6.0.0 through 6.1.0) crashes immediately when the `code-complexity` rule is enabled, before any linting occurs. The error originates from Ajv's schema compilation in `base-checker.js`. ## Environment - **solhint**: 6.1.0 - **Node.js**: v22.20.0 - **OS**: Linux (Manjaro) - **bun**: 1.3.1 (also reproducible with npm) ## `.solhint.json` ```json { "extends": "solhint:recommended", "plugins": ["prettier"], "rules": { "code-complexity": ["error", 8], "compiler-version": ["error", ">=0.8.4"], "func-visibility": ["error", { "ignoreConstructors": true }], "max-line-length": ["error", 120], "named-parameters-mapping": "warn", "no-console": "off", "not-rely-on-time": "off", "prettier/prettier": ["error", { "endOfLine": "auto" }] } } ``` ## Error output ``` Error compiling schema, function code: const schema16 = scope.schema[10];return function validate14(data, ... SyntaxError: Unexpected token ':' at new Function (<anonymous>) at Ajv.compileSchema (.../node_modules/solhint/node_modules/ajv/dist/compile/index.js:89:30) at Ajv._compileSchemaEnv (.../node_modules/solhint/node_modules/ajv/dist/core.js:473:37) at Ajv.compile (.../node_modules/solhint/node_modules/ajv/dist/core.js:160:38) at new BaseChecker (.../node_modules/solhint/lib/rules/base-checker.js:35:40) at new CodeComplexityChecker (.../node_modules/solhint/lib/rules/best-practices/code-complexity.js:55:5) ``` ## Steps to reproduce 1. Install solhint 6.1.0 2. Use the `.solhint.json` config above (or any config with `code-complexity` enabled) 3. Run `solhint "contracts/**/*.sol"` Also tried `["error", { "value": 8 }]` format — same crash. The error occurs in Ajv schema compilation before config values are even evaluated. ## Workaround Stay on solhint 5.2.0 which works correctly.
0 条评论