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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immosquare-cleaner/version.rb +1 -1
  3. data/lib/immosquare-cleaner.rb +3 -2
  4. data/linters/eslintrc.json +54 -27
  5. data/package.json +7 -8
  6. metadata +30 -69
  7. data/node_modules/eslint-plugin-jsonc/LICENSE +0 -21
  8. data/node_modules/eslint-plugin-jsonc/README.md +0 -279
  9. data/node_modules/eslint-plugin-jsonc/conf/eslint-all.js +0 -11
  10. data/node_modules/eslint-plugin-jsonc/conf/eslint-recommended.js +0 -13
  11. data/node_modules/eslint-plugin-jsonc/conf/rules.js +0 -10
  12. data/node_modules/eslint-plugin-jsonc/dist/configs/all.js +0 -18
  13. data/node_modules/eslint-plugin-jsonc/dist/configs/auto-config.js +0 -13
  14. data/node_modules/eslint-plugin-jsonc/dist/configs/base.js +0 -15
  15. data/node_modules/eslint-plugin-jsonc/dist/configs/prettier.js +0 -26
  16. data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-json.js +0 -41
  17. data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-json5.js +0 -30
  18. data/node_modules/eslint-plugin-jsonc/dist/configs/recommended-with-jsonc.js +0 -39
  19. data/node_modules/eslint-plugin-jsonc/dist/index.js +0 -68
  20. data/node_modules/eslint-plugin-jsonc/dist/meta.js +0 -5
  21. data/node_modules/eslint-plugin-jsonc/dist/rules/array-bracket-newline.js +0 -23
  22. data/node_modules/eslint-plugin-jsonc/dist/rules/array-bracket-spacing.js +0 -23
  23. data/node_modules/eslint-plugin-jsonc/dist/rules/array-element-newline.js +0 -23
  24. data/node_modules/eslint-plugin-jsonc/dist/rules/auto.js +0 -66
  25. data/node_modules/eslint-plugin-jsonc/dist/rules/comma-dangle.js +0 -27
  26. data/node_modules/eslint-plugin-jsonc/dist/rules/comma-style.js +0 -23
  27. data/node_modules/eslint-plugin-jsonc/dist/rules/indent.js +0 -23
  28. data/node_modules/eslint-plugin-jsonc/dist/rules/key-name-casing.js +0 -94
  29. data/node_modules/eslint-plugin-jsonc/dist/rules/key-spacing.js +0 -23
  30. data/node_modules/eslint-plugin-jsonc/dist/rules/no-bigint-literals.js +0 -33
  31. data/node_modules/eslint-plugin-jsonc/dist/rules/no-binary-expression.js +0 -38
  32. data/node_modules/eslint-plugin-jsonc/dist/rules/no-binary-numeric-literals.js +0 -39
  33. data/node_modules/eslint-plugin-jsonc/dist/rules/no-comments.js +0 -34
  34. data/node_modules/eslint-plugin-jsonc/dist/rules/no-dupe-keys.js +0 -23
  35. data/node_modules/eslint-plugin-jsonc/dist/rules/no-escape-sequence-in-identifier.js +0 -57
  36. data/node_modules/eslint-plugin-jsonc/dist/rules/no-floating-decimal.js +0 -23
  37. data/node_modules/eslint-plugin-jsonc/dist/rules/no-hexadecimal-numeric-literals.js +0 -39
  38. data/node_modules/eslint-plugin-jsonc/dist/rules/no-infinity.js +0 -37
  39. data/node_modules/eslint-plugin-jsonc/dist/rules/no-irregular-whitespace.js +0 -23
  40. data/node_modules/eslint-plugin-jsonc/dist/rules/no-multi-str.js +0 -23
  41. data/node_modules/eslint-plugin-jsonc/dist/rules/no-nan.js +0 -37
  42. data/node_modules/eslint-plugin-jsonc/dist/rules/no-number-props.js +0 -41
  43. data/node_modules/eslint-plugin-jsonc/dist/rules/no-numeric-separators.js +0 -42
  44. data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal-escape.js +0 -23
  45. data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal-numeric-literals.js +0 -39
  46. data/node_modules/eslint-plugin-jsonc/dist/rules/no-octal.js +0 -23
  47. data/node_modules/eslint-plugin-jsonc/dist/rules/no-parenthesized.js +0 -70
  48. data/node_modules/eslint-plugin-jsonc/dist/rules/no-plus-sign.js +0 -39
  49. data/node_modules/eslint-plugin-jsonc/dist/rules/no-regexp-literals.js +0 -33
  50. data/node_modules/eslint-plugin-jsonc/dist/rules/no-sparse-arrays.js +0 -23
  51. data/node_modules/eslint-plugin-jsonc/dist/rules/no-template-literals.js +0 -36
  52. data/node_modules/eslint-plugin-jsonc/dist/rules/no-undefined-value.js +0 -35
  53. data/node_modules/eslint-plugin-jsonc/dist/rules/no-unicode-codepoint-escapes.js +0 -73
  54. data/node_modules/eslint-plugin-jsonc/dist/rules/no-useless-escape.js +0 -23
  55. data/node_modules/eslint-plugin-jsonc/dist/rules/object-curly-newline.js +0 -23
  56. data/node_modules/eslint-plugin-jsonc/dist/rules/object-curly-spacing.js +0 -23
  57. data/node_modules/eslint-plugin-jsonc/dist/rules/object-property-newline.js +0 -23
  58. data/node_modules/eslint-plugin-jsonc/dist/rules/quote-props.js +0 -27
  59. data/node_modules/eslint-plugin-jsonc/dist/rules/quotes.js +0 -27
  60. data/node_modules/eslint-plugin-jsonc/dist/rules/sort-array-values.js +0 -371
  61. data/node_modules/eslint-plugin-jsonc/dist/rules/sort-keys.js +0 -413
  62. data/node_modules/eslint-plugin-jsonc/dist/rules/space-unary-ops.js +0 -23
  63. data/node_modules/eslint-plugin-jsonc/dist/rules/valid-json-number.js +0 -138
  64. data/node_modules/eslint-plugin-jsonc/dist/rules/vue-custom-block/no-parsing-error.js +0 -86
  65. data/node_modules/eslint-plugin-jsonc/dist/types.js +0 -2
  66. data/node_modules/eslint-plugin-jsonc/dist/utils/casing.js +0 -134
  67. data/node_modules/eslint-plugin-jsonc/dist/utils/get-auto-jsonc-rules-config.js +0 -97
  68. data/node_modules/eslint-plugin-jsonc/dist/utils/index.js +0 -121
  69. data/node_modules/eslint-plugin-jsonc/dist/utils/rules.js +0 -96
  70. data/node_modules/eslint-plugin-jsonc/index.d.ts +0 -364
  71. data/node_modules/eslint-plugin-jsonc/package.json +0 -123
@@ -1,413 +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
- function getPropertyName(node) {
11
- const prop = node.key;
12
- if (prop.type === "JSONIdentifier") {
13
- return prop.name;
14
- }
15
- return String((0, jsonc_eslint_parser_1.getStaticJSONValue)(prop));
16
- }
17
- class JSONPropertyData {
18
- get reportLoc() {
19
- return this.node.key.loc;
20
- }
21
- constructor(object, node, index) {
22
- this.cachedName = null;
23
- this.object = object;
24
- this.node = node;
25
- this.index = index;
26
- }
27
- get name() {
28
- var _a;
29
- return ((_a = this.cachedName) !== null && _a !== void 0 ? _a : (this.cachedName = getPropertyName(this.node)));
30
- }
31
- getPrev() {
32
- const prevIndex = this.index - 1;
33
- return prevIndex >= 0 ? this.object.properties[prevIndex] : null;
34
- }
35
- }
36
- class JSONObjectData {
37
- constructor(node) {
38
- this.cachedProperties = null;
39
- this.node = node;
40
- }
41
- get properties() {
42
- var _a;
43
- return ((_a = this.cachedProperties) !== null && _a !== void 0 ? _a : (this.cachedProperties = this.node.properties.map((e, index) => new JSONPropertyData(this, e, index))));
44
- }
45
- getPath() {
46
- let path = "";
47
- let curr = this.node;
48
- let p = curr.parent;
49
- while (p) {
50
- if (p.type === "JSONProperty") {
51
- const name = getPropertyName(p);
52
- if (/^[$_a-z][\w$]*$/iu.test(name)) {
53
- path = `.${name}${path}`;
54
- }
55
- else {
56
- path = `[${JSON.stringify(name)}]${path}`;
57
- }
58
- curr = p.parent;
59
- }
60
- else if (p.type === "JSONArrayExpression") {
61
- const index = p.elements.indexOf(curr);
62
- path = `[${index}]${path}`;
63
- curr = p;
64
- }
65
- else if (p.type === "JSONExpressionStatement") {
66
- break;
67
- }
68
- else {
69
- curr = p;
70
- }
71
- p = curr.parent;
72
- }
73
- if (path.startsWith(".")) {
74
- path = path.slice(1);
75
- }
76
- return path;
77
- }
78
- }
79
- function isCompatibleWithESLintOptions(options) {
80
- if (options.length === 0) {
81
- return true;
82
- }
83
- if (typeof options[0] === "string" || options[0] == null) {
84
- return true;
85
- }
86
- return false;
87
- }
88
- function buildValidatorFromType(order, insensitive, natural) {
89
- let compare = natural
90
- ? ([a, b]) => (0, natural_compare_1.default)(a, b) <= 0
91
- : ([a, b]) => a <= b;
92
- if (insensitive) {
93
- const baseCompare = compare;
94
- compare = ([a, b]) => baseCompare([a.toLowerCase(), b.toLowerCase()]);
95
- }
96
- if (order === "desc") {
97
- const baseCompare = compare;
98
- compare = (args) => baseCompare(args.reverse());
99
- }
100
- return (a, b) => compare([a.name, b.name]);
101
- }
102
- function parseOptions(options) {
103
- var _a, _b, _c;
104
- if (isCompatibleWithESLintOptions(options)) {
105
- const type = (_a = options[0]) !== null && _a !== void 0 ? _a : "asc";
106
- const obj = (_b = options[1]) !== null && _b !== void 0 ? _b : {};
107
- const insensitive = obj.caseSensitive === false;
108
- const natural = Boolean(obj.natural);
109
- const minKeys = (_c = obj.minKeys) !== null && _c !== void 0 ? _c : 2;
110
- const allowLineSeparatedGroups = obj.allowLineSeparatedGroups || false;
111
- return [
112
- {
113
- isTargetObject: (node) => node.properties.length >= minKeys,
114
- ignore: () => false,
115
- isValidOrder: buildValidatorFromType(type, insensitive, natural),
116
- orderText: `${natural ? "natural " : ""}${insensitive ? "insensitive " : ""}${type}ending`,
117
- allowLineSeparatedGroups,
118
- },
119
- ];
120
- }
121
- return options.map((opt) => {
122
- var _a, _b, _c, _d, _e;
123
- const order = opt.order;
124
- const pathPattern = new RegExp(opt.pathPattern);
125
- const hasProperties = (_a = opt.hasProperties) !== null && _a !== void 0 ? _a : [];
126
- const minKeys = (_b = opt.minKeys) !== null && _b !== void 0 ? _b : 2;
127
- const allowLineSeparatedGroups = opt.allowLineSeparatedGroups || false;
128
- if (!Array.isArray(order)) {
129
- const type = (_c = order.type) !== null && _c !== void 0 ? _c : "asc";
130
- const insensitive = order.caseSensitive === false;
131
- const natural = Boolean(order.natural);
132
- return {
133
- isTargetObject,
134
- ignore: () => false,
135
- isValidOrder: buildValidatorFromType(type, insensitive, natural),
136
- orderText: `${natural ? "natural " : ""}${insensitive ? "insensitive " : ""}${type}ending`,
137
- allowLineSeparatedGroups,
138
- };
139
- }
140
- const parsedOrder = [];
141
- for (const o of order) {
142
- if (typeof o === "string") {
143
- parsedOrder.push({
144
- test: (data) => data.name === o,
145
- isValidNestOrder: () => true,
146
- });
147
- }
148
- else {
149
- const keyPattern = o.keyPattern ? new RegExp(o.keyPattern) : null;
150
- const nestOrder = (_d = o.order) !== null && _d !== void 0 ? _d : {};
151
- const type = (_e = nestOrder.type) !== null && _e !== void 0 ? _e : "asc";
152
- const insensitive = nestOrder.caseSensitive === false;
153
- const natural = Boolean(nestOrder.natural);
154
- parsedOrder.push({
155
- test: (data) => (keyPattern ? keyPattern.test(data.name) : true),
156
- isValidNestOrder: buildValidatorFromType(type, insensitive, natural),
157
- });
158
- }
159
- }
160
- return {
161
- isTargetObject,
162
- ignore: (data) => parsedOrder.every((p) => !p.test(data)),
163
- isValidOrder(a, b) {
164
- for (const p of parsedOrder) {
165
- const matchA = p.test(a);
166
- const matchB = p.test(b);
167
- if (!matchA || !matchB) {
168
- if (matchA) {
169
- return true;
170
- }
171
- if (matchB) {
172
- return false;
173
- }
174
- continue;
175
- }
176
- return p.isValidNestOrder(a, b);
177
- }
178
- return false;
179
- },
180
- orderText: "specified",
181
- allowLineSeparatedGroups,
182
- };
183
- function isTargetObject(data) {
184
- if (data.node.properties.length < minKeys) {
185
- return false;
186
- }
187
- if (hasProperties.length > 0) {
188
- const names = new Set(data.properties.map((p) => p.name));
189
- if (!hasProperties.every((name) => names.has(name))) {
190
- return false;
191
- }
192
- }
193
- return pathPattern.test(data.getPath());
194
- }
195
- });
196
- }
197
- const ALLOW_ORDER_TYPES = ["asc", "desc"];
198
- const ORDER_OBJECT_SCHEMA = {
199
- type: "object",
200
- properties: {
201
- type: {
202
- enum: ALLOW_ORDER_TYPES,
203
- },
204
- caseSensitive: {
205
- type: "boolean",
206
- },
207
- natural: {
208
- type: "boolean",
209
- },
210
- },
211
- additionalProperties: false,
212
- };
213
- exports.default = (0, utils_1.createRule)("sort-keys", {
214
- meta: {
215
- docs: {
216
- description: "require object keys to be sorted",
217
- recommended: null,
218
- extensionRule: false,
219
- layout: false,
220
- },
221
- fixable: "code",
222
- schema: {
223
- oneOf: [
224
- {
225
- type: "array",
226
- items: {
227
- type: "object",
228
- properties: {
229
- pathPattern: { type: "string" },
230
- hasProperties: {
231
- type: "array",
232
- items: { type: "string" },
233
- },
234
- order: {
235
- oneOf: [
236
- {
237
- type: "array",
238
- items: {
239
- anyOf: [
240
- { type: "string" },
241
- {
242
- type: "object",
243
- properties: {
244
- keyPattern: {
245
- type: "string",
246
- },
247
- order: ORDER_OBJECT_SCHEMA,
248
- },
249
- additionalProperties: false,
250
- },
251
- ],
252
- },
253
- uniqueItems: true,
254
- },
255
- ORDER_OBJECT_SCHEMA,
256
- ],
257
- },
258
- minKeys: {
259
- type: "integer",
260
- minimum: 2,
261
- },
262
- allowLineSeparatedGroups: {
263
- type: "boolean",
264
- },
265
- },
266
- required: ["pathPattern", "order"],
267
- additionalProperties: false,
268
- },
269
- minItems: 1,
270
- },
271
- {
272
- type: "array",
273
- items: [
274
- {
275
- enum: ALLOW_ORDER_TYPES,
276
- },
277
- {
278
- type: "object",
279
- properties: {
280
- caseSensitive: {
281
- type: "boolean",
282
- },
283
- natural: {
284
- type: "boolean",
285
- },
286
- minKeys: {
287
- type: "integer",
288
- minimum: 2,
289
- },
290
- allowLineSeparatedGroups: {
291
- type: "boolean",
292
- },
293
- },
294
- additionalProperties: false,
295
- },
296
- ],
297
- additionalItems: false,
298
- },
299
- ],
300
- },
301
- messages: {
302
- sortKeys: "Expected object keys to be in {{orderText}} order. '{{thisName}}' should be before '{{prevName}}'.",
303
- },
304
- type: "suggestion",
305
- },
306
- create(context) {
307
- if (!context.parserServices.isJSON) {
308
- return {};
309
- }
310
- const parsedOptions = parseOptions(context.options);
311
- const sourceCode = context.getSourceCode();
312
- function verifyProperty(data, option) {
313
- if (option.ignore(data)) {
314
- return;
315
- }
316
- const prevList = [];
317
- let currTarget = data;
318
- let prevTarget;
319
- while ((prevTarget = currTarget.getPrev())) {
320
- if (option.allowLineSeparatedGroups) {
321
- if (hasBlankLine(prevTarget, currTarget)) {
322
- break;
323
- }
324
- }
325
- if (!option.ignore(prevTarget)) {
326
- prevList.push(prevTarget);
327
- }
328
- currTarget = prevTarget;
329
- }
330
- if (prevList.length === 0) {
331
- return;
332
- }
333
- const prev = prevList[0];
334
- if (!option.isValidOrder(prev, data)) {
335
- context.report({
336
- loc: data.reportLoc,
337
- messageId: "sortKeys",
338
- data: {
339
- thisName: data.name,
340
- prevName: prev.name,
341
- orderText: option.orderText,
342
- },
343
- *fix(fixer) {
344
- let moveTarget = prevList[0];
345
- for (const prev of prevList) {
346
- if (option.isValidOrder(prev, data)) {
347
- break;
348
- }
349
- else {
350
- moveTarget = prev;
351
- }
352
- }
353
- const beforeToken = sourceCode.getTokenBefore(data.node);
354
- const afterToken = sourceCode.getTokenAfter(data.node);
355
- const hasAfterComma = (0, eslint_utils_1.isCommaToken)(afterToken);
356
- const codeStart = beforeToken.range[1];
357
- const codeEnd = hasAfterComma
358
- ? afterToken.range[1]
359
- : data.node.range[1];
360
- const removeStart = hasAfterComma
361
- ? codeStart
362
- : beforeToken.range[0];
363
- const insertCode = sourceCode.text.slice(codeStart, codeEnd) +
364
- (hasAfterComma ? "" : ",");
365
- const insertTarget = sourceCode.getTokenBefore(moveTarget.node);
366
- let insertRange = insertTarget.range;
367
- const insertNext = sourceCode.getTokenAfter(insertTarget, {
368
- includeComments: true,
369
- });
370
- if (insertNext.loc.start.line - insertTarget.loc.end.line > 1) {
371
- const offset = sourceCode.getIndexFromLoc({
372
- line: insertNext.loc.start.line - 1,
373
- column: 0,
374
- });
375
- insertRange = [offset, offset];
376
- }
377
- yield fixer.insertTextAfterRange(insertRange, insertCode);
378
- yield fixer.removeRange([removeStart, codeEnd]);
379
- },
380
- });
381
- }
382
- }
383
- function hasBlankLine(prev, next) {
384
- const tokenOrNodes = [
385
- ...sourceCode.getTokensBetween(prev.node, next.node, {
386
- includeComments: true,
387
- }),
388
- next.node,
389
- ];
390
- let prevLoc = prev.node.loc;
391
- for (const t of tokenOrNodes) {
392
- const loc = t.loc;
393
- if (loc.start.line - prevLoc.end.line > 1) {
394
- return true;
395
- }
396
- prevLoc = loc;
397
- }
398
- return false;
399
- }
400
- return {
401
- JSONObjectExpression(node) {
402
- const data = new JSONObjectData(node);
403
- const option = parsedOptions.find((o) => o.isTargetObject(data));
404
- if (!option) {
405
- return;
406
- }
407
- for (const prop of data.properties) {
408
- verifyProperty(prop, option);
409
- }
410
- },
411
- };
412
- },
413
- });
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const utils_1 = require("../utils");
5
- const coreRule = (0, utils_1.getCoreRule)("space-unary-ops");
6
- exports.default = (0, utils_1.createRule)("space-unary-ops", {
7
- meta: {
8
- docs: {
9
- description: "disallow spaces after unary operators",
10
- recommended: ["json", "jsonc", "json5"],
11
- extensionRule: true,
12
- layout: true,
13
- },
14
- fixable: (_a = coreRule.meta) === null || _a === void 0 ? void 0 : _a.fixable,
15
- hasSuggestions: coreRule.meta.hasSuggestions,
16
- schema: coreRule.meta.schema,
17
- messages: coreRule.meta.messages,
18
- type: coreRule.meta.type,
19
- },
20
- create(context) {
21
- return (0, utils_1.defineWrapperListener)(coreRule, context, [{ nonwords: false }]);
22
- },
23
- });
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsonc_eslint_parser_1 = require("jsonc-eslint-parser");
4
- const utils_1 = require("../utils");
5
- const nonDecimalNumericLiteralPattern = /^0[\dBOXbox]/u;
6
- function isValidNumber(text) {
7
- try {
8
- JSON.parse(text);
9
- }
10
- catch (_a) {
11
- return false;
12
- }
13
- return true;
14
- }
15
- exports.default = (0, utils_1.createRule)("valid-json-number", {
16
- meta: {
17
- docs: {
18
- description: "disallow invalid number for JSON",
19
- recommended: ["json", "jsonc"],
20
- extensionRule: false,
21
- layout: false,
22
- },
23
- fixable: "code",
24
- schema: [],
25
- messages: {
26
- invalid: "Invalid number for JSON.",
27
- invalidSpace: "Spaces after minus sign are not allowed in JSON.",
28
- invalidPlus: "Plus signs are not allowed in JSON.",
29
- invalidIdentifier: "`{{name}}` are not allowed in JSON.",
30
- invalidLeadingDecimalPoint: "Leading decimal point is not allowed in JSON.",
31
- invalidTrailingDecimalPoint: "Trailing decimal point is not allowed in JSON.",
32
- invalidHex: "Hexadecimal literals are not allowed in JSON.",
33
- invalidOctal: "Octal literals are not allowed in JSON.",
34
- invalidBinary: "Binary literals are not allowed in JSON.",
35
- },
36
- type: "problem",
37
- },
38
- create(context) {
39
- if (!context.parserServices.isJSON) {
40
- return {};
41
- }
42
- const sourceCode = context.getSourceCode();
43
- return {
44
- JSONUnaryExpression(node) {
45
- if (node.argument.type === "JSONIdentifier") {
46
- return;
47
- }
48
- const operator = sourceCode.getFirstToken(node, (token) => token.type === "Punctuator" && token.value === node.operator);
49
- if (node.operator === "+") {
50
- context.report({
51
- loc: (operator === null || operator === void 0 ? void 0 : operator.loc) || node.loc,
52
- messageId: "invalidPlus",
53
- fix(fixer) {
54
- return operator ? fixer.removeRange(operator.range) : null;
55
- },
56
- });
57
- }
58
- else if (operator && operator.range[1] < node.argument.range[0]) {
59
- context.report({
60
- loc: {
61
- start: operator.loc.end,
62
- end: node.argument.loc.start,
63
- },
64
- messageId: "invalidSpace",
65
- fix(fixer) {
66
- return fixer.removeRange([
67
- operator.range[1],
68
- node.argument.range[0],
69
- ]);
70
- },
71
- });
72
- }
73
- },
74
- JSONLiteral(node) {
75
- if (typeof node.value !== "number") {
76
- return;
77
- }
78
- const text = sourceCode.text.slice(...node.range);
79
- if (text.startsWith(".")) {
80
- context.report({
81
- loc: node.loc,
82
- messageId: "invalidLeadingDecimalPoint",
83
- fix(fixer) {
84
- return fixer.insertTextBeforeRange(node.range, "0");
85
- },
86
- });
87
- return;
88
- }
89
- if (text.endsWith(".")) {
90
- context.report({
91
- loc: node.loc,
92
- messageId: "invalidTrailingDecimalPoint",
93
- fix(fixer) {
94
- return fixer.removeRange([node.range[1] - 1, node.range[1]]);
95
- },
96
- });
97
- return;
98
- }
99
- if (nonDecimalNumericLiteralPattern.test(text)) {
100
- context.report({
101
- loc: node.loc,
102
- messageId: text[1].toLowerCase() === "x"
103
- ? "invalidHex"
104
- : text[1].toLowerCase() === "b"
105
- ? "invalidBinary"
106
- : "invalidOctal",
107
- fix: buildFix(node),
108
- });
109
- return;
110
- }
111
- if (!isValidNumber(text)) {
112
- context.report({
113
- loc: node.loc,
114
- messageId: "invalid",
115
- fix: buildFix(node),
116
- });
117
- }
118
- },
119
- JSONIdentifier(node) {
120
- if (!(0, jsonc_eslint_parser_1.isNumberIdentifier)(node)) {
121
- return;
122
- }
123
- context.report({
124
- loc: node.loc,
125
- messageId: "invalidIdentifier",
126
- data: {
127
- name: node.name,
128
- },
129
- });
130
- },
131
- };
132
- function buildFix(node) {
133
- return (fixer) => {
134
- return fixer.replaceTextRange(node.range, `${node.value}`);
135
- };
136
- }
137
- },
138
- });
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const utils_1 = require("../../utils");
27
- const jsoncESLintParser = __importStar(require("jsonc-eslint-parser"));
28
- exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
29
- meta: {
30
- docs: {
31
- description: "disallow parsing errors in Vue custom blocks",
32
- recommended: ["json", "json5", "jsonc"],
33
- extensionRule: false,
34
- layout: false,
35
- },
36
- schema: [],
37
- messages: {},
38
- type: "problem",
39
- },
40
- create(context, { customBlock }) {
41
- if (!customBlock) {
42
- return {};
43
- }
44
- const parseError = context.parserServices.parseError;
45
- if (parseError) {
46
- return errorReportVisitor(context, parseError);
47
- }
48
- const parseCustomBlockElement = context.parserServices.parseCustomBlockElement;
49
- const customBlockElement = context.parserServices.customBlock;
50
- if (customBlockElement && parseCustomBlockElement) {
51
- let lang = getLang(customBlockElement);
52
- if (!lang) {
53
- lang = "json";
54
- }
55
- const { error } = parseCustomBlockElement(jsoncESLintParser, {
56
- jsonSyntax: lang,
57
- });
58
- if (error) {
59
- return errorReportVisitor(context, error);
60
- }
61
- }
62
- return {};
63
- },
64
- });
65
- function errorReportVisitor(context, error) {
66
- let loc = undefined;
67
- if ("column" in error && "lineNumber" in error) {
68
- loc = {
69
- line: error.lineNumber,
70
- column: error.column,
71
- };
72
- }
73
- return {
74
- Program(node) {
75
- context.report({
76
- node,
77
- loc,
78
- message: error.message,
79
- });
80
- },
81
- };
82
- }
83
- function getLang(customBlock) {
84
- var _a, _b;
85
- return (((_b = (_a = customBlock.startTag.attributes.find((attr) => !attr.directive && attr.key.name === "lang")) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value) || null);
86
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });