@dineroregnskab/eslint-plugin-custom-rules 2.0.6 → 2.0.7

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.
Files changed (174) hide show
  1. package/eslint-plugin-custom-rules.js +2 -0
  2. package/package.json +1 -1
  3. package/node_modules/@aashutoshrathi/word-wrap/LICENSE +0 -21
  4. package/node_modules/@aashutoshrathi/word-wrap/README.md +0 -182
  5. package/node_modules/@aashutoshrathi/word-wrap/index.d.ts +0 -50
  6. package/node_modules/@aashutoshrathi/word-wrap/index.js +0 -52
  7. package/node_modules/@aashutoshrathi/word-wrap/package.json +0 -81
  8. package/node_modules/@angular-eslint/bundled-angular-compiler/README.md +0 -1
  9. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.d.ts +0 -5
  10. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.js +0 -32004
  11. package/node_modules/@angular-eslint/bundled-angular-compiler/package.json +0 -19
  12. package/node_modules/@angular-eslint/template-parser/LICENSE +0 -21
  13. package/node_modules/@angular-eslint/template-parser/README.md +0 -1
  14. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.d.ts +0 -6
  15. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.js +0 -69
  16. package/node_modules/@angular-eslint/template-parser/dist/index.d.ts +0 -44
  17. package/node_modules/@angular-eslint/template-parser/dist/index.js +0 -219
  18. package/node_modules/@angular-eslint/template-parser/package.json +0 -28
  19. package/node_modules/@eslint/eslintrc/LICENSE +0 -19
  20. package/node_modules/@eslint/eslintrc/README.md +0 -115
  21. package/node_modules/@eslint/eslintrc/conf/config-schema.js +0 -79
  22. package/node_modules/@eslint/eslintrc/conf/environments.js +0 -215
  23. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +0 -1104
  24. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +0 -1
  25. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +0 -4333
  26. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +0 -1
  27. package/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +0 -532
  28. package/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +0 -523
  29. package/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +0 -115
  30. package/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +0 -145
  31. package/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +0 -238
  32. package/node_modules/@eslint/eslintrc/lib/config-array/index.js +0 -19
  33. package/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +0 -225
  34. package/node_modules/@eslint/eslintrc/lib/config-array-factory.js +0 -1149
  35. package/node_modules/@eslint/eslintrc/lib/flat-compat.js +0 -318
  36. package/node_modules/@eslint/eslintrc/lib/index-universal.js +0 -29
  37. package/node_modules/@eslint/eslintrc/lib/index.js +0 -56
  38. package/node_modules/@eslint/eslintrc/lib/shared/ajv.js +0 -191
  39. package/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +0 -135
  40. package/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +0 -325
  41. package/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +0 -63
  42. package/node_modules/@eslint/eslintrc/lib/shared/naming.js +0 -96
  43. package/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +0 -42
  44. package/node_modules/@eslint/eslintrc/lib/shared/types.js +0 -149
  45. package/node_modules/@eslint/eslintrc/package.json +0 -82
  46. package/node_modules/@eslint/eslintrc/universal.js +0 -9
  47. package/node_modules/@eslint/js/LICENSE +0 -19
  48. package/node_modules/@eslint/js/README.md +0 -57
  49. package/node_modules/@eslint/js/package.json +0 -31
  50. package/node_modules/@eslint/js/src/configs/eslint-all.js +0 -211
  51. package/node_modules/@eslint/js/src/configs/eslint-recommended.js +0 -76
  52. package/node_modules/@eslint/js/src/index.js +0 -17
  53. package/node_modules/@eslint-community/eslint-utils/LICENSE +0 -21
  54. package/node_modules/@eslint-community/eslint-utils/README.md +0 -37
  55. package/node_modules/@eslint-community/eslint-utils/index.js +0 -2068
  56. package/node_modules/@eslint-community/eslint-utils/index.js.map +0 -1
  57. package/node_modules/@eslint-community/eslint-utils/index.mjs +0 -2027
  58. package/node_modules/@eslint-community/eslint-utils/index.mjs.map +0 -1
  59. package/node_modules/@eslint-community/eslint-utils/package.json +0 -73
  60. package/node_modules/@eslint-community/regexpp/LICENSE +0 -21
  61. package/node_modules/@eslint-community/regexpp/README.md +0 -177
  62. package/node_modules/@eslint-community/regexpp/index.d.ts +0 -1065
  63. package/node_modules/@eslint-community/regexpp/index.js +0 -2747
  64. package/node_modules/@eslint-community/regexpp/index.js.map +0 -1
  65. package/node_modules/@eslint-community/regexpp/index.mjs +0 -2737
  66. package/node_modules/@eslint-community/regexpp/index.mjs.map +0 -1
  67. package/node_modules/@eslint-community/regexpp/package.json +0 -93
  68. package/node_modules/@humanwhocodes/config-array/LICENSE +0 -201
  69. package/node_modules/@humanwhocodes/config-array/README.md +0 -342
  70. package/node_modules/@humanwhocodes/config-array/api.js +0 -1061
  71. package/node_modules/@humanwhocodes/config-array/package.json +0 -61
  72. package/node_modules/@humanwhocodes/module-importer/CHANGELOG.md +0 -15
  73. package/node_modules/@humanwhocodes/module-importer/LICENSE +0 -201
  74. package/node_modules/@humanwhocodes/module-importer/README.md +0 -80
  75. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs +0 -22
  76. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts +0 -27
  77. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.ts +0 -2
  78. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.js +0 -18
  79. package/node_modules/@humanwhocodes/module-importer/package.json +0 -65
  80. package/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs +0 -81
  81. package/node_modules/@humanwhocodes/module-importer/src/module-importer.js +0 -22
  82. package/node_modules/@humanwhocodes/object-schema/.eslintrc.js +0 -29
  83. package/node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml +0 -27
  84. package/node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml +0 -39
  85. package/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +0 -26
  86. package/node_modules/@humanwhocodes/object-schema/LICENSE +0 -29
  87. package/node_modules/@humanwhocodes/object-schema/README.md +0 -234
  88. package/node_modules/@humanwhocodes/object-schema/package.json +0 -33
  89. package/node_modules/@humanwhocodes/object-schema/src/index.js +0 -7
  90. package/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +0 -53
  91. package/node_modules/@humanwhocodes/object-schema/src/object-schema.js +0 -301
  92. package/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +0 -102
  93. package/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +0 -66
  94. package/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +0 -659
  95. package/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +0 -186
  96. package/node_modules/@nodelib/fs.scandir/LICENSE +0 -21
  97. package/node_modules/@nodelib/fs.scandir/README.md +0 -171
  98. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +0 -20
  99. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +0 -19
  100. package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +0 -4
  101. package/node_modules/@nodelib/fs.scandir/out/constants.js +0 -17
  102. package/node_modules/@nodelib/fs.scandir/out/index.d.ts +0 -12
  103. package/node_modules/@nodelib/fs.scandir/out/index.js +0 -26
  104. package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +0 -7
  105. package/node_modules/@nodelib/fs.scandir/out/providers/async.js +0 -104
  106. package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +0 -1
  107. package/node_modules/@nodelib/fs.scandir/out/providers/common.js +0 -13
  108. package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +0 -5
  109. package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +0 -54
  110. package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +0 -20
  111. package/node_modules/@nodelib/fs.scandir/out/settings.js +0 -24
  112. package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +0 -20
  113. package/node_modules/@nodelib/fs.scandir/out/types/index.js +0 -2
  114. package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +0 -2
  115. package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +0 -19
  116. package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +0 -2
  117. package/node_modules/@nodelib/fs.scandir/out/utils/index.js +0 -5
  118. package/node_modules/@nodelib/fs.scandir/package.json +0 -44
  119. package/node_modules/@nodelib/fs.stat/LICENSE +0 -21
  120. package/node_modules/@nodelib/fs.stat/README.md +0 -126
  121. package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +0 -13
  122. package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +0 -17
  123. package/node_modules/@nodelib/fs.stat/out/index.d.ts +0 -12
  124. package/node_modules/@nodelib/fs.stat/out/index.js +0 -26
  125. package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +0 -4
  126. package/node_modules/@nodelib/fs.stat/out/providers/async.js +0 -36
  127. package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +0 -3
  128. package/node_modules/@nodelib/fs.stat/out/providers/sync.js +0 -23
  129. package/node_modules/@nodelib/fs.stat/out/settings.d.ts +0 -16
  130. package/node_modules/@nodelib/fs.stat/out/settings.js +0 -16
  131. package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +0 -4
  132. package/node_modules/@nodelib/fs.stat/out/types/index.js +0 -2
  133. package/node_modules/@nodelib/fs.stat/package.json +0 -37
  134. package/node_modules/@nodelib/fs.walk/LICENSE +0 -21
  135. package/node_modules/@nodelib/fs.walk/README.md +0 -215
  136. package/node_modules/@nodelib/fs.walk/out/index.d.ts +0 -14
  137. package/node_modules/@nodelib/fs.walk/out/index.js +0 -34
  138. package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +0 -12
  139. package/node_modules/@nodelib/fs.walk/out/providers/async.js +0 -30
  140. package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +0 -4
  141. package/node_modules/@nodelib/fs.walk/out/providers/index.js +0 -9
  142. package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +0 -12
  143. package/node_modules/@nodelib/fs.walk/out/providers/stream.js +0 -34
  144. package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +0 -10
  145. package/node_modules/@nodelib/fs.walk/out/providers/sync.js +0 -14
  146. package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +0 -30
  147. package/node_modules/@nodelib/fs.walk/out/readers/async.js +0 -97
  148. package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +0 -7
  149. package/node_modules/@nodelib/fs.walk/out/readers/common.js +0 -31
  150. package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +0 -6
  151. package/node_modules/@nodelib/fs.walk/out/readers/reader.js +0 -11
  152. package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +0 -15
  153. package/node_modules/@nodelib/fs.walk/out/readers/sync.js +0 -59
  154. package/node_modules/@nodelib/fs.walk/out/settings.d.ts +0 -30
  155. package/node_modules/@nodelib/fs.walk/out/settings.js +0 -26
  156. package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +0 -8
  157. package/node_modules/@nodelib/fs.walk/out/types/index.js +0 -2
  158. package/node_modules/@nodelib/fs.walk/package.json +0 -44
  159. package/node_modules/@ungap/structured-clone/.github/workflows/node.js.yml +0 -31
  160. package/node_modules/@ungap/structured-clone/LICENSE +0 -15
  161. package/node_modules/@ungap/structured-clone/README.md +0 -95
  162. package/node_modules/@ungap/structured-clone/cjs/deserialize.js +0 -78
  163. package/node_modules/@ungap/structured-clone/cjs/index.js +0 -27
  164. package/node_modules/@ungap/structured-clone/cjs/json.js +0 -24
  165. package/node_modules/@ungap/structured-clone/cjs/package.json +0 -1
  166. package/node_modules/@ungap/structured-clone/cjs/serialize.js +0 -160
  167. package/node_modules/@ungap/structured-clone/cjs/types.js +0 -22
  168. package/node_modules/@ungap/structured-clone/esm/deserialize.js +0 -79
  169. package/node_modules/@ungap/structured-clone/esm/index.js +0 -25
  170. package/node_modules/@ungap/structured-clone/esm/json.js +0 -21
  171. package/node_modules/@ungap/structured-clone/esm/serialize.js +0 -161
  172. package/node_modules/@ungap/structured-clone/esm/types.js +0 -11
  173. package/node_modules/@ungap/structured-clone/package.json +0 -53
  174. package/node_modules/@ungap/structured-clone/structured-json.js +0 -1
@@ -1,523 +0,0 @@
1
- /**
2
- * @fileoverview `ConfigArray` class.
3
- *
4
- * `ConfigArray` class expresses the full of a configuration. It has the entry
5
- * config file, base config files that were extended, loaded parsers, and loaded
6
- * plugins.
7
- *
8
- * `ConfigArray` class provides three properties and two methods.
9
- *
10
- * - `pluginEnvironments`
11
- * - `pluginProcessors`
12
- * - `pluginRules`
13
- * The `Map` objects that contain the members of all plugins that this
14
- * config array contains. Those map objects don't have mutation methods.
15
- * Those keys are the member ID such as `pluginId/memberName`.
16
- * - `isRoot()`
17
- * If `true` then this configuration has `root:true` property.
18
- * - `extractConfig(filePath)`
19
- * Extract the final configuration for a given file. This means merging
20
- * every config array element which that `criteria` property matched. The
21
- * `filePath` argument must be an absolute path.
22
- *
23
- * `ConfigArrayFactory` provides the loading logic of config files.
24
- *
25
- * @author Toru Nagashima <https://github.com/mysticatea>
26
- */
27
-
28
- //------------------------------------------------------------------------------
29
- // Requirements
30
- //------------------------------------------------------------------------------
31
-
32
- import { ExtractedConfig } from "./extracted-config.js";
33
- import { IgnorePattern } from "./ignore-pattern.js";
34
-
35
- //------------------------------------------------------------------------------
36
- // Helpers
37
- //------------------------------------------------------------------------------
38
-
39
- // Define types for VSCode IntelliSense.
40
- /** @typedef {import("../../shared/types").Environment} Environment */
41
- /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
42
- /** @typedef {import("../../shared/types").RuleConf} RuleConf */
43
- /** @typedef {import("../../shared/types").Rule} Rule */
44
- /** @typedef {import("../../shared/types").Plugin} Plugin */
45
- /** @typedef {import("../../shared/types").Processor} Processor */
46
- /** @typedef {import("./config-dependency").DependentParser} DependentParser */
47
- /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
48
- /** @typedef {import("./override-tester")["OverrideTester"]} OverrideTester */
49
-
50
- /**
51
- * @typedef {Object} ConfigArrayElement
52
- * @property {string} name The name of this config element.
53
- * @property {string} filePath The path to the source file of this config element.
54
- * @property {InstanceType<OverrideTester>|null} criteria The tester for the `files` and `excludedFiles` of this config element.
55
- * @property {Record<string, boolean>|undefined} env The environment settings.
56
- * @property {Record<string, GlobalConf>|undefined} globals The global variable settings.
57
- * @property {IgnorePattern|undefined} ignorePattern The ignore patterns.
58
- * @property {boolean|undefined} noInlineConfig The flag that disables directive comments.
59
- * @property {DependentParser|undefined} parser The parser loader.
60
- * @property {Object|undefined} parserOptions The parser options.
61
- * @property {Record<string, DependentPlugin>|undefined} plugins The plugin loaders.
62
- * @property {string|undefined} processor The processor name to refer plugin's processor.
63
- * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments.
64
- * @property {boolean|undefined} root The flag to express root.
65
- * @property {Record<string, RuleConf>|undefined} rules The rule settings
66
- * @property {Object|undefined} settings The shared settings.
67
- * @property {"config" | "ignore" | "implicit-processor"} type The element type.
68
- */
69
-
70
- /**
71
- * @typedef {Object} ConfigArrayInternalSlots
72
- * @property {Map<string, ExtractedConfig>} cache The cache to extract configs.
73
- * @property {ReadonlyMap<string, Environment>|null} envMap The map from environment ID to environment definition.
74
- * @property {ReadonlyMap<string, Processor>|null} processorMap The map from processor ID to environment definition.
75
- * @property {ReadonlyMap<string, Rule>|null} ruleMap The map from rule ID to rule definition.
76
- */
77
-
78
- /** @type {WeakMap<ConfigArray, ConfigArrayInternalSlots>} */
79
- const internalSlotsMap = new class extends WeakMap {
80
- get(key) {
81
- let value = super.get(key);
82
-
83
- if (!value) {
84
- value = {
85
- cache: new Map(),
86
- envMap: null,
87
- processorMap: null,
88
- ruleMap: null
89
- };
90
- super.set(key, value);
91
- }
92
-
93
- return value;
94
- }
95
- }();
96
-
97
- /**
98
- * Get the indices which are matched to a given file.
99
- * @param {ConfigArrayElement[]} elements The elements.
100
- * @param {string} filePath The path to a target file.
101
- * @returns {number[]} The indices.
102
- */
103
- function getMatchedIndices(elements, filePath) {
104
- const indices = [];
105
-
106
- for (let i = elements.length - 1; i >= 0; --i) {
107
- const element = elements[i];
108
-
109
- if (!element.criteria || (filePath && element.criteria.test(filePath))) {
110
- indices.push(i);
111
- }
112
- }
113
-
114
- return indices;
115
- }
116
-
117
- /**
118
- * Check if a value is a non-null object.
119
- * @param {any} x The value to check.
120
- * @returns {boolean} `true` if the value is a non-null object.
121
- */
122
- function isNonNullObject(x) {
123
- return typeof x === "object" && x !== null;
124
- }
125
-
126
- /**
127
- * Merge two objects.
128
- *
129
- * Assign every property values of `y` to `x` if `x` doesn't have the property.
130
- * If `x`'s property value is an object, it does recursive.
131
- * @param {Object} target The destination to merge
132
- * @param {Object|undefined} source The source to merge.
133
- * @returns {void}
134
- */
135
- function mergeWithoutOverwrite(target, source) {
136
- if (!isNonNullObject(source)) {
137
- return;
138
- }
139
-
140
- for (const key of Object.keys(source)) {
141
- if (key === "__proto__") {
142
- continue;
143
- }
144
-
145
- if (isNonNullObject(target[key])) {
146
- mergeWithoutOverwrite(target[key], source[key]);
147
- } else if (target[key] === void 0) {
148
- if (isNonNullObject(source[key])) {
149
- target[key] = Array.isArray(source[key]) ? [] : {};
150
- mergeWithoutOverwrite(target[key], source[key]);
151
- } else if (source[key] !== void 0) {
152
- target[key] = source[key];
153
- }
154
- }
155
- }
156
- }
157
-
158
- /**
159
- * The error for plugin conflicts.
160
- */
161
- class PluginConflictError extends Error {
162
-
163
- /**
164
- * Initialize this error object.
165
- * @param {string} pluginId The plugin ID.
166
- * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins.
167
- */
168
- constructor(pluginId, plugins) {
169
- super(`Plugin "${pluginId}" was conflicted between ${plugins.map(p => `"${p.importerName}"`).join(" and ")}.`);
170
- this.messageTemplate = "plugin-conflict";
171
- this.messageData = { pluginId, plugins };
172
- }
173
- }
174
-
175
- /**
176
- * Merge plugins.
177
- * `target`'s definition is prior to `source`'s.
178
- * @param {Record<string, DependentPlugin>} target The destination to merge
179
- * @param {Record<string, DependentPlugin>|undefined} source The source to merge.
180
- * @returns {void}
181
- */
182
- function mergePlugins(target, source) {
183
- if (!isNonNullObject(source)) {
184
- return;
185
- }
186
-
187
- for (const key of Object.keys(source)) {
188
- if (key === "__proto__") {
189
- continue;
190
- }
191
- const targetValue = target[key];
192
- const sourceValue = source[key];
193
-
194
- // Adopt the plugin which was found at first.
195
- if (targetValue === void 0) {
196
- if (sourceValue.error) {
197
- throw sourceValue.error;
198
- }
199
- target[key] = sourceValue;
200
- } else if (sourceValue.filePath !== targetValue.filePath) {
201
- throw new PluginConflictError(key, [
202
- {
203
- filePath: targetValue.filePath,
204
- importerName: targetValue.importerName
205
- },
206
- {
207
- filePath: sourceValue.filePath,
208
- importerName: sourceValue.importerName
209
- }
210
- ]);
211
- }
212
- }
213
- }
214
-
215
- /**
216
- * Merge rule configs.
217
- * `target`'s definition is prior to `source`'s.
218
- * @param {Record<string, Array>} target The destination to merge
219
- * @param {Record<string, RuleConf>|undefined} source The source to merge.
220
- * @returns {void}
221
- */
222
- function mergeRuleConfigs(target, source) {
223
- if (!isNonNullObject(source)) {
224
- return;
225
- }
226
-
227
- for (const key of Object.keys(source)) {
228
- if (key === "__proto__") {
229
- continue;
230
- }
231
- const targetDef = target[key];
232
- const sourceDef = source[key];
233
-
234
- // Adopt the rule config which was found at first.
235
- if (targetDef === void 0) {
236
- if (Array.isArray(sourceDef)) {
237
- target[key] = [...sourceDef];
238
- } else {
239
- target[key] = [sourceDef];
240
- }
241
-
242
- /*
243
- * If the first found rule config is severity only and the current rule
244
- * config has options, merge the severity and the options.
245
- */
246
- } else if (
247
- targetDef.length === 1 &&
248
- Array.isArray(sourceDef) &&
249
- sourceDef.length >= 2
250
- ) {
251
- targetDef.push(...sourceDef.slice(1));
252
- }
253
- }
254
- }
255
-
256
- /**
257
- * Create the extracted config.
258
- * @param {ConfigArray} instance The config elements.
259
- * @param {number[]} indices The indices to use.
260
- * @returns {ExtractedConfig} The extracted config.
261
- */
262
- function createConfig(instance, indices) {
263
- const config = new ExtractedConfig();
264
- const ignorePatterns = [];
265
-
266
- // Merge elements.
267
- for (const index of indices) {
268
- const element = instance[index];
269
-
270
- // Adopt the parser which was found at first.
271
- if (!config.parser && element.parser) {
272
- if (element.parser.error) {
273
- throw element.parser.error;
274
- }
275
- config.parser = element.parser;
276
- }
277
-
278
- // Adopt the processor which was found at first.
279
- if (!config.processor && element.processor) {
280
- config.processor = element.processor;
281
- }
282
-
283
- // Adopt the noInlineConfig which was found at first.
284
- if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) {
285
- config.noInlineConfig = element.noInlineConfig;
286
- config.configNameOfNoInlineConfig = element.name;
287
- }
288
-
289
- // Adopt the reportUnusedDisableDirectives which was found at first.
290
- if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) {
291
- config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives;
292
- }
293
-
294
- // Collect ignorePatterns
295
- if (element.ignorePattern) {
296
- ignorePatterns.push(element.ignorePattern);
297
- }
298
-
299
- // Merge others.
300
- mergeWithoutOverwrite(config.env, element.env);
301
- mergeWithoutOverwrite(config.globals, element.globals);
302
- mergeWithoutOverwrite(config.parserOptions, element.parserOptions);
303
- mergeWithoutOverwrite(config.settings, element.settings);
304
- mergePlugins(config.plugins, element.plugins);
305
- mergeRuleConfigs(config.rules, element.rules);
306
- }
307
-
308
- // Create the predicate function for ignore patterns.
309
- if (ignorePatterns.length > 0) {
310
- config.ignores = IgnorePattern.createIgnore(ignorePatterns.reverse());
311
- }
312
-
313
- return config;
314
- }
315
-
316
- /**
317
- * Collect definitions.
318
- * @template T, U
319
- * @param {string} pluginId The plugin ID for prefix.
320
- * @param {Record<string,T>} defs The definitions to collect.
321
- * @param {Map<string, U>} map The map to output.
322
- * @param {function(T): U} [normalize] The normalize function for each value.
323
- * @returns {void}
324
- */
325
- function collect(pluginId, defs, map, normalize) {
326
- if (defs) {
327
- const prefix = pluginId && `${pluginId}/`;
328
-
329
- for (const [key, value] of Object.entries(defs)) {
330
- map.set(
331
- `${prefix}${key}`,
332
- normalize ? normalize(value) : value
333
- );
334
- }
335
- }
336
- }
337
-
338
- /**
339
- * Normalize a rule definition.
340
- * @param {Function|Rule} rule The rule definition to normalize.
341
- * @returns {Rule} The normalized rule definition.
342
- */
343
- function normalizePluginRule(rule) {
344
- return typeof rule === "function" ? { create: rule } : rule;
345
- }
346
-
347
- /**
348
- * Delete the mutation methods from a given map.
349
- * @param {Map<any, any>} map The map object to delete.
350
- * @returns {void}
351
- */
352
- function deleteMutationMethods(map) {
353
- Object.defineProperties(map, {
354
- clear: { configurable: true, value: void 0 },
355
- delete: { configurable: true, value: void 0 },
356
- set: { configurable: true, value: void 0 }
357
- });
358
- }
359
-
360
- /**
361
- * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
362
- * @param {ConfigArrayElement[]} elements The config elements.
363
- * @param {ConfigArrayInternalSlots} slots The internal slots.
364
- * @returns {void}
365
- */
366
- function initPluginMemberMaps(elements, slots) {
367
- const processed = new Set();
368
-
369
- slots.envMap = new Map();
370
- slots.processorMap = new Map();
371
- slots.ruleMap = new Map();
372
-
373
- for (const element of elements) {
374
- if (!element.plugins) {
375
- continue;
376
- }
377
-
378
- for (const [pluginId, value] of Object.entries(element.plugins)) {
379
- const plugin = value.definition;
380
-
381
- if (!plugin || processed.has(pluginId)) {
382
- continue;
383
- }
384
- processed.add(pluginId);
385
-
386
- collect(pluginId, plugin.environments, slots.envMap);
387
- collect(pluginId, plugin.processors, slots.processorMap);
388
- collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
389
- }
390
- }
391
-
392
- deleteMutationMethods(slots.envMap);
393
- deleteMutationMethods(slots.processorMap);
394
- deleteMutationMethods(slots.ruleMap);
395
- }
396
-
397
- /**
398
- * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
399
- * @param {ConfigArray} instance The config elements.
400
- * @returns {ConfigArrayInternalSlots} The extracted config.
401
- */
402
- function ensurePluginMemberMaps(instance) {
403
- const slots = internalSlotsMap.get(instance);
404
-
405
- if (!slots.ruleMap) {
406
- initPluginMemberMaps(instance, slots);
407
- }
408
-
409
- return slots;
410
- }
411
-
412
- //------------------------------------------------------------------------------
413
- // Public Interface
414
- //------------------------------------------------------------------------------
415
-
416
- /**
417
- * The Config Array.
418
- *
419
- * `ConfigArray` instance contains all settings, parsers, and plugins.
420
- * You need to call `ConfigArray#extractConfig(filePath)` method in order to
421
- * extract, merge and get only the config data which is related to an arbitrary
422
- * file.
423
- * @extends {Array<ConfigArrayElement>}
424
- */
425
- class ConfigArray extends Array {
426
-
427
- /**
428
- * Get the plugin environments.
429
- * The returned map cannot be mutated.
430
- * @type {ReadonlyMap<string, Environment>} The plugin environments.
431
- */
432
- get pluginEnvironments() {
433
- return ensurePluginMemberMaps(this).envMap;
434
- }
435
-
436
- /**
437
- * Get the plugin processors.
438
- * The returned map cannot be mutated.
439
- * @type {ReadonlyMap<string, Processor>} The plugin processors.
440
- */
441
- get pluginProcessors() {
442
- return ensurePluginMemberMaps(this).processorMap;
443
- }
444
-
445
- /**
446
- * Get the plugin rules.
447
- * The returned map cannot be mutated.
448
- * @returns {ReadonlyMap<string, Rule>} The plugin rules.
449
- */
450
- get pluginRules() {
451
- return ensurePluginMemberMaps(this).ruleMap;
452
- }
453
-
454
- /**
455
- * Check if this config has `root` flag.
456
- * @returns {boolean} `true` if this config array is root.
457
- */
458
- isRoot() {
459
- for (let i = this.length - 1; i >= 0; --i) {
460
- const root = this[i].root;
461
-
462
- if (typeof root === "boolean") {
463
- return root;
464
- }
465
- }
466
- return false;
467
- }
468
-
469
- /**
470
- * Extract the config data which is related to a given file.
471
- * @param {string} filePath The absolute path to the target file.
472
- * @returns {ExtractedConfig} The extracted config data.
473
- */
474
- extractConfig(filePath) {
475
- const { cache } = internalSlotsMap.get(this);
476
- const indices = getMatchedIndices(this, filePath);
477
- const cacheKey = indices.join(",");
478
-
479
- if (!cache.has(cacheKey)) {
480
- cache.set(cacheKey, createConfig(this, indices));
481
- }
482
-
483
- return cache.get(cacheKey);
484
- }
485
-
486
- /**
487
- * Check if a given path is an additional lint target.
488
- * @param {string} filePath The absolute path to the target file.
489
- * @returns {boolean} `true` if the file is an additional lint target.
490
- */
491
- isAdditionalTargetPath(filePath) {
492
- for (const { criteria, type } of this) {
493
- if (
494
- type === "config" &&
495
- criteria &&
496
- !criteria.endsWithWildcard &&
497
- criteria.test(filePath)
498
- ) {
499
- return true;
500
- }
501
- }
502
- return false;
503
- }
504
- }
505
-
506
- /**
507
- * Get the used extracted configs.
508
- * CLIEngine will use this method to collect used deprecated rules.
509
- * @param {ConfigArray} instance The config array object to get.
510
- * @returns {ExtractedConfig[]} The used extracted configs.
511
- * @private
512
- */
513
- function getUsedExtractedConfigs(instance) {
514
- const { cache } = internalSlotsMap.get(instance);
515
-
516
- return Array.from(cache.values());
517
- }
518
-
519
-
520
- export {
521
- ConfigArray,
522
- getUsedExtractedConfigs
523
- };
@@ -1,115 +0,0 @@
1
- /**
2
- * @fileoverview `ConfigDependency` class.
3
- *
4
- * `ConfigDependency` class expresses a loaded parser or plugin.
5
- *
6
- * If the parser or plugin was loaded successfully, it has `definition` property
7
- * and `filePath` property. Otherwise, it has `error` property.
8
- *
9
- * When `JSON.stringify()` converted a `ConfigDependency` object to a JSON, it
10
- * omits `definition` property.
11
- *
12
- * `ConfigArrayFactory` creates `ConfigDependency` objects when it loads parsers
13
- * or plugins.
14
- *
15
- * @author Toru Nagashima <https://github.com/mysticatea>
16
- */
17
-
18
- import util from "util";
19
-
20
- /**
21
- * The class is to store parsers or plugins.
22
- * This class hides the loaded object from `JSON.stringify()` and `console.log`.
23
- * @template T
24
- */
25
- class ConfigDependency {
26
-
27
- /**
28
- * Initialize this instance.
29
- * @param {Object} data The dependency data.
30
- * @param {T} [data.definition] The dependency if the loading succeeded.
31
- * @param {Error} [data.error] The error object if the loading failed.
32
- * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded.
33
- * @param {string} data.id The ID of this dependency.
34
- * @param {string} data.importerName The name of the config file which loads this dependency.
35
- * @param {string} data.importerPath The path to the config file which loads this dependency.
36
- */
37
- constructor({
38
- definition = null,
39
- error = null,
40
- filePath = null,
41
- id,
42
- importerName,
43
- importerPath
44
- }) {
45
-
46
- /**
47
- * The loaded dependency if the loading succeeded.
48
- * @type {T|null}
49
- */
50
- this.definition = definition;
51
-
52
- /**
53
- * The error object if the loading failed.
54
- * @type {Error|null}
55
- */
56
- this.error = error;
57
-
58
- /**
59
- * The loaded dependency if the loading succeeded.
60
- * @type {string|null}
61
- */
62
- this.filePath = filePath;
63
-
64
- /**
65
- * The ID of this dependency.
66
- * @type {string}
67
- */
68
- this.id = id;
69
-
70
- /**
71
- * The name of the config file which loads this dependency.
72
- * @type {string}
73
- */
74
- this.importerName = importerName;
75
-
76
- /**
77
- * The path to the config file which loads this dependency.
78
- * @type {string}
79
- */
80
- this.importerPath = importerPath;
81
- }
82
-
83
- // eslint-disable-next-line jsdoc/require-description
84
- /**
85
- * @returns {Object} a JSON compatible object.
86
- */
87
- toJSON() {
88
- const obj = this[util.inspect.custom]();
89
-
90
- // Display `error.message` (`Error#message` is unenumerable).
91
- if (obj.error instanceof Error) {
92
- obj.error = { ...obj.error, message: obj.error.message };
93
- }
94
-
95
- return obj;
96
- }
97
-
98
- // eslint-disable-next-line jsdoc/require-description
99
- /**
100
- * @returns {Object} an object to display by `console.log()`.
101
- */
102
- [util.inspect.custom]() {
103
- const {
104
- definition: _ignore, // eslint-disable-line no-unused-vars
105
- ...obj
106
- } = this;
107
-
108
- return obj;
109
- }
110
- }
111
-
112
- /** @typedef {ConfigDependency<import("../../shared/types").Parser>} DependentParser */
113
- /** @typedef {ConfigDependency<import("../../shared/types").Plugin>} DependentPlugin */
114
-
115
- export { ConfigDependency };