immosquare-cleaner 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/lib/immosquare-cleaner.rb +3 -2
- data/linters/eslintrc.json +54 -27
- data/package.json +7 -8
- metadata +30 -69
- data/node_modules/eslint-plugin-jsonc/LICENSE +0 -21
- data/node_modules/eslint-plugin-jsonc/README.md +0 -279
- data/node_modules/eslint-plugin-jsonc/conf/eslint-all.js +0 -11
- data/node_modules/eslint-plugin-jsonc/conf/eslint-recommended.js +0 -13
- data/node_modules/eslint-plugin-jsonc/conf/rules.js +0 -10
- data/node_modules/eslint-plugin-jsonc/dist/configs/all.js +0 -18
- data/node_modules/eslint-plugin-jsonc/dist/configs/auto-config.js +0 -13
- data/node_modules/eslint-plugin-jsonc/dist/configs/base.js +0 -15
- data/node_modules/eslint-plugin-jsonc/dist/configs/prettier.js +0 -26
- data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-json.js +0 -41
- data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-json5.js +0 -30
- data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-jsonc.js +0 -39
- data/node_modules/eslint-plugin-jsonc/dist/index.js +0 -68
- data/node_modules/eslint-plugin-jsonc/dist/meta.js +0 -5
- data/node_modules/eslint-plugin-jsonc/dist/rules/array-bracket-newline.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/array-bracket-spacing.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/array-element-newline.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/auto.js +0 -66
- data/node_modules/eslint-plugin-jsonc/dist/rules/comma-dangle.js +0 -27
- data/node_modules/eslint-plugin-jsonc/dist/rules/comma-style.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/indent.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/key-name-casing.js +0 -94
- data/node_modules/eslint-plugin-jsonc/dist/rules/key-spacing.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-bigint-literals.js +0 -33
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-binary-expression.js +0 -38
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-binary-numeric-literals.js +0 -39
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-comments.js +0 -34
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-dupe-keys.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-escape-sequence-in-identifier.js +0 -57
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-floating-decimal.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-hexadecimal-numeric-literals.js +0 -39
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-infinity.js +0 -37
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-irregular-whitespace.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-multi-str.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-nan.js +0 -37
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-number-props.js +0 -41
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-numeric-separators.js +0 -42
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal-escape.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal-numeric-literals.js +0 -39
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-parenthesized.js +0 -70
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-plus-sign.js +0 -39
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-regexp-literals.js +0 -33
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-sparse-arrays.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-template-literals.js +0 -36
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-undefined-value.js +0 -35
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-unicode-codepoint-escapes.js +0 -73
- data/node_modules/eslint-plugin-jsonc/dist/rules/no-useless-escape.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/object-curly-newline.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/object-curly-spacing.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/object-property-newline.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/quote-props.js +0 -27
- data/node_modules/eslint-plugin-jsonc/dist/rules/quotes.js +0 -27
- data/node_modules/eslint-plugin-jsonc/dist/rules/sort-array-values.js +0 -371
- data/node_modules/eslint-plugin-jsonc/dist/rules/sort-keys.js +0 -413
- data/node_modules/eslint-plugin-jsonc/dist/rules/space-unary-ops.js +0 -23
- data/node_modules/eslint-plugin-jsonc/dist/rules/valid-json-number.js +0 -138
- data/node_modules/eslint-plugin-jsonc/dist/rules/vue-custom-block/no-parsing-error.js +0 -86
- data/node_modules/eslint-plugin-jsonc/dist/types.js +0 -2
- data/node_modules/eslint-plugin-jsonc/dist/utils/casing.js +0 -134
- data/node_modules/eslint-plugin-jsonc/dist/utils/get-auto-jsonc-rules-config.js +0 -97
- data/node_modules/eslint-plugin-jsonc/dist/utils/index.js +0 -121
- data/node_modules/eslint-plugin-jsonc/dist/utils/rules.js +0 -96
- data/node_modules/eslint-plugin-jsonc/index.d.ts +0 -364
- data/node_modules/eslint-plugin-jsonc/package.json +0 -123
@@ -1,371 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const natural_compare_1 = __importDefault(require("natural-compare"));
|
7
|
-
const utils_1 = require("../utils");
|
8
|
-
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
9
|
-
const jsonc_eslint_parser_1 = require("jsonc-eslint-parser");
|
10
|
-
class JSONElementData {
|
11
|
-
get reportLoc() {
|
12
|
-
if (this.node) {
|
13
|
-
return this.node.loc;
|
14
|
-
}
|
15
|
-
const aroundTokens = this.aroundTokens;
|
16
|
-
return {
|
17
|
-
start: aroundTokens.before.loc.end,
|
18
|
-
end: aroundTokens.after.loc.start,
|
19
|
-
};
|
20
|
-
}
|
21
|
-
get range() {
|
22
|
-
if (this.node) {
|
23
|
-
return this.node.range;
|
24
|
-
}
|
25
|
-
if (this.cachedRange) {
|
26
|
-
return this.cachedRange;
|
27
|
-
}
|
28
|
-
const aroundTokens = this.aroundTokens;
|
29
|
-
return (this.cachedRange = [
|
30
|
-
aroundTokens.before.range[1],
|
31
|
-
aroundTokens.after.range[0],
|
32
|
-
]);
|
33
|
-
}
|
34
|
-
get aroundTokens() {
|
35
|
-
if (this.cachedAroundTokens) {
|
36
|
-
return this.cachedAroundTokens;
|
37
|
-
}
|
38
|
-
const sourceCode = this.array.sourceCode;
|
39
|
-
if (this.node) {
|
40
|
-
return (this.cachedAroundTokens = {
|
41
|
-
before: sourceCode.getTokenBefore(this.node),
|
42
|
-
after: sourceCode.getTokenAfter(this.node),
|
43
|
-
});
|
44
|
-
}
|
45
|
-
const before = this.index > 0
|
46
|
-
? this.array.elements[this.index - 1].aroundTokens.after
|
47
|
-
: sourceCode.getFirstToken(this.array.node);
|
48
|
-
const after = sourceCode.getTokenAfter(before);
|
49
|
-
return (this.cachedAroundTokens = { before, after });
|
50
|
-
}
|
51
|
-
constructor(array, node, index) {
|
52
|
-
this.cached = null;
|
53
|
-
this.cachedRange = null;
|
54
|
-
this.cachedAroundTokens = null;
|
55
|
-
this.array = array;
|
56
|
-
this.node = node;
|
57
|
-
this.index = index;
|
58
|
-
}
|
59
|
-
get value() {
|
60
|
-
var _a;
|
61
|
-
return ((_a = this.cached) !== null && _a !== void 0 ? _a : (this.cached = {
|
62
|
-
value: this.node == null ? null : (0, jsonc_eslint_parser_1.getStaticJSONValue)(this.node),
|
63
|
-
})).value;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
class JSONArrayData {
|
67
|
-
constructor(node, sourceCode) {
|
68
|
-
this.cachedElements = null;
|
69
|
-
this.node = node;
|
70
|
-
this.sourceCode = sourceCode;
|
71
|
-
}
|
72
|
-
get elements() {
|
73
|
-
var _a;
|
74
|
-
return ((_a = this.cachedElements) !== null && _a !== void 0 ? _a : (this.cachedElements = this.node.elements.map((e, index) => new JSONElementData(this, e, index))));
|
75
|
-
}
|
76
|
-
}
|
77
|
-
function buildValidatorFromType(order, insensitive, natural) {
|
78
|
-
let compareValue = ([a, b]) => a <= b;
|
79
|
-
let compareText = compareValue;
|
80
|
-
if (natural) {
|
81
|
-
compareText = ([a, b]) => (0, natural_compare_1.default)(a, b) <= 0;
|
82
|
-
}
|
83
|
-
if (insensitive) {
|
84
|
-
const baseCompareText = compareText;
|
85
|
-
compareText = ([a, b]) => baseCompareText([a.toLowerCase(), b.toLowerCase()]);
|
86
|
-
}
|
87
|
-
if (order === "desc") {
|
88
|
-
const baseCompareText = compareText;
|
89
|
-
compareText = (args) => baseCompareText(args.reverse());
|
90
|
-
const baseCompareValue = compareValue;
|
91
|
-
compareValue = (args) => baseCompareValue(args.reverse());
|
92
|
-
}
|
93
|
-
return (a, b) => {
|
94
|
-
if (typeof a.value === "string" && typeof b.value === "string") {
|
95
|
-
return compareText([a.value, b.value]);
|
96
|
-
}
|
97
|
-
const type = getJSONPrimitiveType(a.value);
|
98
|
-
if (type && type === getJSONPrimitiveType(b.value)) {
|
99
|
-
return compareValue([a.value, b.value]);
|
100
|
-
}
|
101
|
-
return true;
|
102
|
-
};
|
103
|
-
}
|
104
|
-
function parseOptions(options) {
|
105
|
-
return options.map((opt) => {
|
106
|
-
var _a, _b, _c, _d;
|
107
|
-
const order = opt.order;
|
108
|
-
const pathPattern = new RegExp(opt.pathPattern);
|
109
|
-
const minValues = (_a = opt.minValues) !== null && _a !== void 0 ? _a : 2;
|
110
|
-
if (!Array.isArray(order)) {
|
111
|
-
const type = (_b = order.type) !== null && _b !== void 0 ? _b : "asc";
|
112
|
-
const insensitive = order.caseSensitive === false;
|
113
|
-
const natural = Boolean(order.natural);
|
114
|
-
return {
|
115
|
-
isTargetArray,
|
116
|
-
ignore: () => false,
|
117
|
-
isValidOrder: buildValidatorFromType(type, insensitive, natural),
|
118
|
-
orderText(data) {
|
119
|
-
if (typeof data.value === "string") {
|
120
|
-
return `${natural ? "natural " : ""}${insensitive ? "insensitive " : ""}${type}ending`;
|
121
|
-
}
|
122
|
-
return `${type}ending`;
|
123
|
-
},
|
124
|
-
};
|
125
|
-
}
|
126
|
-
const parsedOrder = [];
|
127
|
-
for (const o of order) {
|
128
|
-
if (typeof o === "string") {
|
129
|
-
parsedOrder.push({
|
130
|
-
test: (v) => v.value === o,
|
131
|
-
isValidNestOrder: () => true,
|
132
|
-
});
|
133
|
-
}
|
134
|
-
else {
|
135
|
-
const valuePattern = o.valuePattern ? new RegExp(o.valuePattern) : null;
|
136
|
-
const nestOrder = (_c = o.order) !== null && _c !== void 0 ? _c : {};
|
137
|
-
const type = (_d = nestOrder.type) !== null && _d !== void 0 ? _d : "asc";
|
138
|
-
const insensitive = nestOrder.caseSensitive === false;
|
139
|
-
const natural = Boolean(nestOrder.natural);
|
140
|
-
parsedOrder.push({
|
141
|
-
test: (v) => valuePattern
|
142
|
-
? Boolean(getJSONPrimitiveType(v.value)) &&
|
143
|
-
valuePattern.test(String(v.value))
|
144
|
-
: true,
|
145
|
-
isValidNestOrder: buildValidatorFromType(type, insensitive, natural),
|
146
|
-
});
|
147
|
-
}
|
148
|
-
}
|
149
|
-
return {
|
150
|
-
isTargetArray,
|
151
|
-
ignore: (v) => parsedOrder.every((p) => !p.test(v)),
|
152
|
-
isValidOrder(a, b) {
|
153
|
-
for (const p of parsedOrder) {
|
154
|
-
const matchA = p.test(a);
|
155
|
-
const matchB = p.test(b);
|
156
|
-
if (!matchA || !matchB) {
|
157
|
-
if (matchA) {
|
158
|
-
return true;
|
159
|
-
}
|
160
|
-
if (matchB) {
|
161
|
-
return false;
|
162
|
-
}
|
163
|
-
continue;
|
164
|
-
}
|
165
|
-
return p.isValidNestOrder(a, b);
|
166
|
-
}
|
167
|
-
return false;
|
168
|
-
},
|
169
|
-
orderText: () => "specified",
|
170
|
-
};
|
171
|
-
function isTargetArray(data) {
|
172
|
-
if (data.node.elements.length < minValues) {
|
173
|
-
return false;
|
174
|
-
}
|
175
|
-
let path = "";
|
176
|
-
let curr = data.node;
|
177
|
-
let p = curr.parent;
|
178
|
-
while (p) {
|
179
|
-
if (p.type === "JSONProperty") {
|
180
|
-
const name = getPropertyName(p);
|
181
|
-
if (/^[$_a-z][\w$]*$/iu.test(name)) {
|
182
|
-
path = `.${name}${path}`;
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
path = `[${JSON.stringify(name)}]${path}`;
|
186
|
-
}
|
187
|
-
}
|
188
|
-
else if (p.type === "JSONArrayExpression") {
|
189
|
-
const index = p.elements.indexOf(curr);
|
190
|
-
path = `[${index}]${path}`;
|
191
|
-
}
|
192
|
-
curr = p;
|
193
|
-
p = curr.parent;
|
194
|
-
}
|
195
|
-
if (path.startsWith(".")) {
|
196
|
-
path = path.slice(1);
|
197
|
-
}
|
198
|
-
return pathPattern.test(path);
|
199
|
-
}
|
200
|
-
});
|
201
|
-
function getPropertyName(node) {
|
202
|
-
const prop = node.key;
|
203
|
-
if (prop.type === "JSONIdentifier") {
|
204
|
-
return prop.name;
|
205
|
-
}
|
206
|
-
return String((0, jsonc_eslint_parser_1.getStaticJSONValue)(prop));
|
207
|
-
}
|
208
|
-
}
|
209
|
-
function getJSONPrimitiveType(val) {
|
210
|
-
const t = typeof val;
|
211
|
-
if (t === "string" || t === "number" || t === "boolean" || t === "bigint") {
|
212
|
-
return t;
|
213
|
-
}
|
214
|
-
if (val === null) {
|
215
|
-
return "null";
|
216
|
-
}
|
217
|
-
if (val === undefined) {
|
218
|
-
return "undefined";
|
219
|
-
}
|
220
|
-
if (val instanceof RegExp) {
|
221
|
-
return "regexp";
|
222
|
-
}
|
223
|
-
return null;
|
224
|
-
}
|
225
|
-
const ALLOW_ORDER_TYPES = ["asc", "desc"];
|
226
|
-
const ORDER_OBJECT_SCHEMA = {
|
227
|
-
type: "object",
|
228
|
-
properties: {
|
229
|
-
type: {
|
230
|
-
enum: ALLOW_ORDER_TYPES,
|
231
|
-
},
|
232
|
-
caseSensitive: {
|
233
|
-
type: "boolean",
|
234
|
-
},
|
235
|
-
natural: {
|
236
|
-
type: "boolean",
|
237
|
-
},
|
238
|
-
},
|
239
|
-
additionalProperties: false,
|
240
|
-
};
|
241
|
-
exports.default = (0, utils_1.createRule)("sort-array-values", {
|
242
|
-
meta: {
|
243
|
-
docs: {
|
244
|
-
description: "require array values to be sorted",
|
245
|
-
recommended: null,
|
246
|
-
extensionRule: false,
|
247
|
-
layout: false,
|
248
|
-
},
|
249
|
-
fixable: "code",
|
250
|
-
schema: {
|
251
|
-
type: "array",
|
252
|
-
items: {
|
253
|
-
type: "object",
|
254
|
-
properties: {
|
255
|
-
pathPattern: { type: "string" },
|
256
|
-
order: {
|
257
|
-
oneOf: [
|
258
|
-
{
|
259
|
-
type: "array",
|
260
|
-
items: {
|
261
|
-
anyOf: [
|
262
|
-
{ type: "string" },
|
263
|
-
{
|
264
|
-
type: "object",
|
265
|
-
properties: {
|
266
|
-
valuePattern: {
|
267
|
-
type: "string",
|
268
|
-
},
|
269
|
-
order: ORDER_OBJECT_SCHEMA,
|
270
|
-
},
|
271
|
-
additionalProperties: false,
|
272
|
-
},
|
273
|
-
],
|
274
|
-
},
|
275
|
-
uniqueItems: true,
|
276
|
-
},
|
277
|
-
ORDER_OBJECT_SCHEMA,
|
278
|
-
],
|
279
|
-
},
|
280
|
-
minValues: {
|
281
|
-
type: "integer",
|
282
|
-
minimum: 2,
|
283
|
-
},
|
284
|
-
},
|
285
|
-
required: ["pathPattern", "order"],
|
286
|
-
additionalProperties: false,
|
287
|
-
},
|
288
|
-
minItems: 1,
|
289
|
-
},
|
290
|
-
messages: {
|
291
|
-
sortValues: "Expected array values to be in {{orderText}} order. '{{thisValue}}' should be before '{{prevValue}}'.",
|
292
|
-
},
|
293
|
-
type: "suggestion",
|
294
|
-
},
|
295
|
-
create(context) {
|
296
|
-
if (!context.parserServices.isJSON) {
|
297
|
-
return {};
|
298
|
-
}
|
299
|
-
const parsedOptions = parseOptions(context.options);
|
300
|
-
const sourceCode = context.getSourceCode();
|
301
|
-
function verifyArrayElement(data, option) {
|
302
|
-
if (option.ignore(data)) {
|
303
|
-
return;
|
304
|
-
}
|
305
|
-
const prevList = data.array.elements
|
306
|
-
.slice(0, data.index)
|
307
|
-
.reverse()
|
308
|
-
.filter((d) => !option.ignore(d));
|
309
|
-
if (prevList.length === 0) {
|
310
|
-
return;
|
311
|
-
}
|
312
|
-
const prev = prevList[0];
|
313
|
-
if (!option.isValidOrder(prev, data)) {
|
314
|
-
const reportLoc = data.reportLoc;
|
315
|
-
context.report({
|
316
|
-
loc: reportLoc,
|
317
|
-
messageId: "sortValues",
|
318
|
-
data: {
|
319
|
-
thisValue: toText(data),
|
320
|
-
prevValue: toText(prev),
|
321
|
-
orderText: option.orderText(data),
|
322
|
-
},
|
323
|
-
*fix(fixer) {
|
324
|
-
let moveTarget = prevList[0];
|
325
|
-
for (const prev of prevList) {
|
326
|
-
if (option.isValidOrder(prev, data)) {
|
327
|
-
break;
|
328
|
-
}
|
329
|
-
else {
|
330
|
-
moveTarget = prev;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
const beforeToken = data.aroundTokens.before;
|
334
|
-
const afterToken = data.aroundTokens.after;
|
335
|
-
const hasAfterComma = (0, eslint_utils_1.isCommaToken)(afterToken);
|
336
|
-
const codeStart = beforeToken.range[1];
|
337
|
-
const codeEnd = hasAfterComma
|
338
|
-
? afterToken.range[1]
|
339
|
-
: data.range[1];
|
340
|
-
const removeStart = hasAfterComma
|
341
|
-
? codeStart
|
342
|
-
: beforeToken.range[0];
|
343
|
-
const insertCode = sourceCode.text.slice(codeStart, codeEnd) +
|
344
|
-
(hasAfterComma ? "" : ",");
|
345
|
-
const insertTarget = moveTarget.aroundTokens.before;
|
346
|
-
yield fixer.insertTextAfterRange(insertTarget.range, insertCode);
|
347
|
-
yield fixer.removeRange([removeStart, codeEnd]);
|
348
|
-
},
|
349
|
-
});
|
350
|
-
}
|
351
|
-
}
|
352
|
-
function toText(data) {
|
353
|
-
if (getJSONPrimitiveType(data.value)) {
|
354
|
-
return String(data.value);
|
355
|
-
}
|
356
|
-
return sourceCode.getText(data.node);
|
357
|
-
}
|
358
|
-
return {
|
359
|
-
JSONArrayExpression(node) {
|
360
|
-
const data = new JSONArrayData(node, sourceCode);
|
361
|
-
const option = parsedOptions.find((o) => o.isTargetArray(data));
|
362
|
-
if (!option) {
|
363
|
-
return;
|
364
|
-
}
|
365
|
-
for (const element of data.elements) {
|
366
|
-
verifyArrayElement(element, option);
|
367
|
-
}
|
368
|
-
},
|
369
|
-
};
|
370
|
-
},
|
371
|
-
});
|