[ESLint] How to export custom dictionary with config #5787
-
Hi! I maintain a custom ESlint config which is a preconfigured set of ESlint rules. As part of this, I am currently looking into adding a spell checker module. The problem is, a lot of false positives were getting picked up (due to platform speciifc words), so I made my own config here. In my config, I have included my dict as a dependency, and then added it in the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'll take a look. |
Beta Was this translation helpful? Give feedback.
-
TL;DRUse You can use a local cspell config file bundled with your plugin or refer to your dictionary directly: rules: {
'@cspell/spellchecker': [
'warn',
{
// ...
configFile: '@isentinel/dict-roblox',
cspell: {
language: 'en-US',
words: ['isentinel'],
},
// ...
},
],
}, It is also possible to use a URL: configFile: 'https://cdn.jsdelivr.net/npm/@isentinel/[email protected]/cspell-ext.json',
// or
configFile: new URL('./cspell.config.js', import.meta.url).href, More DetailThe current implementation of A workaround is to use the The issue is the challenge on how to resolve the location of an import. CSpell uses the location of the configuration file to resolve the import, a bit like: import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
function resolveImport(importName, pathToCSpellConfig) {
const require = createRequire(pathToFileURL(pathToCSpellConfig);
return require.resolve(importName);
} The problem with I apologize that the |
Beta Was this translation helpful? Give feedback.
@christopher-buss,
TL;DR
Use
configFile
to import the dictionary.You can use a local cspell config file bundled with your plugin or refer to your dictionary directly:
It is also possible to use a URL:
More Detail
The current implementation of
cspell.im…