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,135 @@
1
+ /**
2
+ * @fileoverview Config file operations. This file must be usable in the browser,
3
+ * so no Node-specific code can be here.
4
+ * @author Nicholas C. Zakas
5
+ */
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Private
9
+ //------------------------------------------------------------------------------
10
+
11
+ const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
12
+ RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
13
+ map[value] = index;
14
+ return map;
15
+ }, {}),
16
+ VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
17
+
18
+ //------------------------------------------------------------------------------
19
+ // Public Interface
20
+ //------------------------------------------------------------------------------
21
+
22
+ /**
23
+ * Normalizes the severity value of a rule's configuration to a number
24
+ * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
25
+ * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
26
+ * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
27
+ * whose first element is one of the above values. Strings are matched case-insensitively.
28
+ * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
29
+ */
30
+ function getRuleSeverity(ruleConfig) {
31
+ const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
32
+
33
+ if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
34
+ return severityValue;
35
+ }
36
+
37
+ if (typeof severityValue === "string") {
38
+ return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
39
+ }
40
+
41
+ return 0;
42
+ }
43
+
44
+ /**
45
+ * Converts old-style severity settings (0, 1, 2) into new-style
46
+ * severity settings (off, warn, error) for all rules. Assumption is that severity
47
+ * values have already been validated as correct.
48
+ * @param {Object} config The config object to normalize.
49
+ * @returns {void}
50
+ */
51
+ function normalizeToStrings(config) {
52
+
53
+ if (config.rules) {
54
+ Object.keys(config.rules).forEach(ruleId => {
55
+ const ruleConfig = config.rules[ruleId];
56
+
57
+ if (typeof ruleConfig === "number") {
58
+ config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
59
+ } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
60
+ ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
61
+ }
62
+ });
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Determines if the severity for the given rule configuration represents an error.
68
+ * @param {int|string|Array} ruleConfig The configuration for an individual rule.
69
+ * @returns {boolean} True if the rule represents an error, false if not.
70
+ */
71
+ function isErrorSeverity(ruleConfig) {
72
+ return getRuleSeverity(ruleConfig) === 2;
73
+ }
74
+
75
+ /**
76
+ * Checks whether a given config has valid severity or not.
77
+ * @param {number|string|Array} ruleConfig The configuration for an individual rule.
78
+ * @returns {boolean} `true` if the configuration has valid severity.
79
+ */
80
+ function isValidSeverity(ruleConfig) {
81
+ let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
82
+
83
+ if (typeof severity === "string") {
84
+ severity = severity.toLowerCase();
85
+ }
86
+ return VALID_SEVERITIES.indexOf(severity) !== -1;
87
+ }
88
+
89
+ /**
90
+ * Checks whether every rule of a given config has valid severity or not.
91
+ * @param {Object} config The configuration for rules.
92
+ * @returns {boolean} `true` if the configuration has valid severity.
93
+ */
94
+ function isEverySeverityValid(config) {
95
+ return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId]));
96
+ }
97
+
98
+ /**
99
+ * Normalizes a value for a global in a config
100
+ * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in
101
+ * a global directive comment
102
+ * @returns {("readable"|"writeable"|"off")} The value normalized as a string
103
+ * @throws Error if global value is invalid
104
+ */
105
+ function normalizeConfigGlobal(configuredValue) {
106
+ switch (configuredValue) {
107
+ case "off":
108
+ return "off";
109
+
110
+ case true:
111
+ case "true":
112
+ case "writeable":
113
+ case "writable":
114
+ return "writable";
115
+
116
+ case null:
117
+ case false:
118
+ case "false":
119
+ case "readable":
120
+ case "readonly":
121
+ return "readonly";
122
+
123
+ default:
124
+ throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`);
125
+ }
126
+ }
127
+
128
+ export {
129
+ getRuleSeverity,
130
+ normalizeToStrings,
131
+ isErrorSeverity,
132
+ isValidSeverity,
133
+ isEverySeverityValid,
134
+ normalizeConfigGlobal
135
+ };
@@ -0,0 +1,325 @@
1
+ /**
2
+ * @fileoverview Validates configs.
3
+ * @author Brandon Mills
4
+ */
5
+
6
+ /* eslint class-methods-use-this: "off" */
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ import util from "util";
13
+ import * as ConfigOps from "./config-ops.js";
14
+ import { emitDeprecationWarning } from "./deprecation-warnings.js";
15
+ import ajvOrig from "./ajv.js";
16
+ import configSchema from "../../conf/config-schema.js";
17
+ import BuiltInEnvironments from "../../conf/environments.js";
18
+
19
+ const ajv = ajvOrig();
20
+
21
+ const ruleValidators = new WeakMap();
22
+ const noop = Function.prototype;
23
+
24
+ //------------------------------------------------------------------------------
25
+ // Private
26
+ //------------------------------------------------------------------------------
27
+ let validateSchema;
28
+ const severityMap = {
29
+ error: 2,
30
+ warn: 1,
31
+ off: 0
32
+ };
33
+
34
+ const validated = new WeakSet();
35
+
36
+ //-----------------------------------------------------------------------------
37
+ // Exports
38
+ //-----------------------------------------------------------------------------
39
+
40
+ export default class ConfigValidator {
41
+ constructor({ builtInRules = new Map() } = {}) {
42
+ this.builtInRules = builtInRules;
43
+ }
44
+
45
+ /**
46
+ * Gets a complete options schema for a rule.
47
+ * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
48
+ * @returns {Object} JSON Schema for the rule's options.
49
+ */
50
+ getRuleOptionsSchema(rule) {
51
+ if (!rule) {
52
+ return null;
53
+ }
54
+
55
+ const schema = rule.schema || rule.meta && rule.meta.schema;
56
+
57
+ // Given a tuple of schemas, insert warning level at the beginning
58
+ if (Array.isArray(schema)) {
59
+ if (schema.length) {
60
+ return {
61
+ type: "array",
62
+ items: schema,
63
+ minItems: 0,
64
+ maxItems: schema.length
65
+ };
66
+ }
67
+ return {
68
+ type: "array",
69
+ minItems: 0,
70
+ maxItems: 0
71
+ };
72
+
73
+ }
74
+
75
+ // Given a full schema, leave it alone
76
+ return schema || null;
77
+ }
78
+
79
+ /**
80
+ * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
81
+ * @param {options} options The given options for the rule.
82
+ * @returns {number|string} The rule's severity value
83
+ */
84
+ validateRuleSeverity(options) {
85
+ const severity = Array.isArray(options) ? options[0] : options;
86
+ const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
87
+
88
+ if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
89
+ return normSeverity;
90
+ }
91
+
92
+ throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
93
+
94
+ }
95
+
96
+ /**
97
+ * Validates the non-severity options passed to a rule, based on its schema.
98
+ * @param {{create: Function}} rule The rule to validate
99
+ * @param {Array} localOptions The options for the rule, excluding severity
100
+ * @returns {void}
101
+ */
102
+ validateRuleSchema(rule, localOptions) {
103
+ if (!ruleValidators.has(rule)) {
104
+ const schema = this.getRuleOptionsSchema(rule);
105
+
106
+ if (schema) {
107
+ ruleValidators.set(rule, ajv.compile(schema));
108
+ }
109
+ }
110
+
111
+ const validateRule = ruleValidators.get(rule);
112
+
113
+ if (validateRule) {
114
+ validateRule(localOptions);
115
+ if (validateRule.errors) {
116
+ throw new Error(validateRule.errors.map(
117
+ error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
118
+ ).join(""));
119
+ }
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Validates a rule's options against its schema.
125
+ * @param {{create: Function}|null} rule The rule that the config is being validated for
126
+ * @param {string} ruleId The rule's unique name.
127
+ * @param {Array|number} options The given options for the rule.
128
+ * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
129
+ * no source is prepended to the message.
130
+ * @returns {void}
131
+ */
132
+ validateRuleOptions(rule, ruleId, options, source = null) {
133
+ try {
134
+ const severity = this.validateRuleSeverity(options);
135
+
136
+ if (severity !== 0) {
137
+ this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
138
+ }
139
+ } catch (err) {
140
+ const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
141
+
142
+ if (typeof source === "string") {
143
+ throw new Error(`${source}:\n\t${enhancedMessage}`);
144
+ } else {
145
+ throw new Error(enhancedMessage);
146
+ }
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Validates an environment object
152
+ * @param {Object} environment The environment config object to validate.
153
+ * @param {string} source The name of the configuration source to report in any errors.
154
+ * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
155
+ * @returns {void}
156
+ */
157
+ validateEnvironment(
158
+ environment,
159
+ source,
160
+ getAdditionalEnv = noop
161
+ ) {
162
+
163
+ // not having an environment is ok
164
+ if (!environment) {
165
+ return;
166
+ }
167
+
168
+ Object.keys(environment).forEach(id => {
169
+ const env = getAdditionalEnv(id) || BuiltInEnvironments.get(id) || null;
170
+
171
+ if (!env) {
172
+ const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`;
173
+
174
+ throw new Error(message);
175
+ }
176
+ });
177
+ }
178
+
179
+ /**
180
+ * Validates a rules config object
181
+ * @param {Object} rulesConfig The rules config object to validate.
182
+ * @param {string} source The name of the configuration source to report in any errors.
183
+ * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
184
+ * @returns {void}
185
+ */
186
+ validateRules(
187
+ rulesConfig,
188
+ source,
189
+ getAdditionalRule = noop
190
+ ) {
191
+ if (!rulesConfig) {
192
+ return;
193
+ }
194
+
195
+ Object.keys(rulesConfig).forEach(id => {
196
+ const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null;
197
+
198
+ this.validateRuleOptions(rule, id, rulesConfig[id], source);
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Validates a `globals` section of a config file
204
+ * @param {Object} globalsConfig The `globals` section
205
+ * @param {string|null} source The name of the configuration source to report in the event of an error.
206
+ * @returns {void}
207
+ */
208
+ validateGlobals(globalsConfig, source = null) {
209
+ if (!globalsConfig) {
210
+ return;
211
+ }
212
+
213
+ Object.entries(globalsConfig)
214
+ .forEach(([configuredGlobal, configuredValue]) => {
215
+ try {
216
+ ConfigOps.normalizeConfigGlobal(configuredValue);
217
+ } catch (err) {
218
+ throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`);
219
+ }
220
+ });
221
+ }
222
+
223
+ /**
224
+ * Validate `processor` configuration.
225
+ * @param {string|undefined} processorName The processor name.
226
+ * @param {string} source The name of config file.
227
+ * @param {function(id:string): Processor} getProcessor The getter of defined processors.
228
+ * @returns {void}
229
+ */
230
+ validateProcessor(processorName, source, getProcessor) {
231
+ if (processorName && !getProcessor(processorName)) {
232
+ throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`);
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Formats an array of schema validation errors.
238
+ * @param {Array} errors An array of error messages to format.
239
+ * @returns {string} Formatted error message
240
+ */
241
+ formatErrors(errors) {
242
+ return errors.map(error => {
243
+ if (error.keyword === "additionalProperties") {
244
+ const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
245
+
246
+ return `Unexpected top-level property "${formattedPropertyPath}"`;
247
+ }
248
+ if (error.keyword === "type") {
249
+ const formattedField = error.dataPath.slice(1);
250
+ const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
251
+ const formattedValue = JSON.stringify(error.data);
252
+
253
+ return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
254
+ }
255
+
256
+ const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
257
+
258
+ return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
259
+ }).map(message => `\t- ${message}.\n`).join("");
260
+ }
261
+
262
+ /**
263
+ * Validates the top level properties of the config object.
264
+ * @param {Object} config The config object to validate.
265
+ * @param {string} source The name of the configuration source to report in any errors.
266
+ * @returns {void}
267
+ */
268
+ validateConfigSchema(config, source = null) {
269
+ validateSchema = validateSchema || ajv.compile(configSchema);
270
+
271
+ if (!validateSchema(config)) {
272
+ throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
273
+ }
274
+
275
+ if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
276
+ emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Validates an entire config object.
282
+ * @param {Object} config The config object to validate.
283
+ * @param {string} source The name of the configuration source to report in any errors.
284
+ * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
285
+ * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
286
+ * @returns {void}
287
+ */
288
+ validate(config, source, getAdditionalRule, getAdditionalEnv) {
289
+ this.validateConfigSchema(config, source);
290
+ this.validateRules(config.rules, source, getAdditionalRule);
291
+ this.validateEnvironment(config.env, source, getAdditionalEnv);
292
+ this.validateGlobals(config.globals, source);
293
+
294
+ for (const override of config.overrides || []) {
295
+ this.validateRules(override.rules, source, getAdditionalRule);
296
+ this.validateEnvironment(override.env, source, getAdditionalEnv);
297
+ this.validateGlobals(config.globals, source);
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Validate config array object.
303
+ * @param {ConfigArray} configArray The config array to validate.
304
+ * @returns {void}
305
+ */
306
+ validateConfigArray(configArray) {
307
+ const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments);
308
+ const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors);
309
+ const getPluginRule = Map.prototype.get.bind(configArray.pluginRules);
310
+
311
+ // Validate.
312
+ for (const element of configArray) {
313
+ if (validated.has(element)) {
314
+ continue;
315
+ }
316
+ validated.add(element);
317
+
318
+ this.validateEnvironment(element.env, element.name, getPluginEnv);
319
+ this.validateGlobals(element.globals, element.name);
320
+ this.validateProcessor(element.processor, element.name, getPluginProcessor);
321
+ this.validateRules(element.rules, element.name, getPluginRule);
322
+ }
323
+ }
324
+
325
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @fileoverview Provide the function that emits deprecation warnings.
3
+ * @author Toru Nagashima <http://github.com/mysticatea>
4
+ */
5
+
6
+ //------------------------------------------------------------------------------
7
+ // Requirements
8
+ //------------------------------------------------------------------------------
9
+
10
+ import path from "path";
11
+
12
+ //------------------------------------------------------------------------------
13
+ // Private
14
+ //------------------------------------------------------------------------------
15
+
16
+ // Defitions for deprecation warnings.
17
+ const deprecationWarningMessages = {
18
+ ESLINT_LEGACY_ECMAFEATURES:
19
+ "The 'ecmaFeatures' config file property is deprecated and has no effect.",
20
+ ESLINT_PERSONAL_CONFIG_LOAD:
21
+ "'~/.eslintrc.*' config files have been deprecated. " +
22
+ "Please use a config file per project or the '--config' option.",
23
+ ESLINT_PERSONAL_CONFIG_SUPPRESS:
24
+ "'~/.eslintrc.*' config files have been deprecated. " +
25
+ "Please remove it or add 'root:true' to the config files in your " +
26
+ "projects in order to avoid loading '~/.eslintrc.*' accidentally."
27
+ };
28
+
29
+ const sourceFileErrorCache = new Set();
30
+
31
+ /**
32
+ * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
33
+ * for each unique file path, but repeated invocations with the same file path have no effect.
34
+ * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
35
+ * @param {string} source The name of the configuration source to report the warning for.
36
+ * @param {string} errorCode The warning message to show.
37
+ * @returns {void}
38
+ */
39
+ function emitDeprecationWarning(source, errorCode) {
40
+ const cacheKey = JSON.stringify({ source, errorCode });
41
+
42
+ if (sourceFileErrorCache.has(cacheKey)) {
43
+ return;
44
+ }
45
+ sourceFileErrorCache.add(cacheKey);
46
+
47
+ const rel = path.relative(process.cwd(), source);
48
+ const message = deprecationWarningMessages[errorCode];
49
+
50
+ process.emitWarning(
51
+ `${message} (found in "${rel}")`,
52
+ "DeprecationWarning",
53
+ errorCode
54
+ );
55
+ }
56
+
57
+ //------------------------------------------------------------------------------
58
+ // Public Interface
59
+ //------------------------------------------------------------------------------
60
+
61
+ export {
62
+ emitDeprecationWarning
63
+ };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @fileoverview Common helpers for naming of plugins, formatters and configs
3
+ */
4
+
5
+ const NAMESPACE_REGEX = /^@.*\//iu;
6
+
7
+ /**
8
+ * Brings package name to correct format based on prefix
9
+ * @param {string} name The name of the package.
10
+ * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
11
+ * @returns {string} Normalized name of the package
12
+ * @private
13
+ */
14
+ function normalizePackageName(name, prefix) {
15
+ let normalizedName = name;
16
+
17
+ /**
18
+ * On Windows, name can come in with Windows slashes instead of Unix slashes.
19
+ * Normalize to Unix first to avoid errors later on.
20
+ * https://github.com/eslint/eslint/issues/5644
21
+ */
22
+ if (normalizedName.includes("\\")) {
23
+ normalizedName = normalizedName.replace(/\\/gu, "/");
24
+ }
25
+
26
+ if (normalizedName.charAt(0) === "@") {
27
+
28
+ /**
29
+ * it's a scoped package
30
+ * package name is the prefix, or just a username
31
+ */
32
+ const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
33
+ scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
34
+
35
+ if (scopedPackageShortcutRegex.test(normalizedName)) {
36
+ normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
37
+ } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
38
+
39
+ /**
40
+ * for scoped packages, insert the prefix after the first / unless
41
+ * the path is already @scope/eslint or @scope/eslint-xxx-yyy
42
+ */
43
+ normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
44
+ }
45
+ } else if (!normalizedName.startsWith(`${prefix}-`)) {
46
+ normalizedName = `${prefix}-${normalizedName}`;
47
+ }
48
+
49
+ return normalizedName;
50
+ }
51
+
52
+ /**
53
+ * Removes the prefix from a fullname.
54
+ * @param {string} fullname The term which may have the prefix.
55
+ * @param {string} prefix The prefix to remove.
56
+ * @returns {string} The term without prefix.
57
+ */
58
+ function getShorthandName(fullname, prefix) {
59
+ if (fullname[0] === "@") {
60
+ let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
61
+
62
+ if (matchResult) {
63
+ return matchResult[1];
64
+ }
65
+
66
+ matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
67
+ if (matchResult) {
68
+ return `${matchResult[1]}/${matchResult[2]}`;
69
+ }
70
+ } else if (fullname.startsWith(`${prefix}-`)) {
71
+ return fullname.slice(prefix.length + 1);
72
+ }
73
+
74
+ return fullname;
75
+ }
76
+
77
+ /**
78
+ * Gets the scope (namespace) of a term.
79
+ * @param {string} term The term which may have the namespace.
80
+ * @returns {string} The namespace of the term if it has one.
81
+ */
82
+ function getNamespaceFromTerm(term) {
83
+ const match = term.match(NAMESPACE_REGEX);
84
+
85
+ return match ? match[0] : "";
86
+ }
87
+
88
+ //------------------------------------------------------------------------------
89
+ // Public Interface
90
+ //------------------------------------------------------------------------------
91
+
92
+ export {
93
+ normalizePackageName,
94
+ getShorthandName,
95
+ getNamespaceFromTerm
96
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Utility for resolving a module relative to another module
3
+ * @author Teddy Katz
4
+ */
5
+
6
+ import Module from "module";
7
+
8
+ /*
9
+ * `Module.createRequire` is added in v12.2.0. It supports URL as well.
10
+ * We only support the case where the argument is a filepath, not a URL.
11
+ */
12
+ const createRequire = Module.createRequire;
13
+
14
+ /**
15
+ * Resolves a Node module relative to another module
16
+ * @param {string} moduleName The name of a Node module, or a path to a Node module.
17
+ * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
18
+ * a file rather than a directory, but the file need not actually exist.
19
+ * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
20
+ */
21
+ function resolve(moduleName, relativeToPath) {
22
+ try {
23
+ return createRequire(relativeToPath).resolve(moduleName);
24
+ } catch (error) {
25
+
26
+ // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
27
+ if (
28
+ typeof error === "object" &&
29
+ error !== null &&
30
+ error.code === "MODULE_NOT_FOUND" &&
31
+ !error.requireStack &&
32
+ error.message.includes(moduleName)
33
+ ) {
34
+ error.message += `\nRequire stack:\n- ${relativeToPath}`;
35
+ }
36
+ throw error;
37
+ }
38
+ }
39
+
40
+ export {
41
+ resolve
42
+ };