diff --git a/package.json b/package.json index 2ca7461..722fb78 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "repository": "textlint-rule/textlint-rule-spellchecker", "dependencies": { "@textlint/ast-node-types": "^2.0.0", - "spellchecker": "^3.4.4", + "spellchecker": "^3.7.1", "textlint-rule-helper": "^2.0.0", "textlint-util-to-string": "^2.1.1" }, diff --git a/src/spellchecker.js b/src/spellchecker.js index 93c95c8..d660d58 100644 --- a/src/spellchecker.js +++ b/src/spellchecker.js @@ -57,10 +57,11 @@ function reporter(context, options = {}) { const misspelledCharacterRanges = SpellChecker.checkSpelling(text); misspelledCharacterRanges.forEach((range) => { + const nodeStart = node.range[0]; const originalPosition = source.originalPositionFromIndex(range.start); const originalRange = [ - originalPosition.column, - originalPosition.column + (range.end - range.start), + nodeStart + originalPosition.column, + nodeStart + originalPosition.column + (range.end - range.start), ]; // if range is ignored, not report diff --git a/test/spellchecker.js b/test/spellchecker.js index f5327ee..24a8ca7 100644 --- a/test/spellchecker.js +++ b/test/spellchecker.js @@ -79,5 +79,15 @@ tester.run('spellchecker', rule, { }, ], }, + { + text: + 'This link contains an [errror](index.html) and should not be reported.', + output: + 'This link contains an [errror](index.html) and should not be reported.', + options: { + skipNodeTypes: ['Link'], + }, + errors: [], + }, ], });