eslint-plugin-toml 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunk-CfYAbeIz.mjs +13 -0
- package/lib/index.d.mts +7 -13
- package/lib/index.mjs +149 -175
- package/package.json +8 -8
- package/lib/chunk-DQk6qfdC.mjs +0 -18
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
package/lib/index.d.mts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { AST, TOMLVersionOption } from "toml-eslint-parser";
|
|
2
2
|
import { IDirective, TextSourceCodeBase, TraversalStep } from "@eslint/plugin-kit";
|
|
3
3
|
import { CursorWithCountOptionsWithComment, CursorWithCountOptionsWithFilter, CursorWithCountOptionsWithoutFilter, CursorWithSkipOptionsWithComment, CursorWithSkipOptionsWithFilter, CursorWithSkipOptionsWithoutFilter } from "@ota-meshi/ast-token-store";
|
|
4
|
-
import * as _eslint_core0 from "@eslint/core";
|
|
5
|
-
import { File, FileProblem, Language, OkParseResult, RuleDefinition, RulesConfig } from "@eslint/core";
|
|
4
|
+
import * as _$_eslint_core0 from "@eslint/core";
|
|
5
|
+
import { File, FileProblem, Language, OkParseResult, ParseResult, RuleDefinition, RulesConfig } from "@eslint/core";
|
|
6
6
|
import { Linter, Scope } from "eslint";
|
|
7
7
|
|
|
8
8
|
//#region src/meta.d.ts
|
|
9
9
|
declare namespace meta_d_exports {
|
|
10
|
-
export { name, version };
|
|
10
|
+
export { name, namespace, version };
|
|
11
11
|
}
|
|
12
12
|
declare const name: string;
|
|
13
13
|
declare const version: string;
|
|
14
|
+
declare const namespace = "toml";
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/language/toml-source-code.d.ts
|
|
16
17
|
/**
|
|
@@ -283,13 +284,6 @@ declare class TOMLSourceCode extends TextSourceCodeBase<{
|
|
|
283
284
|
}
|
|
284
285
|
//#endregion
|
|
285
286
|
//#region src/language/toml-language.d.ts
|
|
286
|
-
/**
|
|
287
|
-
* Parse result
|
|
288
|
-
*/
|
|
289
|
-
interface TOMLParseResult {
|
|
290
|
-
ok: true;
|
|
291
|
-
ast: AST.TOMLProgram;
|
|
292
|
-
}
|
|
293
287
|
/**
|
|
294
288
|
* Language options for TOML
|
|
295
289
|
* Currently no options are defined.
|
|
@@ -334,11 +328,11 @@ declare class TOMLLanguage implements Language<{
|
|
|
334
328
|
*/
|
|
335
329
|
parse(file: File, context: {
|
|
336
330
|
languageOptions?: TOMLLanguageOptions;
|
|
337
|
-
}):
|
|
331
|
+
}): ParseResult<AST.TOMLProgram>;
|
|
338
332
|
/**
|
|
339
333
|
* Creates a new SourceCode object for the given file and parse result.
|
|
340
334
|
*/
|
|
341
|
-
createSourceCode(file: File, parseResult: OkParseResult<AST.TOMLProgram>
|
|
335
|
+
createSourceCode(file: File, parseResult: OkParseResult<AST.TOMLProgram>): TOMLSourceCode;
|
|
342
336
|
}
|
|
343
337
|
//#endregion
|
|
344
338
|
//#region src/index.d.ts
|
|
@@ -364,7 +358,7 @@ declare const _default: {
|
|
|
364
358
|
"flat/recommended": Linter.Config[];
|
|
365
359
|
"flat/standard": Linter.Config[];
|
|
366
360
|
};
|
|
367
|
-
rules: Record<string, RuleDefinition<_eslint_core0.RuleDefinitionTypeOptions>>;
|
|
361
|
+
rules: Record<string, RuleDefinition<_$_eslint_core0.RuleDefinitionTypeOptions>>;
|
|
368
362
|
languages: {
|
|
369
363
|
toml: TOMLLanguage;
|
|
370
364
|
};
|
package/lib/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-
|
|
1
|
+
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
2
|
import * as tomlESLintParser from "toml-eslint-parser";
|
|
3
3
|
import { VisitorKeys, getStaticTOMLValue, parseTOML, traverseNodes } from "toml-eslint-parser";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { CallMethodStep, ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep } from "@eslint/plugin-kit";
|
|
6
6
|
import { TokenStore } from "@ota-meshi/ast-token-store";
|
|
7
|
-
|
|
8
7
|
//#region src/utils/index.ts
|
|
9
8
|
/**
|
|
10
9
|
* Define the rule.
|
|
@@ -34,7 +33,6 @@ function createRule(ruleName, rule) {
|
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
37
|
//#region src/utils/ast-utils.ts
|
|
40
38
|
const LINEBREAK_MATCHER = /\r\n|[\n\r\u2028\u2029]/u;
|
|
@@ -105,7 +103,6 @@ function isTokenOnSameLine(left, right) {
|
|
|
105
103
|
function negate(f) {
|
|
106
104
|
return ((token) => !f(token));
|
|
107
105
|
}
|
|
108
|
-
|
|
109
106
|
//#endregion
|
|
110
107
|
//#region src/rules/array-bracket-newline.ts
|
|
111
108
|
var array_bracket_newline_default = createRule("array-bracket-newline", {
|
|
@@ -278,7 +275,6 @@ var array_bracket_newline_default = createRule("array-bracket-newline", {
|
|
|
278
275
|
return { TOMLArray: check };
|
|
279
276
|
}
|
|
280
277
|
});
|
|
281
|
-
|
|
282
278
|
//#endregion
|
|
283
279
|
//#region src/rules/array-bracket-spacing.ts
|
|
284
280
|
var array_bracket_spacing_default = createRule("array-bracket-spacing", {
|
|
@@ -451,7 +447,6 @@ var array_bracket_spacing_default = createRule("array-bracket-spacing", {
|
|
|
451
447
|
return { TOMLArray: validateArraySpacing };
|
|
452
448
|
}
|
|
453
449
|
});
|
|
454
|
-
|
|
455
450
|
//#endregion
|
|
456
451
|
//#region src/rules/array-element-newline.ts
|
|
457
452
|
var array_element_newline_default = createRule("array-element-newline", {
|
|
@@ -638,7 +633,6 @@ var array_element_newline_default = createRule("array-element-newline", {
|
|
|
638
633
|
return { TOMLArray: check };
|
|
639
634
|
}
|
|
640
635
|
});
|
|
641
|
-
|
|
642
636
|
//#endregion
|
|
643
637
|
//#region src/rules/comma-style.ts
|
|
644
638
|
var comma_style_default = createRule("comma-style", {
|
|
@@ -798,7 +792,6 @@ var comma_style_default = createRule("comma-style", {
|
|
|
798
792
|
return nodes;
|
|
799
793
|
}
|
|
800
794
|
});
|
|
801
|
-
|
|
802
795
|
//#endregion
|
|
803
796
|
//#region src/rules/indent.ts
|
|
804
797
|
const ITERATION_OPTS = Object.freeze({ includeComments: true });
|
|
@@ -1172,7 +1165,6 @@ var indent_default = createRule("indent", {
|
|
|
1172
1165
|
}
|
|
1173
1166
|
}
|
|
1174
1167
|
});
|
|
1175
|
-
|
|
1176
1168
|
//#endregion
|
|
1177
1169
|
//#region src/rules/inline-table-curly-newline.ts
|
|
1178
1170
|
var inline_table_curly_newline_default = createRule("inline-table-curly-newline", {
|
|
@@ -1319,7 +1311,6 @@ var inline_table_curly_newline_default = createRule("inline-table-curly-newline"
|
|
|
1319
1311
|
return { TOMLInlineTable: check };
|
|
1320
1312
|
}
|
|
1321
1313
|
});
|
|
1322
|
-
|
|
1323
1314
|
//#endregion
|
|
1324
1315
|
//#region src/rules/inline-table-curly-spacing.ts
|
|
1325
1316
|
/**
|
|
@@ -1588,7 +1579,6 @@ var inline_table_curly_spacing_default = createRule("inline-table-curly-spacing"
|
|
|
1588
1579
|
return { TOMLInlineTable: checkForObject };
|
|
1589
1580
|
}
|
|
1590
1581
|
});
|
|
1591
|
-
|
|
1592
1582
|
//#endregion
|
|
1593
1583
|
//#region src/rules/inline-table-key-value-newline.ts
|
|
1594
1584
|
/**
|
|
@@ -1660,7 +1650,6 @@ var inline_table_key_value_newline_default = createRule("inline-table-key-value-
|
|
|
1660
1650
|
} };
|
|
1661
1651
|
}
|
|
1662
1652
|
});
|
|
1663
|
-
|
|
1664
1653
|
//#endregion
|
|
1665
1654
|
//#region src/rules/key-spacing.ts
|
|
1666
1655
|
/**
|
|
@@ -2069,7 +2058,6 @@ function create(context) {
|
|
|
2069
2058
|
} };
|
|
2070
2059
|
}
|
|
2071
2060
|
}
|
|
2072
|
-
|
|
2073
2061
|
//#endregion
|
|
2074
2062
|
//#region src/rules/keys-order.ts
|
|
2075
2063
|
var keys_order_default = createRule("keys-order", {
|
|
@@ -2143,7 +2131,6 @@ var keys_order_default = createRule("keys-order", {
|
|
|
2143
2131
|
};
|
|
2144
2132
|
}
|
|
2145
2133
|
});
|
|
2146
|
-
|
|
2147
2134
|
//#endregion
|
|
2148
2135
|
//#region src/rules/no-mixed-type-in-array.ts
|
|
2149
2136
|
var no_mixed_type_in_array_default = createRule("no-mixed-type-in-array", {
|
|
@@ -2220,7 +2207,6 @@ var no_mixed_type_in_array_default = createRule("no-mixed-type-in-array", {
|
|
|
2220
2207
|
} };
|
|
2221
2208
|
}
|
|
2222
2209
|
});
|
|
2223
|
-
|
|
2224
2210
|
//#endregion
|
|
2225
2211
|
//#region src/rules/no-non-decimal-integer.ts
|
|
2226
2212
|
/**
|
|
@@ -2311,7 +2297,6 @@ var no_non_decimal_integer_default = createRule("no-non-decimal-integer", {
|
|
|
2311
2297
|
} };
|
|
2312
2298
|
}
|
|
2313
2299
|
});
|
|
2314
|
-
|
|
2315
2300
|
//#endregion
|
|
2316
2301
|
//#region src/rules/no-space-dots.ts
|
|
2317
2302
|
var no_space_dots_default = createRule("no-space-dots", {
|
|
@@ -2361,7 +2346,6 @@ var no_space_dots_default = createRule("no-space-dots", {
|
|
|
2361
2346
|
} };
|
|
2362
2347
|
}
|
|
2363
2348
|
});
|
|
2364
|
-
|
|
2365
2349
|
//#endregion
|
|
2366
2350
|
//#region src/rules/no-unreadable-number-separator.ts
|
|
2367
2351
|
var no_unreadable_number_separator_default = createRule("no-unreadable-number-separator", {
|
|
@@ -2475,7 +2459,6 @@ var no_unreadable_number_separator_default = createRule("no-unreadable-number-se
|
|
|
2475
2459
|
} };
|
|
2476
2460
|
}
|
|
2477
2461
|
});
|
|
2478
|
-
|
|
2479
2462
|
//#endregion
|
|
2480
2463
|
//#region src/rules/padding-line-between-pairs.ts
|
|
2481
2464
|
var padding_line_between_pairs_default = createRule("padding-line-between-pairs", {
|
|
@@ -2548,7 +2531,6 @@ var padding_line_between_pairs_default = createRule("padding-line-between-pairs"
|
|
|
2548
2531
|
};
|
|
2549
2532
|
}
|
|
2550
2533
|
});
|
|
2551
|
-
|
|
2552
2534
|
//#endregion
|
|
2553
2535
|
//#region src/rules/padding-line-between-tables.ts
|
|
2554
2536
|
var padding_line_between_tables_default = createRule("padding-line-between-tables", {
|
|
@@ -2600,7 +2582,6 @@ var padding_line_between_tables_default = createRule("padding-line-between-table
|
|
|
2600
2582
|
return { TOMLTopLevelTable: verify };
|
|
2601
2583
|
}
|
|
2602
2584
|
});
|
|
2603
|
-
|
|
2604
2585
|
//#endregion
|
|
2605
2586
|
//#region src/rules/precision-of-fractional-seconds.ts
|
|
2606
2587
|
var precision_of_fractional_seconds_default = createRule("precision-of-fractional-seconds", {
|
|
@@ -2642,7 +2623,6 @@ var precision_of_fractional_seconds_default = createRule("precision-of-fractiona
|
|
|
2642
2623
|
} };
|
|
2643
2624
|
}
|
|
2644
2625
|
});
|
|
2645
|
-
|
|
2646
2626
|
//#endregion
|
|
2647
2627
|
//#region src/utils/bit.ts
|
|
2648
2628
|
/**
|
|
@@ -2685,7 +2665,6 @@ function maxBitToMaxValues(maxBit) {
|
|
|
2685
2665
|
}
|
|
2686
2666
|
}
|
|
2687
2667
|
}
|
|
2688
|
-
|
|
2689
2668
|
//#endregion
|
|
2690
2669
|
//#region src/rules/precision-of-integer.ts
|
|
2691
2670
|
const cacheMaxValues = {};
|
|
@@ -2762,7 +2741,6 @@ var precision_of_integer_default = createRule("precision-of-integer", {
|
|
|
2762
2741
|
} };
|
|
2763
2742
|
}
|
|
2764
2743
|
});
|
|
2765
|
-
|
|
2766
2744
|
//#endregion
|
|
2767
2745
|
//#region src/rules/quoted-keys.ts
|
|
2768
2746
|
var quoted_keys_default = createRule("quoted-keys", {
|
|
@@ -2831,7 +2809,6 @@ var quoted_keys_default = createRule("quoted-keys", {
|
|
|
2831
2809
|
};
|
|
2832
2810
|
}
|
|
2833
2811
|
});
|
|
2834
|
-
|
|
2835
2812
|
//#endregion
|
|
2836
2813
|
//#region src/rules/space-eq-sign.ts
|
|
2837
2814
|
var space_eq_sign_default = createRule("space-eq-sign", {
|
|
@@ -2872,7 +2849,6 @@ var space_eq_sign_default = createRule("space-eq-sign", {
|
|
|
2872
2849
|
} };
|
|
2873
2850
|
}
|
|
2874
2851
|
});
|
|
2875
|
-
|
|
2876
2852
|
//#endregion
|
|
2877
2853
|
//#region src/rules/spaced-comment.ts
|
|
2878
2854
|
/**
|
|
@@ -3041,7 +3017,6 @@ var spaced_comment_default = createRule("spaced-comment", {
|
|
|
3041
3017
|
} };
|
|
3042
3018
|
}
|
|
3043
3019
|
});
|
|
3044
|
-
|
|
3045
3020
|
//#endregion
|
|
3046
3021
|
//#region src/rules/table-bracket-spacing.ts
|
|
3047
3022
|
var table_bracket_spacing_default = createRule("table-bracket-spacing", {
|
|
@@ -3158,7 +3133,6 @@ var table_bracket_spacing_default = createRule("table-bracket-spacing", {
|
|
|
3158
3133
|
return { TOMLTable: validateArraySpacing };
|
|
3159
3134
|
}
|
|
3160
3135
|
});
|
|
3161
|
-
|
|
3162
3136
|
//#endregion
|
|
3163
3137
|
//#region src/rules/tables-order.ts
|
|
3164
3138
|
/**
|
|
@@ -3177,134 +3151,6 @@ function getLast(keys) {
|
|
|
3177
3151
|
if (last) return getLast(last.keys) || last.node;
|
|
3178
3152
|
return null;
|
|
3179
3153
|
}
|
|
3180
|
-
var tables_order_default = createRule("tables-order", {
|
|
3181
|
-
meta: {
|
|
3182
|
-
docs: {
|
|
3183
|
-
description: "disallow defining tables out-of-order",
|
|
3184
|
-
categories: ["standard"],
|
|
3185
|
-
extensionRule: false
|
|
3186
|
-
},
|
|
3187
|
-
fixable: "code",
|
|
3188
|
-
schema: [],
|
|
3189
|
-
messages: {
|
|
3190
|
-
outOfOrder: "'{{target}}' must be next to '{{before}}'.",
|
|
3191
|
-
outOfOrderToBefore: "'{{target}}' must be previous to '{{after}}'."
|
|
3192
|
-
},
|
|
3193
|
-
type: "suggestion"
|
|
3194
|
-
},
|
|
3195
|
-
create(context) {
|
|
3196
|
-
const sourceCode = context.sourceCode;
|
|
3197
|
-
if (!sourceCode.parserServices?.isTOML) return {};
|
|
3198
|
-
/**
|
|
3199
|
-
* Apply new key
|
|
3200
|
-
*/
|
|
3201
|
-
function applyKey(rootKeys, node) {
|
|
3202
|
-
const keyNames = [...node.resolvedKey];
|
|
3203
|
-
let before = null;
|
|
3204
|
-
let keys = rootKeys;
|
|
3205
|
-
while (keyNames.length) {
|
|
3206
|
-
const key = keyNames.shift();
|
|
3207
|
-
const isLast = !keyNames.length;
|
|
3208
|
-
let next = keys.find((e) => e.key === key);
|
|
3209
|
-
if (!next) {
|
|
3210
|
-
next = {
|
|
3211
|
-
key,
|
|
3212
|
-
node,
|
|
3213
|
-
keys: []
|
|
3214
|
-
};
|
|
3215
|
-
if (isLast) before = getLast(keys);
|
|
3216
|
-
keys.push(next);
|
|
3217
|
-
} else if (isLast) {
|
|
3218
|
-
if (next.keys.length > 0) return {
|
|
3219
|
-
before: null,
|
|
3220
|
-
after: getFirst(next.keys)
|
|
3221
|
-
};
|
|
3222
|
-
/* istanbul ignore next */
|
|
3223
|
-
before = getLast(keys);
|
|
3224
|
-
}
|
|
3225
|
-
keys = next.keys;
|
|
3226
|
-
}
|
|
3227
|
-
return {
|
|
3228
|
-
before,
|
|
3229
|
-
after: null
|
|
3230
|
-
};
|
|
3231
|
-
}
|
|
3232
|
-
/**
|
|
3233
|
-
* Verify tables
|
|
3234
|
-
*/
|
|
3235
|
-
function verify(node) {
|
|
3236
|
-
const keys = [];
|
|
3237
|
-
let prev = null;
|
|
3238
|
-
for (const body of node.body) {
|
|
3239
|
-
if (body.type !== "TOMLTable") continue;
|
|
3240
|
-
const { before, after } = applyKey(keys, body);
|
|
3241
|
-
if (after) context.report({
|
|
3242
|
-
node: body.key,
|
|
3243
|
-
messageId: "outOfOrderToBefore",
|
|
3244
|
-
data: {
|
|
3245
|
-
target: getStaticTOMLValue(body.key).join("."),
|
|
3246
|
-
after: getStaticTOMLValue(after.key).join(".")
|
|
3247
|
-
},
|
|
3248
|
-
fix(fixer) {
|
|
3249
|
-
const startToken = sourceCode.getTokenBefore(body);
|
|
3250
|
-
const code = sourceCode.text.slice(startToken.range[1], body.range[1]);
|
|
3251
|
-
return [fixer.insertTextBefore(after, `${code.trim()}\n`), fixer.removeRange([startToken.range[1], body.range[1]])];
|
|
3252
|
-
}
|
|
3253
|
-
});
|
|
3254
|
-
else if (before && before !== prev) context.report({
|
|
3255
|
-
node: body.key,
|
|
3256
|
-
messageId: "outOfOrder",
|
|
3257
|
-
data: {
|
|
3258
|
-
target: getStaticTOMLValue(body.key).join("."),
|
|
3259
|
-
before: getStaticTOMLValue(before.key).join(".")
|
|
3260
|
-
},
|
|
3261
|
-
fix(fixer) {
|
|
3262
|
-
const startToken = sourceCode.getTokenBefore(body);
|
|
3263
|
-
const code = sourceCode.text.slice(startToken.range[1], body.range[1]);
|
|
3264
|
-
return [fixer.insertTextAfter(before, `\n${code.trim()}`), fixer.removeRange([startToken.range[1], body.range[1]])];
|
|
3265
|
-
}
|
|
3266
|
-
});
|
|
3267
|
-
prev = body;
|
|
3268
|
-
}
|
|
3269
|
-
}
|
|
3270
|
-
return { TOMLTopLevelTable: verify };
|
|
3271
|
-
}
|
|
3272
|
-
});
|
|
3273
|
-
|
|
3274
|
-
//#endregion
|
|
3275
|
-
//#region src/rules/vue-custom-block/no-parsing-error.ts
|
|
3276
|
-
var no_parsing_error_default = createRule("vue-custom-block/no-parsing-error", {
|
|
3277
|
-
meta: {
|
|
3278
|
-
docs: {
|
|
3279
|
-
description: "disallow parsing errors in Vue custom blocks",
|
|
3280
|
-
categories: ["recommended", "standard"],
|
|
3281
|
-
extensionRule: false
|
|
3282
|
-
},
|
|
3283
|
-
schema: [],
|
|
3284
|
-
messages: {},
|
|
3285
|
-
type: "problem"
|
|
3286
|
-
},
|
|
3287
|
-
create(context, { customBlock }) {
|
|
3288
|
-
if (!customBlock) return {};
|
|
3289
|
-
const parseError = context.sourceCode.parserServices?.parseError;
|
|
3290
|
-
if (parseError && typeof parseError === "object") {
|
|
3291
|
-
let loc = void 0;
|
|
3292
|
-
if ("column" in parseError && "lineNumber" in parseError) loc = {
|
|
3293
|
-
line: parseError.lineNumber,
|
|
3294
|
-
column: parseError.column
|
|
3295
|
-
};
|
|
3296
|
-
return { Program(node) {
|
|
3297
|
-
context.report({
|
|
3298
|
-
node,
|
|
3299
|
-
loc,
|
|
3300
|
-
message: parseError.message
|
|
3301
|
-
});
|
|
3302
|
-
} };
|
|
3303
|
-
}
|
|
3304
|
-
return {};
|
|
3305
|
-
}
|
|
3306
|
-
});
|
|
3307
|
-
|
|
3308
3154
|
//#endregion
|
|
3309
3155
|
//#region src/utils/rules.ts
|
|
3310
3156
|
const rules$1 = [
|
|
@@ -3330,10 +3176,131 @@ const rules$1 = [
|
|
|
3330
3176
|
space_eq_sign_default,
|
|
3331
3177
|
spaced_comment_default,
|
|
3332
3178
|
table_bracket_spacing_default,
|
|
3333
|
-
|
|
3334
|
-
|
|
3179
|
+
createRule("tables-order", {
|
|
3180
|
+
meta: {
|
|
3181
|
+
docs: {
|
|
3182
|
+
description: "disallow defining tables out-of-order",
|
|
3183
|
+
categories: ["standard"],
|
|
3184
|
+
extensionRule: false
|
|
3185
|
+
},
|
|
3186
|
+
fixable: "code",
|
|
3187
|
+
schema: [],
|
|
3188
|
+
messages: {
|
|
3189
|
+
outOfOrder: "'{{target}}' must be next to '{{before}}'.",
|
|
3190
|
+
outOfOrderToBefore: "'{{target}}' must be previous to '{{after}}'."
|
|
3191
|
+
},
|
|
3192
|
+
type: "suggestion"
|
|
3193
|
+
},
|
|
3194
|
+
create(context) {
|
|
3195
|
+
const sourceCode = context.sourceCode;
|
|
3196
|
+
if (!sourceCode.parserServices?.isTOML) return {};
|
|
3197
|
+
/**
|
|
3198
|
+
* Apply new key
|
|
3199
|
+
*/
|
|
3200
|
+
function applyKey(rootKeys, node) {
|
|
3201
|
+
const keyNames = [...node.resolvedKey];
|
|
3202
|
+
let before = null;
|
|
3203
|
+
let keys = rootKeys;
|
|
3204
|
+
while (keyNames.length) {
|
|
3205
|
+
const key = keyNames.shift();
|
|
3206
|
+
const isLast = !keyNames.length;
|
|
3207
|
+
let next = keys.find((e) => e.key === key);
|
|
3208
|
+
if (!next) {
|
|
3209
|
+
next = {
|
|
3210
|
+
key,
|
|
3211
|
+
node,
|
|
3212
|
+
keys: []
|
|
3213
|
+
};
|
|
3214
|
+
if (isLast) before = getLast(keys);
|
|
3215
|
+
keys.push(next);
|
|
3216
|
+
} else if (isLast) {
|
|
3217
|
+
if (next.keys.length > 0) return {
|
|
3218
|
+
before: null,
|
|
3219
|
+
after: getFirst(next.keys)
|
|
3220
|
+
};
|
|
3221
|
+
/* istanbul ignore next */
|
|
3222
|
+
before = getLast(keys);
|
|
3223
|
+
}
|
|
3224
|
+
keys = next.keys;
|
|
3225
|
+
}
|
|
3226
|
+
return {
|
|
3227
|
+
before,
|
|
3228
|
+
after: null
|
|
3229
|
+
};
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Verify tables
|
|
3233
|
+
*/
|
|
3234
|
+
function verify(node) {
|
|
3235
|
+
const keys = [];
|
|
3236
|
+
let prev = null;
|
|
3237
|
+
for (const body of node.body) {
|
|
3238
|
+
if (body.type !== "TOMLTable") continue;
|
|
3239
|
+
const { before, after } = applyKey(keys, body);
|
|
3240
|
+
if (after) context.report({
|
|
3241
|
+
node: body.key,
|
|
3242
|
+
messageId: "outOfOrderToBefore",
|
|
3243
|
+
data: {
|
|
3244
|
+
target: getStaticTOMLValue(body.key).join("."),
|
|
3245
|
+
after: getStaticTOMLValue(after.key).join(".")
|
|
3246
|
+
},
|
|
3247
|
+
fix(fixer) {
|
|
3248
|
+
const startToken = sourceCode.getTokenBefore(body);
|
|
3249
|
+
const code = sourceCode.text.slice(startToken.range[1], body.range[1]);
|
|
3250
|
+
return [fixer.insertTextBefore(after, `${code.trim()}\n`), fixer.removeRange([startToken.range[1], body.range[1]])];
|
|
3251
|
+
}
|
|
3252
|
+
});
|
|
3253
|
+
else if (before && before !== prev) context.report({
|
|
3254
|
+
node: body.key,
|
|
3255
|
+
messageId: "outOfOrder",
|
|
3256
|
+
data: {
|
|
3257
|
+
target: getStaticTOMLValue(body.key).join("."),
|
|
3258
|
+
before: getStaticTOMLValue(before.key).join(".")
|
|
3259
|
+
},
|
|
3260
|
+
fix(fixer) {
|
|
3261
|
+
const startToken = sourceCode.getTokenBefore(body);
|
|
3262
|
+
const code = sourceCode.text.slice(startToken.range[1], body.range[1]);
|
|
3263
|
+
return [fixer.insertTextAfter(before, `\n${code.trim()}`), fixer.removeRange([startToken.range[1], body.range[1]])];
|
|
3264
|
+
}
|
|
3265
|
+
});
|
|
3266
|
+
prev = body;
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
return { TOMLTopLevelTable: verify };
|
|
3270
|
+
}
|
|
3271
|
+
}),
|
|
3272
|
+
createRule("vue-custom-block/no-parsing-error", {
|
|
3273
|
+
meta: {
|
|
3274
|
+
docs: {
|
|
3275
|
+
description: "disallow parsing errors in Vue custom blocks",
|
|
3276
|
+
categories: ["recommended", "standard"],
|
|
3277
|
+
extensionRule: false
|
|
3278
|
+
},
|
|
3279
|
+
schema: [],
|
|
3280
|
+
messages: {},
|
|
3281
|
+
type: "problem"
|
|
3282
|
+
},
|
|
3283
|
+
create(context, { customBlock }) {
|
|
3284
|
+
if (!customBlock) return {};
|
|
3285
|
+
const parseError = context.sourceCode.parserServices?.parseError;
|
|
3286
|
+
if (parseError && typeof parseError === "object") {
|
|
3287
|
+
let loc = void 0;
|
|
3288
|
+
if ("column" in parseError && "lineNumber" in parseError) loc = {
|
|
3289
|
+
line: parseError.lineNumber,
|
|
3290
|
+
column: parseError.column
|
|
3291
|
+
};
|
|
3292
|
+
return { Program(node) {
|
|
3293
|
+
context.report({
|
|
3294
|
+
node,
|
|
3295
|
+
loc,
|
|
3296
|
+
message: parseError.message
|
|
3297
|
+
});
|
|
3298
|
+
} };
|
|
3299
|
+
}
|
|
3300
|
+
return {};
|
|
3301
|
+
}
|
|
3302
|
+
})
|
|
3335
3303
|
];
|
|
3336
|
-
|
|
3337
3304
|
//#endregion
|
|
3338
3305
|
//#region src/configs/flat/base.ts
|
|
3339
3306
|
var base_default = [{ plugins: { get toml() {
|
|
@@ -3346,7 +3313,6 @@ var base_default = [{ plugins: { get toml() {
|
|
|
3346
3313
|
"spaced-comment": "off"
|
|
3347
3314
|
}
|
|
3348
3315
|
}];
|
|
3349
|
-
|
|
3350
3316
|
//#endregion
|
|
3351
3317
|
//#region src/configs/flat/recommended.ts
|
|
3352
3318
|
var recommended_default = [...base_default, { rules: {
|
|
@@ -3355,7 +3321,6 @@ var recommended_default = [...base_default, { rules: {
|
|
|
3355
3321
|
"toml/precision-of-integer": "error",
|
|
3356
3322
|
"toml/vue-custom-block/no-parsing-error": "error"
|
|
3357
3323
|
} }];
|
|
3358
|
-
|
|
3359
3324
|
//#endregion
|
|
3360
3325
|
//#region src/configs/flat/standard.ts
|
|
3361
3326
|
var standard_default = [...base_default, { rules: {
|
|
@@ -3381,21 +3346,20 @@ var standard_default = [...base_default, { rules: {
|
|
|
3381
3346
|
"toml/tables-order": "error",
|
|
3382
3347
|
"toml/vue-custom-block/no-parsing-error": "error"
|
|
3383
3348
|
} }];
|
|
3384
|
-
|
|
3385
3349
|
//#endregion
|
|
3386
3350
|
//#region package.json
|
|
3387
3351
|
var name$1 = "eslint-plugin-toml";
|
|
3388
|
-
var version$1 = "1.
|
|
3389
|
-
|
|
3352
|
+
var version$1 = "1.4.0";
|
|
3390
3353
|
//#endregion
|
|
3391
3354
|
//#region src/meta.ts
|
|
3392
3355
|
var meta_exports = /* @__PURE__ */ __exportAll({
|
|
3393
3356
|
name: () => name,
|
|
3357
|
+
namespace: () => namespace,
|
|
3394
3358
|
version: () => version
|
|
3395
3359
|
});
|
|
3396
3360
|
const name = name$1;
|
|
3397
3361
|
const version = version$1;
|
|
3398
|
-
|
|
3362
|
+
const namespace = "toml";
|
|
3399
3363
|
//#endregion
|
|
3400
3364
|
//#region src/language/toml-source-code.ts
|
|
3401
3365
|
/**
|
|
@@ -3700,7 +3664,6 @@ function createFakeGlobalScope(node) {
|
|
|
3700
3664
|
fakeGlobalScope.variableScope = fakeGlobalScope;
|
|
3701
3665
|
return fakeGlobalScope;
|
|
3702
3666
|
}
|
|
3703
|
-
|
|
3704
3667
|
//#endregion
|
|
3705
3668
|
//#region src/language/toml-language.ts
|
|
3706
3669
|
/**
|
|
@@ -3729,13 +3692,26 @@ var TOMLLanguage = class {
|
|
|
3729
3692
|
*/
|
|
3730
3693
|
parse(file, context) {
|
|
3731
3694
|
const text = file.body;
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3695
|
+
try {
|
|
3696
|
+
return {
|
|
3697
|
+
ok: true,
|
|
3698
|
+
ast: parseTOML(text, {
|
|
3699
|
+
filePath: file.path,
|
|
3700
|
+
tomlVersion: context.languageOptions?.parserOptions?.tomlVersion
|
|
3701
|
+
})
|
|
3702
|
+
};
|
|
3703
|
+
} catch (error) {
|
|
3704
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3705
|
+
const parseError = error;
|
|
3706
|
+
return {
|
|
3707
|
+
ok: false,
|
|
3708
|
+
errors: [{
|
|
3709
|
+
message,
|
|
3710
|
+
line: parseError.lineNumber ?? 1,
|
|
3711
|
+
column: parseError.column ?? 1
|
|
3712
|
+
}]
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3739
3715
|
}
|
|
3740
3716
|
/**
|
|
3741
3717
|
* Creates a new SourceCode object for the given file and parse result.
|
|
@@ -3750,7 +3726,6 @@ var TOMLLanguage = class {
|
|
|
3750
3726
|
});
|
|
3751
3727
|
}
|
|
3752
3728
|
};
|
|
3753
|
-
|
|
3754
3729
|
//#endregion
|
|
3755
3730
|
//#region src/index.ts
|
|
3756
3731
|
const configs = {
|
|
@@ -3772,6 +3747,5 @@ var src_default = {
|
|
|
3772
3747
|
rules,
|
|
3773
3748
|
languages
|
|
3774
3749
|
};
|
|
3775
|
-
|
|
3776
3750
|
//#endregion
|
|
3777
|
-
export { configs, src_default as default, languages, meta_exports as meta, rules };
|
|
3751
|
+
export { configs, src_default as default, languages, meta_exports as meta, rules };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-toml",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for TOML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@eslint/core": "^1.0.1",
|
|
68
|
-
"@eslint/plugin-kit": "^0.
|
|
68
|
+
"@eslint/plugin-kit": "^0.7.0",
|
|
69
69
|
"@ota-meshi/ast-token-store": "^0.3.0",
|
|
70
70
|
"debug": "^4.1.1",
|
|
71
71
|
"toml-eslint-parser": "^1.0.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@changesets/changelog-github": "^0.
|
|
74
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
75
75
|
"@changesets/cli": "^2.27.5",
|
|
76
76
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
77
77
|
"@eslint/json": "^1.0.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@typescript-eslint/parser": "^8.16.0",
|
|
87
87
|
"cross-env": "^10.0.0",
|
|
88
88
|
"env-cmd": "^11.0.0",
|
|
89
|
-
"esbuild": "^0.
|
|
89
|
+
"esbuild": "^0.28.0",
|
|
90
90
|
"eslint": "^10.0.0",
|
|
91
91
|
"eslint-config-prettier": "^10.0.0",
|
|
92
92
|
"eslint-plugin-eslint-plugin": "^7.0.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"eslint-plugin-yml": "^3.0.0",
|
|
104
104
|
"events": "^3.3.0",
|
|
105
105
|
"mocha": "^11.0.0",
|
|
106
|
-
"nyc": "^
|
|
106
|
+
"nyc": "^18.0.0",
|
|
107
107
|
"pako": "^2.1.0",
|
|
108
108
|
"prettier": "^3.3.2",
|
|
109
109
|
"semver": "^7.6.2",
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
"stylelint-config-standard": "^40.0.0",
|
|
113
113
|
"stylelint-config-standard-vue": "^1.0.0",
|
|
114
114
|
"stylelint-stylus": "^1.0.0",
|
|
115
|
-
"tsdown": "^0.
|
|
115
|
+
"tsdown": "^0.21.0",
|
|
116
116
|
"tsx": "^4.21.0",
|
|
117
|
-
"typescript": "~
|
|
117
|
+
"typescript": "~6.0.0",
|
|
118
118
|
"typescript-eslint": "^8.16.0",
|
|
119
|
-
"vite-plugin-eslint4b": "^0.
|
|
119
|
+
"vite-plugin-eslint4b": "^0.8.0",
|
|
120
120
|
"vitepress": "^1.2.3",
|
|
121
121
|
"vue-eslint-parser": "^10.0.0"
|
|
122
122
|
},
|
package/lib/chunk-DQk6qfdC.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!no_symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll as t };
|