immosquare-cleaner 0.1.23 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immosquare-cleaner/version.rb +1 -1
  3. data/linters/rubocop-3.2.2.yml +1 -0
  4. data/linters/rubocop.yml +2 -0
  5. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/LICENSE +19 -0
  6. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/README.md +71 -0
  7. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/conf/config-schema.js +79 -0
  8. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/conf/environments.js +215 -0
  9. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
  10. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
  11. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4333 -0
  12. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
  13. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +532 -0
  14. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +523 -0
  15. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +115 -0
  16. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +145 -0
  17. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +238 -0
  18. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js +19 -0
  19. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +225 -0
  20. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js +1149 -0
  21. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js +318 -0
  22. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index-universal.js +29 -0
  23. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js +56 -0
  24. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js +191 -0
  25. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +135 -0
  26. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +325 -0
  27. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +63 -0
  28. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js +96 -0
  29. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +42 -0
  30. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/types.js +149 -0
  31. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/index.d.ts +36 -0
  32. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/index.js +77 -0
  33. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/license +9 -0
  34. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/package.json +47 -0
  35. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/readme.md +78 -0
  36. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/package.json +82 -0
  37. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/universal.js +9 -0
  38. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/LICENSE +19 -0
  39. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/README.md +57 -0
  40. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/package.json +31 -0
  41. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/configs/eslint-all.js +278 -0
  42. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js +76 -0
  43. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/index.js +17 -0
  44. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/LICENSE +201 -0
  45. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/README.md +342 -0
  46. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/api.js +1061 -0
  47. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +8 -0
  48. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/LICENSE +29 -0
  49. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/README.md +234 -0
  50. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/package.json +33 -0
  51. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/index.js +7 -0
  52. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +53 -0
  53. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/object-schema.js +235 -0
  54. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +102 -0
  55. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +66 -0
  56. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +611 -0
  57. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +186 -0
  58. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/LICENSE +15 -0
  59. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/README.md +224 -0
  60. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/minimatch.js +947 -0
  61. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
  62. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
  63. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
  64. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
  65. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/package.json +33 -0
  66. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/package.json +61 -0
  67. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/index.d.ts +415 -0
  68. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/license +9 -0
  69. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/package.json +68 -0
  70. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/readme.md +341 -0
  71. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/index.js +229 -0
  72. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/templates.js +134 -0
  73. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/util.js +39 -0
  74. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/LICENSE +15 -0
  75. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/README.md +230 -0
  76. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/minimatch.js +947 -0
  77. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
  78. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
  79. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
  80. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
  81. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/package.json +33 -0
  82. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/index.d.ts +17 -0
  83. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/index.js +4 -0
  84. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/license +9 -0
  85. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
  86. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
  87. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/license +9 -0
  88. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
  89. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
  90. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/package.json +54 -0
  91. data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/readme.md +46 -0
  92. data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/index.js +162 -0
  93. data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/license.md +21 -0
  94. data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/package.json +38 -0
  95. data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/readme.md +59 -0
  96. data/node_modules/npm-check-updates/build/package.json +2 -3
  97. data/node_modules/npm-check-updates/build/src/lib/runGlobal.js +18 -11
  98. data/node_modules/npm-check-updates/build/src/lib/runGlobal.js.map +1 -1
  99. data/node_modules/npm-check-updates/build/src/package-managers/bun.js +2 -3
  100. data/node_modules/npm-check-updates/build/src/package-managers/bun.js.map +1 -1
  101. data/node_modules/npm-check-updates/build/src/package-managers/npm.js +12 -8
  102. data/node_modules/npm-check-updates/build/src/package-managers/npm.js.map +1 -1
  103. data/node_modules/npm-check-updates/build/src/package-managers/pnpm.js +37 -14
  104. data/node_modules/npm-check-updates/build/src/package-managers/pnpm.js.map +1 -1
  105. data/node_modules/npm-check-updates/build/src/package-managers/yarn.js +36 -11
  106. data/node_modules/npm-check-updates/build/src/package-managers/yarn.js.map +1 -1
  107. data/node_modules/npm-check-updates/package.json +2 -3
  108. data/node_modules/prettier/LICENSE +3 -3
  109. data/node_modules/prettier/index.cjs +1 -1
  110. data/node_modules/prettier/index.mjs +14 -22
  111. data/node_modules/prettier/package.json +1 -1
  112. data/node_modules/prettier/plugins/acorn.js +10 -10
  113. data/node_modules/prettier/plugins/acorn.mjs +10 -10
  114. data/node_modules/prettier/plugins/angular.js +1 -1
  115. data/node_modules/prettier/plugins/angular.mjs +1 -1
  116. data/node_modules/prettier/plugins/babel.js +8 -8
  117. data/node_modules/prettier/plugins/babel.mjs +8 -8
  118. data/node_modules/prettier/plugins/estree.js +24 -24
  119. data/node_modules/prettier/plugins/estree.mjs +24 -24
  120. data/node_modules/prettier/plugins/flow.js +17 -17
  121. data/node_modules/prettier/plugins/flow.mjs +17 -17
  122. data/node_modules/prettier/plugins/graphql.js +6 -6
  123. data/node_modules/prettier/plugins/graphql.mjs +6 -6
  124. data/node_modules/prettier/plugins/html.js +1 -1
  125. data/node_modules/prettier/plugins/html.mjs +1 -1
  126. data/node_modules/prettier/plugins/markdown.js +1 -1
  127. data/node_modules/prettier/plugins/markdown.mjs +1 -1
  128. data/node_modules/prettier/plugins/meriyah.js +4 -4
  129. data/node_modules/prettier/plugins/meriyah.mjs +4 -4
  130. data/node_modules/prettier/plugins/typescript.js +19 -19
  131. data/node_modules/prettier/plugins/typescript.mjs +19 -19
  132. data/node_modules/prettier/standalone.js +10 -10
  133. data/node_modules/prettier/standalone.mjs +9 -9
  134. data/package.json +2 -2
  135. metadata +95 -4
@@ -0,0 +1,523 @@
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
+ };
@@ -0,0 +1,115 @@
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 };