Q [eslint-plugin]: How to import a CSpell configuration file?
avichai-PhoneDo opened this issue · comments
Kind of Issue
Runtime - command-line tools
Tool or Library
cspell/eslint-plugin
Version
8.7.0
Supporting Library
Not sure / None
OS
Linux
OS Version
20.04 ubuntu
Description
hii
i try tell my .eslintrc.cjs file to use cspell config from other location:
'@cspell/spellchecker': [
'error',
{ checkComments: true, autoFix: true, import: ['../cspell.json'] },
],
but i get in VScode eslint output error:
[Info - 12:52:18 PM] ESLint server is starting.
[Info - 12:52:18 PM] ESLint server running in node v18.18.2
[Info - 12:52:18 PM] ESLint server is running.
[Info - 12:52:18 PM] ESLint library loaded from: /home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/eslint/lib/api.js
[Error - 12:52:19 PM] Server process exited with code 0.
[Error - 12:52:19 PM] Calculating config file for file:///home/avichai/Downloads/local-devops/phonedo/api-client-builder/src/oldSDK/Interfaces/node.ts) failed.
Error: .eslintrc.cjs:
Configuration for rule "@cspell/spellchecker" is invalid:
Value {"checkComments":true,"autoFix":true,"import":["../cspell.json"],"checkIdentifiers":true,"checkJSXText":true,"checkStringTemplates":true,"checkStrings":true,"generateSuggestions":true,"ignoreImportProperties":true,"ignoreImports":true,"numSuggestions":8} should NOT have additional properties.
at ConfigValidator.validateRuleOptions (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2048:23)
at /home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2103:18
at Array.forEach (<anonymous>)
at ConfigValidator.validateRules (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2100:34)
at ConfigValidator.validateConfigArray (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2226:18)
at CascadingConfigArrayFactory._finalizeConfigArray (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3985:23)
at CascadingConfigArrayFactory.getConfigArrayForFile (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3791:21)
at CLIEngine.getConfigForFile (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/eslint/lib/cli-engine/cli-engine.js:980:14)
at ESLint.calculateConfigForFile (/home/avichai/Downloads/local-devops/phonedo/api-client-builder/node_modules/eslint/lib/eslint/eslint.js:667:26)
at /home/avichai/.vscode/extensions/dbaeumer.vscode-eslint-2.4.4/server/out/eslintServer.js:1:22554
[Error - 12:52:19 PM] .eslintrc.cjs: Configuration for rule "@cspell/spellchecker" is invalid: Value {"checkComments":true,"autoFix":true,"import":["../cspell.json"],"checkIdentifiers":true,"checkJSXText":true,"checkStringTemplates":true,"checkStrings":true,"generateSuggestions":true,"ignoreImportProperties":true,"ignoreImports":true,"numSuggestions":8} should NOT have additional properties.
my .eslintrc.cjs is:
module.exports = {
env: {
es2021: true,
node: true,
jest: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'airbnb-base',
'airbnb-typescript/base',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:promise/recommended',
'plugin:@cspell/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
parser: '@typescript-eslint/parser',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
ignorePatterns: ['build*/', 'dist*/'],
plugins: ['@typescript-eslint', 'promise', 'import', 'prettier'],
rules: {
'@typescript-eslint/lines-between-class-members': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'import/prefer-default-export': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'prefer-destructuring': 'off',
'consistent-return': 'off',
'no-plusplus': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeAlias',
format: ['PascalCase'],
},
{
selector: 'enum',
format: ['PascalCase'],
},
{
selector: 'interface',
format: ['PascalCase'],
},
],
'no-underscore-dangle': ['error', { allow: ['_id'] }],
'@typescript-eslint/no-namespace': 'off',
'@cspell/spellchecker': ['error', { checkComments: true, autoFix: true }],
'@typescript-eslint/no-unused-vars': 'error',
'no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
},
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
typedefs: true,
},
],
'import/no-extraneous-dependencies': 'off',
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
],
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
'prettier/prettier': ['error', { configFile: '../.prettierrc.json' }],
},
};
my cspell.json file is one level above the eslint file and looks like this:
{
"version": "0.2",
"dictionaries": [
"he",
"aws",
"sql",
"npm",
"bash",
"html",
"typescript",
"node",
"css"
],
"dictionaryDefinitions": [],
"import": ["./node_modules/@cspell/dict-he/cspell-ext.json"],
"useGitignore": true,
"ignorePaths": ["**/*{node_modules,build,dist,lib}*/**"],
"words": [
],
"ignoreWords": []
}
Steps to Reproduce
No response
Expected Behavior
No response
Additional Information
No response
cspell.json
No response
cspell.config.yaml
No response
Example Repository
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
ESLint has very bad error messages. import
needs to be under cspell
:
'@cspell/spellchecker': [
'error',
{ checkComments: true, autoFix: true, cspell: { import: ['../cspell.json'] }},
],
Even so, I can see how adding a configFile
setting would be more intuitive.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.