@alexlit/lint-kit 117.3.1 → 117.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.
Files changed (159) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +5 -9
  3. package/packages/config-eslint/plugins/no-await-in-promise.js +1 -1
  4. package/packages/config-eslint/utils/create-config.js +3 -3
  5. package/scripts/.config.sh +1 -1
  6. package/packages/config-eslint/node_modules/@eslint/eslintrc/LICENSE +0 -19
  7. package/packages/config-eslint/node_modules/@eslint/eslintrc/README.md +0 -126
  8. package/packages/config-eslint/node_modules/@eslint/eslintrc/conf/config-schema.js +0 -79
  9. package/packages/config-eslint/node_modules/@eslint/eslintrc/conf/environments.js +0 -215
  10. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +0 -1143
  11. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +0 -1
  12. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +0 -4371
  13. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +0 -1
  14. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +0 -532
  15. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +0 -510
  16. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +0 -124
  17. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +0 -145
  18. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +0 -238
  19. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js +0 -19
  20. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +0 -225
  21. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js +0 -1155
  22. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js +0 -318
  23. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/index-universal.js +0 -29
  24. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/index.js +0 -58
  25. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js +0 -191
  26. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +0 -135
  27. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +0 -370
  28. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +0 -63
  29. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js +0 -96
  30. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +0 -42
  31. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/types.js +0 -149
  32. package/packages/config-eslint/node_modules/@eslint/eslintrc/package.json +0 -82
  33. package/packages/config-eslint/node_modules/@eslint/eslintrc/universal.js +0 -9
  34. package/packages/config-eslint/node_modules/ajv/.tonic_example.js +0 -20
  35. package/packages/config-eslint/node_modules/ajv/LICENSE +0 -22
  36. package/packages/config-eslint/node_modules/ajv/README.md +0 -1497
  37. package/packages/config-eslint/node_modules/ajv/dist/ajv.bundle.js +0 -7189
  38. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js +0 -3
  39. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js.map +0 -1
  40. package/packages/config-eslint/node_modules/ajv/lib/ajv.d.ts +0 -397
  41. package/packages/config-eslint/node_modules/ajv/lib/ajv.js +0 -506
  42. package/packages/config-eslint/node_modules/ajv/lib/cache.js +0 -26
  43. package/packages/config-eslint/node_modules/ajv/lib/compile/async.js +0 -90
  44. package/packages/config-eslint/node_modules/ajv/lib/compile/equal.js +0 -5
  45. package/packages/config-eslint/node_modules/ajv/lib/compile/error_classes.js +0 -34
  46. package/packages/config-eslint/node_modules/ajv/lib/compile/formats.js +0 -142
  47. package/packages/config-eslint/node_modules/ajv/lib/compile/index.js +0 -387
  48. package/packages/config-eslint/node_modules/ajv/lib/compile/resolve.js +0 -270
  49. package/packages/config-eslint/node_modules/ajv/lib/compile/rules.js +0 -66
  50. package/packages/config-eslint/node_modules/ajv/lib/compile/schema_obj.js +0 -9
  51. package/packages/config-eslint/node_modules/ajv/lib/compile/ucs2length.js +0 -20
  52. package/packages/config-eslint/node_modules/ajv/lib/compile/util.js +0 -239
  53. package/packages/config-eslint/node_modules/ajv/lib/data.js +0 -49
  54. package/packages/config-eslint/node_modules/ajv/lib/definition_schema.js +0 -37
  55. package/packages/config-eslint/node_modules/ajv/lib/dot/_limit.jst +0 -113
  56. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitItems.jst +0 -12
  57. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitLength.jst +0 -12
  58. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitProperties.jst +0 -12
  59. package/packages/config-eslint/node_modules/ajv/lib/dot/allOf.jst +0 -32
  60. package/packages/config-eslint/node_modules/ajv/lib/dot/anyOf.jst +0 -46
  61. package/packages/config-eslint/node_modules/ajv/lib/dot/coerce.def +0 -51
  62. package/packages/config-eslint/node_modules/ajv/lib/dot/comment.jst +0 -9
  63. package/packages/config-eslint/node_modules/ajv/lib/dot/const.jst +0 -11
  64. package/packages/config-eslint/node_modules/ajv/lib/dot/contains.jst +0 -55
  65. package/packages/config-eslint/node_modules/ajv/lib/dot/custom.jst +0 -191
  66. package/packages/config-eslint/node_modules/ajv/lib/dot/defaults.def +0 -47
  67. package/packages/config-eslint/node_modules/ajv/lib/dot/definitions.def +0 -203
  68. package/packages/config-eslint/node_modules/ajv/lib/dot/dependencies.jst +0 -79
  69. package/packages/config-eslint/node_modules/ajv/lib/dot/enum.jst +0 -30
  70. package/packages/config-eslint/node_modules/ajv/lib/dot/errors.def +0 -194
  71. package/packages/config-eslint/node_modules/ajv/lib/dot/format.jst +0 -106
  72. package/packages/config-eslint/node_modules/ajv/lib/dot/if.jst +0 -73
  73. package/packages/config-eslint/node_modules/ajv/lib/dot/items.jst +0 -98
  74. package/packages/config-eslint/node_modules/ajv/lib/dot/missing.def +0 -39
  75. package/packages/config-eslint/node_modules/ajv/lib/dot/multipleOf.jst +0 -22
  76. package/packages/config-eslint/node_modules/ajv/lib/dot/not.jst +0 -43
  77. package/packages/config-eslint/node_modules/ajv/lib/dot/oneOf.jst +0 -54
  78. package/packages/config-eslint/node_modules/ajv/lib/dot/pattern.jst +0 -14
  79. package/packages/config-eslint/node_modules/ajv/lib/dot/properties.jst +0 -245
  80. package/packages/config-eslint/node_modules/ajv/lib/dot/propertyNames.jst +0 -52
  81. package/packages/config-eslint/node_modules/ajv/lib/dot/ref.jst +0 -85
  82. package/packages/config-eslint/node_modules/ajv/lib/dot/required.jst +0 -108
  83. package/packages/config-eslint/node_modules/ajv/lib/dot/uniqueItems.jst +0 -62
  84. package/packages/config-eslint/node_modules/ajv/lib/dot/validate.jst +0 -276
  85. package/packages/config-eslint/node_modules/ajv/lib/dotjs/README.md +0 -3
  86. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limit.js +0 -163
  87. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitItems.js +0 -80
  88. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitLength.js +0 -85
  89. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitProperties.js +0 -80
  90. package/packages/config-eslint/node_modules/ajv/lib/dotjs/allOf.js +0 -42
  91. package/packages/config-eslint/node_modules/ajv/lib/dotjs/anyOf.js +0 -73
  92. package/packages/config-eslint/node_modules/ajv/lib/dotjs/comment.js +0 -14
  93. package/packages/config-eslint/node_modules/ajv/lib/dotjs/const.js +0 -56
  94. package/packages/config-eslint/node_modules/ajv/lib/dotjs/contains.js +0 -81
  95. package/packages/config-eslint/node_modules/ajv/lib/dotjs/custom.js +0 -228
  96. package/packages/config-eslint/node_modules/ajv/lib/dotjs/dependencies.js +0 -168
  97. package/packages/config-eslint/node_modules/ajv/lib/dotjs/enum.js +0 -66
  98. package/packages/config-eslint/node_modules/ajv/lib/dotjs/format.js +0 -150
  99. package/packages/config-eslint/node_modules/ajv/lib/dotjs/if.js +0 -103
  100. package/packages/config-eslint/node_modules/ajv/lib/dotjs/index.js +0 -33
  101. package/packages/config-eslint/node_modules/ajv/lib/dotjs/items.js +0 -140
  102. package/packages/config-eslint/node_modules/ajv/lib/dotjs/multipleOf.js +0 -80
  103. package/packages/config-eslint/node_modules/ajv/lib/dotjs/not.js +0 -84
  104. package/packages/config-eslint/node_modules/ajv/lib/dotjs/oneOf.js +0 -73
  105. package/packages/config-eslint/node_modules/ajv/lib/dotjs/pattern.js +0 -75
  106. package/packages/config-eslint/node_modules/ajv/lib/dotjs/properties.js +0 -335
  107. package/packages/config-eslint/node_modules/ajv/lib/dotjs/propertyNames.js +0 -81
  108. package/packages/config-eslint/node_modules/ajv/lib/dotjs/ref.js +0 -124
  109. package/packages/config-eslint/node_modules/ajv/lib/dotjs/required.js +0 -270
  110. package/packages/config-eslint/node_modules/ajv/lib/dotjs/uniqueItems.js +0 -86
  111. package/packages/config-eslint/node_modules/ajv/lib/dotjs/validate.js +0 -482
  112. package/packages/config-eslint/node_modules/ajv/lib/keyword.js +0 -146
  113. package/packages/config-eslint/node_modules/ajv/lib/refs/data.json +0 -17
  114. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-04.json +0 -149
  115. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json +0 -154
  116. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-07.json +0 -168
  117. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-secure.json +0 -94
  118. package/packages/config-eslint/node_modules/ajv/package.json +0 -106
  119. package/packages/config-eslint/node_modules/ajv/scripts/.eslintrc.yml +0 -3
  120. package/packages/config-eslint/node_modules/ajv/scripts/bundle.js +0 -61
  121. package/packages/config-eslint/node_modules/ajv/scripts/compile-dots.js +0 -73
  122. package/packages/config-eslint/node_modules/ajv/scripts/info +0 -10
  123. package/packages/config-eslint/node_modules/ajv/scripts/prepare-tests +0 -12
  124. package/packages/config-eslint/node_modules/ajv/scripts/publish-built-version +0 -32
  125. package/packages/config-eslint/node_modules/ajv/scripts/travis-gh-pages +0 -23
  126. package/packages/config-eslint/node_modules/eslint-visitor-keys/LICENSE +0 -201
  127. package/packages/config-eslint/node_modules/eslint-visitor-keys/README.md +0 -105
  128. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +0 -384
  129. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +0 -27
  130. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/index.d.ts +0 -16
  131. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +0 -12
  132. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/index.js +0 -65
  133. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js +0 -315
  134. package/packages/config-eslint/node_modules/eslint-visitor-keys/package.json +0 -74
  135. package/packages/config-eslint/node_modules/espree/LICENSE +0 -25
  136. package/packages/config-eslint/node_modules/espree/README.md +0 -244
  137. package/packages/config-eslint/node_modules/espree/dist/espree.cjs +0 -883
  138. package/packages/config-eslint/node_modules/espree/espree.js +0 -177
  139. package/packages/config-eslint/node_modules/espree/lib/espree.js +0 -349
  140. package/packages/config-eslint/node_modules/espree/lib/features.js +0 -27
  141. package/packages/config-eslint/node_modules/espree/lib/options.js +0 -123
  142. package/packages/config-eslint/node_modules/espree/lib/token-translator.js +0 -263
  143. package/packages/config-eslint/node_modules/espree/lib/version.js +0 -3
  144. package/packages/config-eslint/node_modules/espree/package.json +0 -86
  145. package/packages/config-eslint/node_modules/globals/globals.json +0 -1998
  146. package/packages/config-eslint/node_modules/globals/index.d.ts +0 -2077
  147. package/packages/config-eslint/node_modules/globals/index.js +0 -2
  148. package/packages/config-eslint/node_modules/globals/license +0 -9
  149. package/packages/config-eslint/node_modules/globals/package.json +0 -58
  150. package/packages/config-eslint/node_modules/globals/readme.md +0 -44
  151. package/packages/config-eslint/node_modules/json-schema-traverse/.eslintrc.yml +0 -27
  152. package/packages/config-eslint/node_modules/json-schema-traverse/.travis.yml +0 -8
  153. package/packages/config-eslint/node_modules/json-schema-traverse/LICENSE +0 -21
  154. package/packages/config-eslint/node_modules/json-schema-traverse/README.md +0 -83
  155. package/packages/config-eslint/node_modules/json-schema-traverse/index.js +0 -89
  156. package/packages/config-eslint/node_modules/json-schema-traverse/package.json +0 -43
  157. package/packages/config-eslint/node_modules/json-schema-traverse/spec/.eslintrc.yml +0 -6
  158. package/packages/config-eslint/node_modules/json-schema-traverse/spec/fixtures/schema.js +0 -125
  159. package/packages/config-eslint/node_modules/json-schema-traverse/spec/index.spec.js +0 -171
@@ -1,510 +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
- * @returns {void}
323
- */
324
- function collect(pluginId, defs, map) {
325
- if (defs) {
326
- const prefix = pluginId && `${pluginId}/`;
327
-
328
- for (const [key, value] of Object.entries(defs)) {
329
- map.set(`${prefix}${key}`, value);
330
- }
331
- }
332
- }
333
-
334
- /**
335
- * Delete the mutation methods from a given map.
336
- * @param {Map<any, any>} map The map object to delete.
337
- * @returns {void}
338
- */
339
- function deleteMutationMethods(map) {
340
- Object.defineProperties(map, {
341
- clear: { configurable: true, value: void 0 },
342
- delete: { configurable: true, value: void 0 },
343
- set: { configurable: true, value: void 0 }
344
- });
345
- }
346
-
347
- /**
348
- * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
349
- * @param {ConfigArrayElement[]} elements The config elements.
350
- * @param {ConfigArrayInternalSlots} slots The internal slots.
351
- * @returns {void}
352
- */
353
- function initPluginMemberMaps(elements, slots) {
354
- const processed = new Set();
355
-
356
- slots.envMap = new Map();
357
- slots.processorMap = new Map();
358
- slots.ruleMap = new Map();
359
-
360
- for (const element of elements) {
361
- if (!element.plugins) {
362
- continue;
363
- }
364
-
365
- for (const [pluginId, value] of Object.entries(element.plugins)) {
366
- const plugin = value.definition;
367
-
368
- if (!plugin || processed.has(pluginId)) {
369
- continue;
370
- }
371
- processed.add(pluginId);
372
-
373
- collect(pluginId, plugin.environments, slots.envMap);
374
- collect(pluginId, plugin.processors, slots.processorMap);
375
- collect(pluginId, plugin.rules, slots.ruleMap);
376
- }
377
- }
378
-
379
- deleteMutationMethods(slots.envMap);
380
- deleteMutationMethods(slots.processorMap);
381
- deleteMutationMethods(slots.ruleMap);
382
- }
383
-
384
- /**
385
- * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
386
- * @param {ConfigArray} instance The config elements.
387
- * @returns {ConfigArrayInternalSlots} The extracted config.
388
- */
389
- function ensurePluginMemberMaps(instance) {
390
- const slots = internalSlotsMap.get(instance);
391
-
392
- if (!slots.ruleMap) {
393
- initPluginMemberMaps(instance, slots);
394
- }
395
-
396
- return slots;
397
- }
398
-
399
- //------------------------------------------------------------------------------
400
- // Public Interface
401
- //------------------------------------------------------------------------------
402
-
403
- /**
404
- * The Config Array.
405
- *
406
- * `ConfigArray` instance contains all settings, parsers, and plugins.
407
- * You need to call `ConfigArray#extractConfig(filePath)` method in order to
408
- * extract, merge and get only the config data which is related to an arbitrary
409
- * file.
410
- * @extends {Array<ConfigArrayElement>}
411
- */
412
- class ConfigArray extends Array {
413
-
414
- /**
415
- * Get the plugin environments.
416
- * The returned map cannot be mutated.
417
- * @type {ReadonlyMap<string, Environment>} The plugin environments.
418
- */
419
- get pluginEnvironments() {
420
- return ensurePluginMemberMaps(this).envMap;
421
- }
422
-
423
- /**
424
- * Get the plugin processors.
425
- * The returned map cannot be mutated.
426
- * @type {ReadonlyMap<string, Processor>} The plugin processors.
427
- */
428
- get pluginProcessors() {
429
- return ensurePluginMemberMaps(this).processorMap;
430
- }
431
-
432
- /**
433
- * Get the plugin rules.
434
- * The returned map cannot be mutated.
435
- * @returns {ReadonlyMap<string, Rule>} The plugin rules.
436
- */
437
- get pluginRules() {
438
- return ensurePluginMemberMaps(this).ruleMap;
439
- }
440
-
441
- /**
442
- * Check if this config has `root` flag.
443
- * @returns {boolean} `true` if this config array is root.
444
- */
445
- isRoot() {
446
- for (let i = this.length - 1; i >= 0; --i) {
447
- const root = this[i].root;
448
-
449
- if (typeof root === "boolean") {
450
- return root;
451
- }
452
- }
453
- return false;
454
- }
455
-
456
- /**
457
- * Extract the config data which is related to a given file.
458
- * @param {string} filePath The absolute path to the target file.
459
- * @returns {ExtractedConfig} The extracted config data.
460
- */
461
- extractConfig(filePath) {
462
- const { cache } = internalSlotsMap.get(this);
463
- const indices = getMatchedIndices(this, filePath);
464
- const cacheKey = indices.join(",");
465
-
466
- if (!cache.has(cacheKey)) {
467
- cache.set(cacheKey, createConfig(this, indices));
468
- }
469
-
470
- return cache.get(cacheKey);
471
- }
472
-
473
- /**
474
- * Check if a given path is an additional lint target.
475
- * @param {string} filePath The absolute path to the target file.
476
- * @returns {boolean} `true` if the file is an additional lint target.
477
- */
478
- isAdditionalTargetPath(filePath) {
479
- for (const { criteria, type } of this) {
480
- if (
481
- type === "config" &&
482
- criteria &&
483
- !criteria.endsWithWildcard &&
484
- criteria.test(filePath)
485
- ) {
486
- return true;
487
- }
488
- }
489
- return false;
490
- }
491
- }
492
-
493
- /**
494
- * Get the used extracted configs.
495
- * CLIEngine will use this method to collect used deprecated rules.
496
- * @param {ConfigArray} instance The config array object to get.
497
- * @returns {ExtractedConfig[]} The used extracted configs.
498
- * @private
499
- */
500
- function getUsedExtractedConfigs(instance) {
501
- const { cache } = internalSlotsMap.get(instance);
502
-
503
- return Array.from(cache.values());
504
- }
505
-
506
-
507
- export {
508
- ConfigArray,
509
- getUsedExtractedConfigs
510
- };
@@ -1,124 +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 {T} [data.original] The original, non-normalized dependency if the loading succeeded.
32
- * @param {Error} [data.error] The error object if the loading failed.
33
- * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded.
34
- * @param {string} data.id The ID of this dependency.
35
- * @param {string} data.importerName The name of the config file which loads this dependency.
36
- * @param {string} data.importerPath The path to the config file which loads this dependency.
37
- */
38
- constructor({
39
- definition = null,
40
- original = null,
41
- error = null,
42
- filePath = null,
43
- id,
44
- importerName,
45
- importerPath
46
- }) {
47
-
48
- /**
49
- * The loaded dependency if the loading succeeded.
50
- * @type {T|null}
51
- */
52
- this.definition = definition;
53
-
54
- /**
55
- * The original dependency as loaded directly from disk if the loading succeeded.
56
- * @type {T|null}
57
- */
58
- this.original = original;
59
-
60
- /**
61
- * The error object if the loading failed.
62
- * @type {Error|null}
63
- */
64
- this.error = error;
65
-
66
- /**
67
- * The loaded dependency if the loading succeeded.
68
- * @type {string|null}
69
- */
70
- this.filePath = filePath;
71
-
72
- /**
73
- * The ID of this dependency.
74
- * @type {string}
75
- */
76
- this.id = id;
77
-
78
- /**
79
- * The name of the config file which loads this dependency.
80
- * @type {string}
81
- */
82
- this.importerName = importerName;
83
-
84
- /**
85
- * The path to the config file which loads this dependency.
86
- * @type {string}
87
- */
88
- this.importerPath = importerPath;
89
- }
90
-
91
- // eslint-disable-next-line jsdoc/require-description
92
- /**
93
- * @returns {Object} a JSON compatible object.
94
- */
95
- toJSON() {
96
- const obj = this[util.inspect.custom]();
97
-
98
- // Display `error.message` (`Error#message` is unenumerable).
99
- if (obj.error instanceof Error) {
100
- obj.error = { ...obj.error, message: obj.error.message };
101
- }
102
-
103
- return obj;
104
- }
105
-
106
- // eslint-disable-next-line jsdoc/require-description
107
- /**
108
- * @returns {Object} an object to display by `console.log()`.
109
- */
110
- [util.inspect.custom]() {
111
- const {
112
- definition: _ignore1, // eslint-disable-line no-unused-vars
113
- original: _ignore2, // eslint-disable-line no-unused-vars
114
- ...obj
115
- } = this;
116
-
117
- return obj;
118
- }
119
- }
120
-
121
- /** @typedef {ConfigDependency<import("../../shared/types").Parser>} DependentParser */
122
- /** @typedef {ConfigDependency<import("../../shared/types").Plugin>} DependentPlugin */
123
-
124
- export { ConfigDependency };