@cspell/eslint-plugin 8.3.2 → 8.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,11 +14,68 @@ This plugin is still in active development as part of the CSpell suite of tools
14
14
  npm install --save-dev @cspell/eslint-plugin
15
15
  ```
16
16
 
17
- - Add to it to `.eslintrc.json`
17
+ - Add the plugin to the ESLint configuration (see below:)
18
+ - [Configuration (new: `eslint.config.js`)](#configuration-new-eslintconfigjs)
19
+ - [Configuration (Legacy: `.eslintrc`)](#configuration-legacy-eslintrc)
18
20
 
19
- ```json
21
+ ### Configuration (new: `eslint.config.js`)
22
+
23
+ **`eslint.config.js` using recommended.**
24
+
25
+ ```js
26
+ import cspellESLintPluginRecommended from '@cspell/eslint-plugin/recommended';
27
+
28
+ export default [
29
+ // other config imports
30
+ cspellESLintPluginRecommended
31
+ // other configs
32
+ ];
33
+ ```
34
+
35
+ **Or**
36
+
37
+ **`eslint.config.js` using configs.**
38
+
39
+ ```js
40
+ import cspellConfigs from '@cspell/eslint-plugin/configs';
41
+
42
+ export default [
43
+ // other config imports
44
+ cspellConfigs.recommended
45
+ // other configs
46
+ ];
47
+ ```
48
+
49
+ **Or**
50
+
51
+ **`eslint.config.js` using `plugins`**
52
+
53
+ ```js
54
+ import cspellPlugin from '@cspell/eslint-plugin';
55
+
56
+ export default [
57
+ // other config imports
58
+ {
59
+ plugins: { '@cspell': cspellPlugin },
60
+ rules: {
61
+ '@cspell/spellchecker': ['warn', {}]
62
+ }
63
+ }
64
+ // other configs
65
+ ];
66
+ ```
67
+
68
+ ### Configuration (Legacy: `.eslintrc`)
69
+
70
+ Add `"plugin:@cspell/recommended"` to the `extends` section of the configuration.
71
+
72
+ **`.eslintrc`**
73
+
74
+ ```json
75
+ {
20
76
  "extends": ["plugin:@cspell/recommended"]
21
- ```
77
+ }
78
+ ```
22
79
 
23
80
  ## Options
24
81
 
@@ -87,6 +144,11 @@ interface Options {
87
144
  * Some CSpell Settings
88
145
  */
89
146
  cspell?: {
147
+ /**
148
+ * The language locale to use, i.e. `en-US,en-GB` to enable both
149
+ * American and British English.
150
+ */
151
+ language?: string;
90
152
  /** List of words to be considered correct. */
91
153
  words?: string[];
92
154
  /**
@@ -141,7 +203,39 @@ interface Options {
141
203
  }
142
204
  ````
143
205
 
144
- Example:
206
+ Examples:
207
+
208
+ **`eslint.config.js`**
209
+
210
+ ```js
211
+ import cspellPlugin from '@cspell/eslint-plugin';
212
+
213
+ export default [
214
+ {
215
+ plugins: { '@cspell': cspellPlugin },
216
+ rules: {
217
+ '@cspell/spellchecker': ['warn', { checkComments: false, autoFix: true }]
218
+ }
219
+ }
220
+ ];
221
+ ```
222
+
223
+ **`eslint.config.js`**
224
+
225
+ ```js
226
+ import cspellConfigs from '@cspell/eslint-plugin/configs';
227
+
228
+ export default [
229
+ cspellConfigs.recommended,
230
+ {
231
+ rules: {
232
+ '@cspell/spellchecker': ['warn', { checkComments: false, autoFix: true }]
233
+ }
234
+ }
235
+ ];
236
+ ```
237
+
238
+ **`.eslintrc.json`**
145
239
 
146
240
  ```json
147
241
  {
@@ -158,6 +158,11 @@
158
158
  },
159
159
  "type": "array"
160
160
  },
161
+ "language": {
162
+ "default": "en",
163
+ "description": "Current active spelling language. This specifies the language locale to use in choosing the general dictionary.\n\nFor example:\n\n- \"en-GB\" for British English.\n- \"en,nl\" to enable both English and Dutch.",
164
+ "type": "string"
165
+ },
161
166
  "words": {
162
167
  "description": "List of words to be considered correct.",
163
168
  "items": {
@@ -23,7 +23,7 @@ export interface Options extends Check {
23
23
  debugMode?: boolean;
24
24
  }
25
25
  type DictionaryDefinition = DictionaryDefinitionPreferred;
26
- export type CSpellOptions = Pick<CSpellSettings, 'allowCompoundWords' | 'dictionaries' | 'enabled' | 'flagWords' | 'ignoreWords' | 'ignoreRegExpList' | 'includeRegExpList' | 'import' | 'words'> & {
26
+ export type CSpellOptions = Pick<CSpellSettings, 'allowCompoundWords' | 'dictionaries' | 'enabled' | 'flagWords' | 'ignoreWords' | 'ignoreRegExpList' | 'includeRegExpList' | 'import' | 'language' | 'words'> & {
27
27
  dictionaryDefinitions?: DictionaryDefinition[];
28
28
  };
29
29
  export type RequiredOptions = Required<Pick<Options, Exclude<keyof Options, 'debugMode'>>> & Pick<Options, 'debugMode'>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.debug = exports.recommended = void 0;
27
+ const cspell_eslint_plugin_cjs_1 = require("./cspell-eslint-plugin.cjs");
28
+ exports.recommended = __importStar(require("./recommended.cjs"));
29
+ exports.debug = {
30
+ plugins: {
31
+ '@cspell': cspell_eslint_plugin_cjs_1.plugin,
32
+ },
33
+ rules: {
34
+ '@cspell/spellchecker': ['warn', { debugMode: true }],
35
+ },
36
+ };
37
+ //# sourceMappingURL=configs.cjs.map
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ export * as recommended from './recommended.cjs';
3
+ export declare const debug: Linter.FlatConfig;
4
+ //# sourceMappingURL=configs.d.cts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configs = exports.rules = void 0;
3
+ exports.plugin = exports.configs = exports.meta = exports.rules = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const synckit_1 = require("synckit");
@@ -8,13 +8,13 @@ const logger_cjs_1 = require("../common/logger.cjs");
8
8
  const defaultCheckOptions_cjs_1 = require("./defaultCheckOptions.cjs");
9
9
  const optionsSchema = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../assets/options.schema.json'), 'utf8'));
10
10
  const schema = optionsSchema;
11
- const spellCheck = (0, synckit_1.createSyncFn)(require.resolve('../worker/worker.mjs'), undefined, 30000);
11
+ const spellCheck = (0, synckit_1.createSyncFn)(require.resolve('../worker/worker.mjs'), 30000);
12
12
  const messages = {
13
13
  wordUnknown: 'Unknown word: "{{word}}"',
14
14
  wordForbidden: 'Forbidden word: "{{word}}"',
15
15
  suggestWord: '{{word}}{{preferred}}',
16
16
  };
17
- const meta = {
17
+ const ruleMeta = {
18
18
  docs: {
19
19
  description: 'CSpell spellchecker',
20
20
  category: 'Possible Errors',
@@ -93,11 +93,12 @@ function create(context) {
93
93
  }
94
94
  return { Program: checkProgram };
95
95
  }
96
+ const spellchecker = {
97
+ meta: ruleMeta,
98
+ create,
99
+ };
96
100
  exports.rules = {
97
- spellchecker: {
98
- meta,
99
- create,
100
- },
101
+ spellchecker,
101
102
  };
102
103
  function logContext(log, context) {
103
104
  log('context: %o', {
@@ -109,18 +110,24 @@ function logContext(log, context) {
109
110
  options: context.options.length === 1 ? context.options[0] : context.options,
110
111
  });
111
112
  }
112
- exports.configs = {
113
- recommended: {
114
- plugins: ['@cspell'],
115
- rules: {
116
- '@cspell/spellchecker': ['warn', {}],
117
- },
113
+ exports.meta = { name: '@cspell' };
114
+ const recommended = {
115
+ plugins: ['@cspell'],
116
+ rules: {
117
+ '@cspell/spellchecker': ['warn', {}],
118
118
  },
119
- debug: {
120
- plugins: ['@cspell'],
121
- rules: {
122
- '@cspell/spellchecker': ['warn', { debugMode: true }],
123
- },
119
+ };
120
+ const debugConfig = {
121
+ plugins: ['@cspell'],
122
+ rules: {
123
+ '@cspell/spellchecker': ['warn', { debugMode: true }],
124
124
  },
125
125
  };
126
+ exports.configs = {
127
+ debug: debugConfig,
128
+ 'debug-legacy': debugConfig,
129
+ recommended,
130
+ 'recommended-legacy': recommended,
131
+ };
132
+ exports.plugin = { rules: exports.rules, configs: exports.configs, meta: exports.meta };
126
133
  //# sourceMappingURL=cspell-eslint-plugin.cjs.map
@@ -1,22 +1,19 @@
1
- import type { Rule } from 'eslint';
2
- interface PluginRules {
3
- ['spellchecker']: Rule.RuleModule;
4
- }
5
- export declare const rules: PluginRules;
6
- export declare const configs: {
7
- recommended: {
8
- plugins: string[];
9
- rules: {
10
- '@cspell/spellchecker': {}[];
11
- };
1
+ import type { ESLint, Rule } from 'eslint';
2
+ type ESlintPlugin = ESLint.Plugin;
3
+ export declare const rules: {
4
+ spellchecker: Rule.RuleModule;
5
+ };
6
+ export declare const meta: {
7
+ readonly name: "@cspell";
8
+ };
9
+ export declare const configs: ESlintPlugin['configs'];
10
+ export declare const plugin: {
11
+ rules: {
12
+ spellchecker: Rule.RuleModule;
12
13
  };
13
- debug: {
14
- plugins: string[];
15
- rules: {
16
- '@cspell/spellchecker': (string | {
17
- debugMode: boolean;
18
- })[];
19
- };
14
+ configs: Record<string, ESLint.ConfigData<import("eslint").Linter.RulesRecord> | import("eslint").Linter.FlatConfig | import("eslint").Linter.FlatConfig[]>;
15
+ meta: {
16
+ readonly name: "@cspell";
20
17
  };
21
18
  };
22
19
  export {};
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rules = exports.configs = void 0;
4
- var cspell_eslint_plugin_cjs_1 = require("./cspell-eslint-plugin.cjs");
5
- Object.defineProperty(exports, "configs", { enumerable: true, get: function () { return cspell_eslint_plugin_cjs_1.configs; } });
6
- Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return cspell_eslint_plugin_cjs_1.rules; } });
3
+ exports.rules = exports.meta = exports.configs = void 0;
4
+ const cspell_eslint_plugin_cjs_1 = require("./cspell-eslint-plugin.cjs");
5
+ var cspell_eslint_plugin_cjs_2 = require("./cspell-eslint-plugin.cjs");
6
+ Object.defineProperty(exports, "configs", { enumerable: true, get: function () { return cspell_eslint_plugin_cjs_2.configs; } });
7
+ Object.defineProperty(exports, "meta", { enumerable: true, get: function () { return cspell_eslint_plugin_cjs_2.meta; } });
8
+ Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return cspell_eslint_plugin_cjs_2.rules; } });
9
+ exports.default = cspell_eslint_plugin_cjs_1.plugin;
7
10
  //# sourceMappingURL=index.cjs.map
@@ -1,3 +1,5 @@
1
1
  export type { Options } from '../common/options.cjs';
2
- export { configs, rules } from './cspell-eslint-plugin.cjs';
2
+ import { plugin } from './cspell-eslint-plugin.cjs';
3
+ export { configs, meta, rules } from './cspell-eslint-plugin.cjs';
4
+ export default plugin;
3
5
  //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rules = exports.plugins = void 0;
4
+ const cspell_eslint_plugin_cjs_1 = require("./cspell-eslint-plugin.cjs");
5
+ const config = {
6
+ plugins: {
7
+ '@cspell': cspell_eslint_plugin_cjs_1.plugin,
8
+ },
9
+ rules: {
10
+ '@cspell/spellchecker': ['warn', {}],
11
+ },
12
+ };
13
+ exports.plugins = config.plugins;
14
+ exports.rules = config.rules;
15
+ //# sourceMappingURL=recommended.cjs.map
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ export declare const plugins: Record<string, import("eslint").ESLint.Plugin> | undefined;
3
+ export declare const rules: Linter.RulesRecord | undefined;
4
+ //# sourceMappingURL=recommended.d.cts.map
@@ -28,7 +28,7 @@ export interface SpellCheckResults {
28
28
  issues: Issue[];
29
29
  errors?: Error[];
30
30
  }
31
- type SpellCheckFn = (filename: string, text: string, root: Node, options: WorkerOptions) => Promise<SpellCheckResults>;
31
+ export type SpellCheckFn = (filename: string, text: string, root: Node, options: WorkerOptions) => Promise<SpellCheckResults>;
32
32
  export type SpellCheckSyncFn = (...p: Parameters<SpellCheckFn>) => Awaited<ReturnType<SpellCheckFn>>;
33
33
  export {};
34
34
  //# sourceMappingURL=types.d.cts.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "8.3.2",
6
+ "version": "8.4.1",
7
7
  "description": "CSpell ESLint plugin",
8
8
  "keywords": [
9
9
  "cspell",
@@ -23,6 +23,18 @@
23
23
  "require": "./dist/plugin/index.cjs",
24
24
  "import": "./dist/plugin/index.cjs",
25
25
  "default": "./dist/plugin/index.cjs"
26
+ },
27
+ "./configs": {
28
+ "types": "./dist/plugin/configs.d.cts",
29
+ "require": "./dist/plugin/configs.cjs",
30
+ "import": "./dist/plugin/configs.cjs",
31
+ "default": "./dist/plugin/configs.cjs"
32
+ },
33
+ "./recommended": {
34
+ "types": "./dist/plugin/recommended.d.cts",
35
+ "require": "./dist/plugin/recommended.cjs",
36
+ "import": "./dist/plugin/recommended.cjs",
37
+ "default": "./dist/plugin/recommended.cjs"
26
38
  }
27
39
  },
28
40
  "type": "module",
@@ -60,24 +72,24 @@
60
72
  "node": ">=18"
61
73
  },
62
74
  "devDependencies": {
63
- "@types/eslint": "^8.56.0",
75
+ "@types/eslint": "^8.56.2",
64
76
  "@types/estree": "^1.0.5",
65
77
  "@types/mocha": "^10.0.6",
66
- "@typescript-eslint/eslint-plugin": "^6.16.0",
67
- "@typescript-eslint/parser": "^6.16.0",
68
- "@typescript-eslint/types": "^6.16.0",
69
- "@typescript-eslint/typescript-estree": "^6.16.0",
78
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
79
+ "@typescript-eslint/parser": "^6.21.0",
80
+ "@typescript-eslint/types": "^6.21.0",
81
+ "@typescript-eslint/typescript-estree": "^6.21.0",
70
82
  "eslint": "^8.56.0",
71
83
  "eslint-plugin-react": "^7.33.2",
72
- "mocha": "^10.2.0",
84
+ "mocha": "^10.3.0",
73
85
  "ts-json-schema-generator": "^1.5.0",
74
86
  "typescript": "^5.3.3"
75
87
  },
76
88
  "dependencies": {
77
- "@cspell/cspell-types": "8.3.2",
78
- "cspell-lib": "8.3.2",
89
+ "@cspell/cspell-types": "8.4.1",
90
+ "cspell-lib": "8.4.1",
79
91
  "estree-walker": "^3.0.3",
80
- "synckit": "^0.8.8"
92
+ "synckit": "^0.9.0"
81
93
  },
82
- "gitHead": "98f622b2b12529f2d1ccf0f3a57991e4c08b3e3a"
94
+ "gitHead": "d57dbadb81b859d659c578cd8e81ac5dbcbaae8c"
83
95
  }