Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import fs from 'fs-extra';
import glob from 'globby';
import { globby } from 'globby';
import reporter, { VFileMessage } from 'vfile-reporter';

import { buildPersonalDictionary } from './lib/build-personal-dictionary.js';
Expand Down Expand Up @@ -43,7 +43,7 @@ import { toDictionary } from './lib/to-dictionary.js';
);
}

const filesFromGlobs = await glob(files, { gitignore: !noGitignore });
const filesFromGlobs = await globby(files, { gitignore: !noGitignore });

if (!quiet) {
console.log(
Expand Down
2 changes: 1 addition & 1 deletion lib/frontmatter-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import map from 'lodash/map.js';
import pick from 'lodash/pick.js';
import toString from 'lodash/toString.js';
import toml from 'toml';
import visit from 'unist-util-visit';
import { visit } from 'unist-util-visit';

import { printError } from './print-error.js';

Expand Down
22 changes: 14 additions & 8 deletions lib/spellchecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import repeatedWords from 'retext-repeated-words';
import spell from 'retext-spell';
import syntaxMentions from 'retext-syntax-mentions';
import syntaxUrls from 'retext-syntax-urls';
import vfile from 'vfile';
import { VFile, VFileMessage } from 'vfile-reporter';
import { VFile as _VFile } from 'vfile';
import { VFileMessage } from 'vfile-message';
// import { VFile, VFileMessage } from 'vfile-reporter';

import { FrontmatterConfig, frontmatterFilter } from './frontmatter-filter.js';
import { isMarkdownFile } from './is-markdown-file.js';

type VFile = typeof _VFile;

function buildSpellchecker({
dictionary,
suggestions,
Expand Down Expand Up @@ -148,18 +151,21 @@ export class Spellchecker {
''
);

const file = vfile({
const file = new _VFile({
contents: contentsWithoutVariationSelectors,
path: filePath,
});
const result = await spellcheckerForFileType.process(file);
return assign({}, result, {
messages: result.messages.filter(({ actual }: VFileMessage) => {
const doesNotMatch = (regex: RegExp) => !regex.test(actual);
return (
every(this.ignoreRegexes, doesNotMatch) &&
every(this.personalDictionary, doesNotMatch)
);
if (actual) {
const doesNotMatch = (regex: RegExp) => !regex.test(actual);
return (
every(this.ignoreRegexes, doesNotMatch) &&
every(this.personalDictionary, doesNotMatch)
);
}
return true;
}),
});
}
Expand Down
Loading