@cspell/eslint-plugin 6.4.0-alpha.0 → 6.4.0

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/dist/index.d.ts CHANGED
@@ -78,10 +78,26 @@ interface Check {
78
78
  */
79
79
  checkComments?: boolean;
80
80
  /**
81
- * **Experimental**: Specify a path to a custom word list file. A utf-8 text file with one word per line.
82
- * This file is used to present the option to add words.
81
+ * Specify a path to a custom word list file
83
82
  */
84
- customWordListFile?: string | undefined;
83
+ customWordListFile?: CustomWordListFilePath | CustomWordListFile | undefined;
84
+ }
85
+ /**
86
+ * Specify a path to a custom word list file
87
+ */
88
+ declare type CustomWordListFilePath = string;
89
+ interface CustomWordListFile {
90
+ /**
91
+ * Path to word list file.
92
+ * File format: 1 word per line
93
+ */
94
+ path: CustomWordListFilePath;
95
+ /**
96
+ * **Experimental**: Provide a fix option to add words to the file.
97
+ *
98
+ * Note: this does not yet work perfectly.
99
+ */
100
+ addWords: boolean;
85
101
  }
86
102
 
87
103
  export { Options, configs, rules };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cspell/eslint-plugin v6.3.0
2
+ * @cspell/eslint-plugin v6.4.0-alpha.0
3
3
  * Copyright 2022 Jason Dent <jason@streetsidesoftware.nl>
4
4
  * Released under the MIT License
5
5
  * https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#readme
@@ -97,6 +97,28 @@ function normalizeOptions(opts) {
97
97
  var $schema = "http://json-schema.org/draft-07/schema#";
98
98
  var additionalProperties = false;
99
99
  var definitions = {
100
+ CustomWordListFile: {
101
+ additionalProperties: false,
102
+ properties: {
103
+ addWords: {
104
+ description: "**Experimental**: Provide a fix option to add words to the file.\n\nNote: this does not yet work perfectly.",
105
+ type: "boolean"
106
+ },
107
+ path: {
108
+ $ref: "#/definitions/CustomWordListFilePath",
109
+ description: "Path to word list file. File format: 1 word per line"
110
+ }
111
+ },
112
+ required: [
113
+ "path",
114
+ "addWords"
115
+ ],
116
+ type: "object"
117
+ },
118
+ CustomWordListFilePath: {
119
+ description: "Specify a path to a custom word list file",
120
+ type: "string"
121
+ }
100
122
  };
101
123
  var properties = {
102
124
  checkComments: {
@@ -120,8 +142,15 @@ var properties = {
120
142
  type: "boolean"
121
143
  },
122
144
  customWordListFile: {
123
- description: "**Experimental**: Specify a path to a custom word list file. A utf-8 text file with one word per line. This file is used to present the option to add words.",
124
- type: "string"
145
+ anyOf: [
146
+ {
147
+ $ref: "#/definitions/CustomWordListFilePath"
148
+ },
149
+ {
150
+ $ref: "#/definitions/CustomWordListFile"
151
+ }
152
+ ],
153
+ description: "Specify a path to a custom word list file"
125
154
  },
126
155
  debugMode: {
127
156
  "default": false,
@@ -336,9 +365,10 @@ function create(context) {
336
365
  };
337
366
  }
338
367
  function createAddWordToDictionaryFix(word) {
339
- if (!options.customWordListFile)
368
+ if (!isCustomWordListFile(options.customWordListFile) || !options.customWordListFile.addWords) {
340
369
  return undefined;
341
- const dictFile = path__namespace.resolve(context.getCwd(), options.customWordListFile);
370
+ }
371
+ const dictFile = path__namespace.resolve(context.getCwd(), options.customWordListFile.path);
342
372
  const data = { word, dictionary: path__namespace.basename(dictFile) };
343
373
  const messageId = 'addWordToDictionary';
344
374
  return {
@@ -533,9 +563,11 @@ function getDocValidator(context) {
533
563
  return validator;
534
564
  }
535
565
  function calcInitialSettings(options, cwd) {
536
- if (!options.customWordListFile)
566
+ const { customWordListFile } = options;
567
+ if (!customWordListFile)
537
568
  return defaultSettings;
538
- const dictFile = path__namespace.resolve(cwd, options.customWordListFile);
569
+ const filePath = isCustomWordListFile(customWordListFile) ? customWordListFile.path : customWordListFile;
570
+ const dictFile = path__namespace.resolve(cwd, filePath);
539
571
  const settings = {
540
572
  ...defaultSettings,
541
573
  dictionaryDefinitions: [{ name: 'eslint-plugin-custom-words', path: dictFile }],
@@ -578,6 +610,9 @@ class WrapFix {
578
610
  return this.fix.text;
579
611
  }
580
612
  }
613
+ function isCustomWordListFile(value) {
614
+ return !!value && typeof value === 'object';
615
+ }
581
616
 
582
617
  exports.configs = configs;
583
618
  exports.rules = rules;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cspell/eslint-plugin v6.3.0
2
+ * @cspell/eslint-plugin v6.4.0-alpha.0
3
3
  * Copyright 2022 Jason Dent <jason@streetsidesoftware.nl>
4
4
  * Released under the MIT License
5
5
  * https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#readme
@@ -69,6 +69,28 @@ function normalizeOptions(opts) {
69
69
  var $schema = "http://json-schema.org/draft-07/schema#";
70
70
  var additionalProperties = false;
71
71
  var definitions = {
72
+ CustomWordListFile: {
73
+ additionalProperties: false,
74
+ properties: {
75
+ addWords: {
76
+ description: "**Experimental**: Provide a fix option to add words to the file.\n\nNote: this does not yet work perfectly.",
77
+ type: "boolean"
78
+ },
79
+ path: {
80
+ $ref: "#/definitions/CustomWordListFilePath",
81
+ description: "Path to word list file. File format: 1 word per line"
82
+ }
83
+ },
84
+ required: [
85
+ "path",
86
+ "addWords"
87
+ ],
88
+ type: "object"
89
+ },
90
+ CustomWordListFilePath: {
91
+ description: "Specify a path to a custom word list file",
92
+ type: "string"
93
+ }
72
94
  };
73
95
  var properties = {
74
96
  checkComments: {
@@ -92,8 +114,15 @@ var properties = {
92
114
  type: "boolean"
93
115
  },
94
116
  customWordListFile: {
95
- description: "**Experimental**: Specify a path to a custom word list file. A utf-8 text file with one word per line. This file is used to present the option to add words.",
96
- type: "string"
117
+ anyOf: [
118
+ {
119
+ $ref: "#/definitions/CustomWordListFilePath"
120
+ },
121
+ {
122
+ $ref: "#/definitions/CustomWordListFile"
123
+ }
124
+ ],
125
+ description: "Specify a path to a custom word list file"
97
126
  },
98
127
  debugMode: {
99
128
  "default": false,
@@ -308,9 +337,10 @@ function create(context) {
308
337
  };
309
338
  }
310
339
  function createAddWordToDictionaryFix(word) {
311
- if (!options.customWordListFile)
340
+ if (!isCustomWordListFile(options.customWordListFile) || !options.customWordListFile.addWords) {
312
341
  return undefined;
313
- const dictFile = path.resolve(context.getCwd(), options.customWordListFile);
342
+ }
343
+ const dictFile = path.resolve(context.getCwd(), options.customWordListFile.path);
314
344
  const data = { word, dictionary: path.basename(dictFile) };
315
345
  const messageId = 'addWordToDictionary';
316
346
  return {
@@ -505,9 +535,11 @@ function getDocValidator(context) {
505
535
  return validator;
506
536
  }
507
537
  function calcInitialSettings(options, cwd) {
508
- if (!options.customWordListFile)
538
+ const { customWordListFile } = options;
539
+ if (!customWordListFile)
509
540
  return defaultSettings;
510
- const dictFile = path.resolve(cwd, options.customWordListFile);
541
+ const filePath = isCustomWordListFile(customWordListFile) ? customWordListFile.path : customWordListFile;
542
+ const dictFile = path.resolve(cwd, filePath);
511
543
  const settings = {
512
544
  ...defaultSettings,
513
545
  dictionaryDefinitions: [{ name: 'eslint-plugin-custom-words', path: dictFile }],
@@ -550,6 +582,9 @@ class WrapFix {
550
582
  return this.fix.text;
551
583
  }
552
584
  }
585
+ function isCustomWordListFile(value) {
586
+ return !!value && typeof value === 'object';
587
+ }
553
588
 
554
589
  export { configs, rules };
555
590
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "6.4.0-alpha.0",
6
+ "version": "6.4.0",
7
7
  "description": "[WIP] CSpell ESLint plugin",
8
8
  "keywords": [
9
9
  "cspell",
@@ -59,11 +59,11 @@
59
59
  "@rollup/plugin-node-resolve": "^13.3.0",
60
60
  "@rollup/plugin-typescript": "^8.3.3",
61
61
  "@types/eslint": "^8.4.5",
62
- "@types/estree": "^0.0.52",
62
+ "@types/estree": "^1.0.0",
63
63
  "@types/node": "^18.0.6",
64
- "@typescript-eslint/parser": "^5.30.6",
65
- "@typescript-eslint/types": "^5.30.6",
66
- "@typescript-eslint/typescript-estree": "^5.30.6",
64
+ "@typescript-eslint/parser": "^5.30.7",
65
+ "@typescript-eslint/types": "^5.30.7",
66
+ "@typescript-eslint/typescript-estree": "^5.30.7",
67
67
  "eslint": "^8.20.0",
68
68
  "mocha": "^10.0.0",
69
69
  "rimraf": "^3.0.2",
@@ -72,7 +72,7 @@
72
72
  "ts-json-schema-generator": "^1.0.0"
73
73
  },
74
74
  "dependencies": {
75
- "cspell-lib": "^6.4.0-alpha.0"
75
+ "cspell-lib": "^6.4.0"
76
76
  },
77
- "gitHead": "ad84fb5398b1f9c1133187616637efe2f13ea598"
77
+ "gitHead": "e10256a7593f449cecc55600b12710264e106a24"
78
78
  }