Skip to content

linters/obsidianmd-eslint-nesting

Warns when the eslint that eslint-plugin-obsidianmd resolves is another major than the one that runs the lint.

eslint-plugin-obsidianmd builds the core half of its recommended config from the builtinRules of the eslint it resolves from its OWN location. When npm nests an ESLint 9 under it while the project runs ESLint 10, the rules only ESLint 10 recommends (preserve-caught-error, no-useless-assignment, no-unassigned-vars) are left out of every lint, and nothing says so. The fix is an overrides entry, "eslint": "$eslint", which makes npm install the project’s own eslint everywhere; npm dedupe cannot do it, because other dependencies of the plugin peer on ESLint 9.

Re-implemented after obsidian-plugin-dev-kit’s src/scanner/eslint-nesting.ts (MIT), as a warning the shared config gives on load rather than a scanner step.

Interface Description
DescribeEslintMajorMismatchParams The eslint versions to compare.
WarnOnEslintMajorMismatchOptions Parameters for warnOnEslintMajorMismatch.
Function Description
describeEslintMajorMismatch Describes an eslint major mismatch.
getMajorVersion Gets the major of a version such as 9.39.4 or v10.1.0.
readObsidianmdEslintVersion Reads the version of the eslint that eslint-plugin-obsidianmd resolves, from the copy of the plugin this package’s ESLint config imports.
readProjectEslintVersion Reads the version of the eslint installed in the project root, which is the one npx eslint runs.
warnOnEslintMajorMismatch Warns when eslint-plugin-obsidianmd resolves an eslint of another major than the one the project runs. A probe that fails is reported too, since the check then did not run.