eslint-plugin-toml 0.11.0 → 0.11.1
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/meta.d.ts +2 -2
- package/lib/meta.js +1 -1
- package/lib/rules/comma-style.js +1 -2
- package/lib/rules/indent.js +4 -6
- package/lib/rules/inline-table-curly-spacing.js +1 -2
- package/lib/rules/key-spacing.js +19 -6
- package/lib/rules/keys-order.js +1 -2
- package/lib/rules/no-mixed-type-in-array.js +13 -2
- package/lib/rules/no-non-decimal-integer.js +3 -4
- package/lib/rules/precision-of-fractional-seconds.js +3 -5
- package/lib/rules/precision-of-integer.js +1 -2
- package/lib/rules/quoted-keys.js +2 -3
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/vue-custom-block/no-parsing-error.js +1 -2
- package/lib/utils/ast-utils.js +9 -10
- package/lib/utils/bit.js +1 -2
- package/lib/utils/casing.js +14 -14
- package/lib/utils/compat.js +2 -3
- package/lib/utils/index.js +10 -3
- package/package.json +48 -46
package/lib/meta.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const name
|
|
2
|
-
export declare const version
|
|
1
|
+
export declare const name = "eslint-plugin-toml";
|
|
2
|
+
export declare const version = "0.11.1";
|
package/lib/meta.js
CHANGED
package/lib/rules/comma-style.js
CHANGED
|
@@ -38,7 +38,6 @@ exports.default = (0, utils_1.createRule)("comma-style", {
|
|
|
38
38
|
},
|
|
39
39
|
create(context) {
|
|
40
40
|
var _a;
|
|
41
|
-
var _b;
|
|
42
41
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
43
42
|
if (!sourceCode.parserServices.isTOML) {
|
|
44
43
|
return {};
|
|
@@ -47,7 +46,7 @@ exports.default = (0, utils_1.createRule)("comma-style", {
|
|
|
47
46
|
const exceptions = {};
|
|
48
47
|
if (context.options.length === 2 &&
|
|
49
48
|
Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
|
|
50
|
-
(_a =
|
|
49
|
+
(_a = context.options)[1] ?? (_a[1] = { exceptions: {} });
|
|
51
50
|
const rawExceptions = context.options[1].exceptions;
|
|
52
51
|
const keys = Object.keys(rawExceptions);
|
|
53
52
|
for (let i = 0; i < keys.length; i++)
|
package/lib/rules/indent.js
CHANGED
|
@@ -8,7 +8,7 @@ const ITERATION_OPTS = Object.freeze({
|
|
|
8
8
|
includeComments: true,
|
|
9
9
|
});
|
|
10
10
|
function buildIndentUtility(optionValue) {
|
|
11
|
-
const indent = optionValue
|
|
11
|
+
const indent = optionValue ?? 2;
|
|
12
12
|
const textIndent = typeof indent === "number" ? " ".repeat(indent) : "\t";
|
|
13
13
|
return {
|
|
14
14
|
getIndentText: (offset) => offset === 1 ? textIndent : textIndent.repeat(offset),
|
|
@@ -52,14 +52,13 @@ exports.default = (0, utils_1.createRule)("indent", {
|
|
|
52
52
|
type: "layout",
|
|
53
53
|
},
|
|
54
54
|
create(context) {
|
|
55
|
-
var _a, _b, _c, _d;
|
|
56
55
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
57
56
|
if (!sourceCode.parserServices.isTOML) {
|
|
58
57
|
return {};
|
|
59
58
|
}
|
|
60
59
|
const { getIndentText, outdent } = buildIndentUtility(context.options[0]);
|
|
61
|
-
const subTablesOffset =
|
|
62
|
-
const keyValuePairsOffset =
|
|
60
|
+
const subTablesOffset = context.options[1]?.subTables ?? 0;
|
|
61
|
+
const keyValuePairsOffset = context.options[1]?.keyValuePairs ?? 0;
|
|
63
62
|
const offsets = new Map();
|
|
64
63
|
function setOffset(token, offset, baseToken) {
|
|
65
64
|
if (token == null) {
|
|
@@ -362,11 +361,10 @@ exports.default = (0, utils_1.createRule)("indent", {
|
|
|
362
361
|
continue;
|
|
363
362
|
}
|
|
364
363
|
const indentCandidate = expectedIndents.find((indent, index) => {
|
|
365
|
-
var _a, _b;
|
|
366
364
|
if (indent.length <= commentLineIndent.actualIndent.length) {
|
|
367
365
|
return true;
|
|
368
366
|
}
|
|
369
|
-
const prev =
|
|
367
|
+
const prev = expectedIndents[index + 1]?.length ?? -1;
|
|
370
368
|
return (prev < commentLineIndent.actualIndent.length &&
|
|
371
369
|
commentLineIndent.actualIndent.length < indent.length);
|
|
372
370
|
});
|
|
@@ -56,7 +56,6 @@ exports.default = (0, utils_1.createRule)("inline-table-curly-spacing", {
|
|
|
56
56
|
return options.spaced;
|
|
57
57
|
},
|
|
58
58
|
isClosingCurlyBraceMustBeSpaced(penultimate) {
|
|
59
|
-
var _a;
|
|
60
59
|
const targetPenultimateType = options.arraysInObjectsException && (0, ast_utils_1.isClosingBracketToken)(penultimate)
|
|
61
60
|
? "TOMLArray"
|
|
62
61
|
: options.objectsInObjectsException &&
|
|
@@ -64,7 +63,7 @@ exports.default = (0, utils_1.createRule)("inline-table-curly-spacing", {
|
|
|
64
63
|
? "TOMLInlineTable"
|
|
65
64
|
: null;
|
|
66
65
|
return targetPenultimateType &&
|
|
67
|
-
|
|
66
|
+
sourceCode.getNodeByRangeIndex(penultimate.range[0])?.type ===
|
|
68
67
|
targetPenultimateType
|
|
69
68
|
? !options.spaced
|
|
70
69
|
: options.spaced;
|
package/lib/rules/key-spacing.js
CHANGED
|
@@ -56,7 +56,11 @@ function initOptionProperty(fromOptions) {
|
|
|
56
56
|
function initOptions(fromOptions) {
|
|
57
57
|
let align, multiLine, singleLine;
|
|
58
58
|
if (typeof fromOptions.align === "object") {
|
|
59
|
-
align =
|
|
59
|
+
align = {
|
|
60
|
+
...initOptionProperty(fromOptions.align),
|
|
61
|
+
on: fromOptions.align.on || "equal",
|
|
62
|
+
mode: fromOptions.align.mode || "strict",
|
|
63
|
+
};
|
|
60
64
|
multiLine = initOptionProperty(fromOptions.multiLine || fromOptions);
|
|
61
65
|
singleLine = initOptionProperty(fromOptions.singleLine || fromOptions);
|
|
62
66
|
}
|
|
@@ -98,7 +102,10 @@ const OBJECT_WITHOUT_ON_SCHEMA = {
|
|
|
98
102
|
};
|
|
99
103
|
const ALIGN_OBJECT_SCHEMA = {
|
|
100
104
|
type: "object",
|
|
101
|
-
properties:
|
|
105
|
+
properties: {
|
|
106
|
+
on: ON_SCHEMA,
|
|
107
|
+
...OBJECT_WITHOUT_ON_SCHEMA.properties,
|
|
108
|
+
},
|
|
102
109
|
additionalProperties: false,
|
|
103
110
|
};
|
|
104
111
|
exports.default = (0, utils_1.createRule)("key-spacing", {
|
|
@@ -114,9 +121,12 @@ exports.default = (0, utils_1.createRule)("key-spacing", {
|
|
|
114
121
|
anyOf: [
|
|
115
122
|
{
|
|
116
123
|
type: "object",
|
|
117
|
-
properties:
|
|
124
|
+
properties: {
|
|
125
|
+
align: {
|
|
118
126
|
anyOf: [ON_SCHEMA, ALIGN_OBJECT_SCHEMA],
|
|
119
|
-
}
|
|
127
|
+
},
|
|
128
|
+
...OBJECT_WITHOUT_ON_SCHEMA.properties,
|
|
129
|
+
},
|
|
120
130
|
additionalProperties: false,
|
|
121
131
|
},
|
|
122
132
|
{
|
|
@@ -125,9 +135,12 @@ exports.default = (0, utils_1.createRule)("key-spacing", {
|
|
|
125
135
|
singleLine: OBJECT_WITHOUT_ON_SCHEMA,
|
|
126
136
|
multiLine: {
|
|
127
137
|
type: "object",
|
|
128
|
-
properties:
|
|
138
|
+
properties: {
|
|
139
|
+
align: {
|
|
129
140
|
anyOf: [ON_SCHEMA, ALIGN_OBJECT_SCHEMA],
|
|
130
|
-
}
|
|
141
|
+
},
|
|
142
|
+
...OBJECT_WITHOUT_ON_SCHEMA.properties,
|
|
143
|
+
},
|
|
131
144
|
additionalProperties: false,
|
|
132
145
|
},
|
|
133
146
|
},
|
package/lib/rules/keys-order.js
CHANGED
|
@@ -27,7 +27,6 @@ exports.default = (0, utils_1.createRule)("keys-order", {
|
|
|
27
27
|
return {};
|
|
28
28
|
}
|
|
29
29
|
function applyKey(tableKeys, node) {
|
|
30
|
-
var _a;
|
|
31
30
|
const keyNames = (0, toml_eslint_parser_1.getStaticTOMLValue)(node.key);
|
|
32
31
|
let before = null;
|
|
33
32
|
let keys = tableKeys;
|
|
@@ -40,7 +39,7 @@ exports.default = (0, utils_1.createRule)("keys-order", {
|
|
|
40
39
|
node,
|
|
41
40
|
keys: [],
|
|
42
41
|
};
|
|
43
|
-
before =
|
|
42
|
+
before = lodash_1.default.last(keys)?.node || null;
|
|
44
43
|
keys.push(next);
|
|
45
44
|
}
|
|
46
45
|
else {
|
|
@@ -39,12 +39,23 @@ exports.default = (0, utils_1.createRule)("no-mixed-type-in-array", {
|
|
|
39
39
|
type: "suggestion",
|
|
40
40
|
},
|
|
41
41
|
create(context) {
|
|
42
|
-
var _a;
|
|
43
42
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
44
43
|
if (!sourceCode.parserServices.isTOML) {
|
|
45
44
|
return {};
|
|
46
45
|
}
|
|
47
|
-
const typeMap =
|
|
46
|
+
const typeMap = {
|
|
47
|
+
string: "String",
|
|
48
|
+
integer: "Integer",
|
|
49
|
+
float: "Float",
|
|
50
|
+
boolean: "Boolean",
|
|
51
|
+
offsetDateTime: "Datetime",
|
|
52
|
+
localDateTime: "Datetime",
|
|
53
|
+
localDate: "Datetime",
|
|
54
|
+
localTime: "Datetime",
|
|
55
|
+
array: "Array",
|
|
56
|
+
inlineTable: "Inline Table",
|
|
57
|
+
...(context.options[0]?.typeMap || {}),
|
|
58
|
+
};
|
|
48
59
|
function getDataType(node) {
|
|
49
60
|
if (node.type === "TOMLArray") {
|
|
50
61
|
return "array";
|
|
@@ -51,14 +51,13 @@ exports.default = (0, utils_1.createRule)("no-non-decimal-integer", {
|
|
|
51
51
|
type: "suggestion",
|
|
52
52
|
},
|
|
53
53
|
create(context) {
|
|
54
|
-
var _a, _b, _c;
|
|
55
54
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
56
55
|
if (!sourceCode.parserServices.isTOML) {
|
|
57
56
|
return {};
|
|
58
57
|
}
|
|
59
|
-
const allowHexadecimal = Boolean(
|
|
60
|
-
const allowOctal = Boolean(
|
|
61
|
-
const allowBinary = Boolean(
|
|
58
|
+
const allowHexadecimal = Boolean(context.options[0]?.allowHexadecimal);
|
|
59
|
+
const allowOctal = Boolean(context.options[0]?.allowOctal);
|
|
60
|
+
const allowBinary = Boolean(context.options[0]?.allowBinary);
|
|
62
61
|
function buildFixer(node, text, mark) {
|
|
63
62
|
if (allowHexadecimal || allowOctal || allowBinary) {
|
|
64
63
|
return undefined;
|
|
@@ -27,17 +27,15 @@ exports.default = (0, utils_1.createRule)("precision-of-fractional-seconds", {
|
|
|
27
27
|
type: "problem",
|
|
28
28
|
},
|
|
29
29
|
create(context) {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
32
31
|
if (!sourceCode.parserServices.isTOML) {
|
|
33
32
|
return {};
|
|
34
33
|
}
|
|
35
|
-
const max =
|
|
34
|
+
const max = context.options[0]?.max ?? 3;
|
|
36
35
|
function verifyText(node) {
|
|
37
|
-
var _a, _b;
|
|
38
36
|
const text = node.datetime;
|
|
39
|
-
const fractional =
|
|
40
|
-
|
|
37
|
+
const fractional = /^\d{4}-\d{2}-\d{2}[ t]\d{2}:\d{2}:\d{2}.(\d+)/iu.exec(text)?.[1] ||
|
|
38
|
+
/^\d{2}:\d{2}:\d{2}.(\d+)/u.exec(text)?.[1];
|
|
41
39
|
if (!fractional) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
@@ -35,12 +35,11 @@ exports.default = (0, utils_1.createRule)("precision-of-integer", {
|
|
|
35
35
|
type: "problem",
|
|
36
36
|
},
|
|
37
37
|
create(context) {
|
|
38
|
-
var _a, _b;
|
|
39
38
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
40
39
|
if (!sourceCode.parserServices.isTOML) {
|
|
41
40
|
return {};
|
|
42
41
|
}
|
|
43
|
-
const maxBit =
|
|
42
|
+
const maxBit = context.options[0]?.maxBit ?? 64;
|
|
44
43
|
const maxValues = getMaxValues(maxBit);
|
|
45
44
|
function verifyMaxValue(node, numText, max) {
|
|
46
45
|
const num = numText.replace(/^0+/, "").toLowerCase();
|
package/lib/rules/quoted-keys.js
CHANGED
|
@@ -32,13 +32,12 @@ exports.default = (0, utils_1.createRule)("quoted-keys", {
|
|
|
32
32
|
type: "layout",
|
|
33
33
|
},
|
|
34
34
|
create(context) {
|
|
35
|
-
var _a, _b, _c;
|
|
36
35
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
37
36
|
if (!sourceCode.parserServices.isTOML) {
|
|
38
37
|
return {};
|
|
39
38
|
}
|
|
40
|
-
const prefer =
|
|
41
|
-
const numbers =
|
|
39
|
+
const prefer = context.options[0]?.prefer ?? "as-needed";
|
|
40
|
+
const numbers = context.options[0]?.numbers !== false;
|
|
42
41
|
return {
|
|
43
42
|
TOMLBare(node) {
|
|
44
43
|
if (prefer === "always") {
|
|
@@ -118,7 +118,7 @@ exports.default = (0, utils_1.createRule)("spaced-comment", {
|
|
|
118
118
|
return fixer.insertTextAfterRange([start, end], " ");
|
|
119
119
|
}
|
|
120
120
|
end += match[0].length;
|
|
121
|
-
return fixer.replaceTextRange([start, end], `#${
|
|
121
|
+
return fixer.replaceTextRange([start, end], `#${match?.[1] ? match[1] : ""}`);
|
|
122
122
|
},
|
|
123
123
|
messageId,
|
|
124
124
|
data: { refChar },
|
|
@@ -14,12 +14,11 @@ exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
|
|
|
14
14
|
type: "problem",
|
|
15
15
|
},
|
|
16
16
|
create(context, { customBlock }) {
|
|
17
|
-
var _a;
|
|
18
17
|
if (!customBlock) {
|
|
19
18
|
return {};
|
|
20
19
|
}
|
|
21
20
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
22
|
-
const parserServices =
|
|
21
|
+
const parserServices = context.parserServices ?? sourceCode.parserServices;
|
|
23
22
|
const parseError = parserServices.parseError;
|
|
24
23
|
if (parseError) {
|
|
25
24
|
let loc = undefined;
|
package/lib/utils/ast-utils.js
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isNotClosingParenToken = exports.LINEBREAK_MATCHER = void 0;
|
|
4
|
+
exports.isCommentToken = isCommentToken;
|
|
5
|
+
exports.isCommaToken = isCommaToken;
|
|
6
|
+
exports.isEqualSign = isEqualSign;
|
|
7
|
+
exports.isClosingParenToken = isClosingParenToken;
|
|
8
|
+
exports.isClosingBracketToken = isClosingBracketToken;
|
|
9
|
+
exports.isClosingBraceToken = isClosingBraceToken;
|
|
10
|
+
exports.isTokenOnSameLine = isTokenOnSameLine;
|
|
4
11
|
exports.LINEBREAK_MATCHER = /\r\n|[\n\r\u2028\u2029]/u;
|
|
5
12
|
function isCommentToken(token) {
|
|
6
13
|
return Boolean(token && token.type === "Block");
|
|
7
14
|
}
|
|
8
|
-
exports.isCommentToken = isCommentToken;
|
|
9
15
|
function isCommaToken(token) {
|
|
10
16
|
return token != null && token.value === "," && token.type === "Punctuator";
|
|
11
17
|
}
|
|
12
|
-
exports.isCommaToken = isCommaToken;
|
|
13
18
|
function isEqualSign(token) {
|
|
14
19
|
return token != null && token.type === "Punctuator" && token.value === "=";
|
|
15
20
|
}
|
|
16
|
-
exports.isEqualSign = isEqualSign;
|
|
17
21
|
function isClosingParenToken(token) {
|
|
18
22
|
return token != null && token.value === ")" && token.type === "Punctuator";
|
|
19
23
|
}
|
|
20
|
-
exports.isClosingParenToken = isClosingParenToken;
|
|
21
24
|
exports.isNotClosingParenToken = negate(isClosingParenToken);
|
|
22
25
|
function isClosingBracketToken(token) {
|
|
23
26
|
return token != null && token.value === "]" && token.type === "Punctuator";
|
|
24
27
|
}
|
|
25
|
-
exports.isClosingBracketToken = isClosingBracketToken;
|
|
26
28
|
function isClosingBraceToken(token) {
|
|
27
29
|
return token != null && token.value === "}" && token.type === "Punctuator";
|
|
28
30
|
}
|
|
29
|
-
exports.isClosingBraceToken = isClosingBraceToken;
|
|
30
31
|
function isTokenOnSameLine(left, right) {
|
|
31
|
-
|
|
32
|
-
return ((_a = left === null || left === void 0 ? void 0 : left.loc) === null || _a === void 0 ? void 0 : _a.end.line) === ((_b = right === null || right === void 0 ? void 0 : right.loc) === null || _b === void 0 ? void 0 : _b.start.line);
|
|
32
|
+
return left?.loc?.end.line === right?.loc?.start.line;
|
|
33
33
|
}
|
|
34
|
-
exports.isTokenOnSameLine = isTokenOnSameLine;
|
|
35
34
|
function negate(f) {
|
|
36
35
|
return ((token) => !f(token));
|
|
37
36
|
}
|
package/lib/utils/bit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxBitToMaxValues =
|
|
3
|
+
exports.maxBitToMaxValues = maxBitToMaxValues;
|
|
4
4
|
function maxBitToMaxValues(maxBit) {
|
|
5
5
|
const binaryMax = [];
|
|
6
6
|
const minusMax = [0];
|
|
@@ -41,4 +41,3 @@ function maxBitToMaxValues(maxBit) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
exports.maxBitToMaxValues = maxBitToMaxValues;
|
package/lib/utils/casing.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.allowedCaseOptions = void 0;
|
|
4
|
+
exports.kebabCase = kebabCase;
|
|
5
|
+
exports.isKebabCase = isKebabCase;
|
|
6
|
+
exports.snakeCase = snakeCase;
|
|
7
|
+
exports.isSnakeCase = isSnakeCase;
|
|
8
|
+
exports.screamingSnakeCase = screamingSnakeCase;
|
|
9
|
+
exports.isScreamingSnakeCase = isScreamingSnakeCase;
|
|
10
|
+
exports.camelCase = camelCase;
|
|
11
|
+
exports.isCamelCase = isCamelCase;
|
|
12
|
+
exports.pascalCase = pascalCase;
|
|
13
|
+
exports.isPascalCase = isPascalCase;
|
|
14
|
+
exports.getChecker = getChecker;
|
|
15
|
+
exports.getConverter = getConverter;
|
|
16
|
+
exports.getExactConverter = getExactConverter;
|
|
4
17
|
exports.allowedCaseOptions = [
|
|
5
18
|
"camelCase",
|
|
6
19
|
"kebab-case",
|
|
@@ -27,7 +40,6 @@ function kebabCase(str) {
|
|
|
27
40
|
}
|
|
28
41
|
return res.toLowerCase();
|
|
29
42
|
}
|
|
30
|
-
exports.kebabCase = kebabCase;
|
|
31
43
|
function isKebabCase(str) {
|
|
32
44
|
if (hasUpper(str) ||
|
|
33
45
|
hasSymbols(str) ||
|
|
@@ -37,7 +49,6 @@ function isKebabCase(str) {
|
|
|
37
49
|
}
|
|
38
50
|
return true;
|
|
39
51
|
}
|
|
40
|
-
exports.isKebabCase = isKebabCase;
|
|
41
52
|
function snakeCase(str) {
|
|
42
53
|
let res = str.replace(/-/gu, "_");
|
|
43
54
|
if (hasLower(res)) {
|
|
@@ -45,14 +56,12 @@ function snakeCase(str) {
|
|
|
45
56
|
}
|
|
46
57
|
return res.toLowerCase();
|
|
47
58
|
}
|
|
48
|
-
exports.snakeCase = snakeCase;
|
|
49
59
|
function isSnakeCase(str) {
|
|
50
60
|
if (hasUpper(str) || hasSymbols(str) || /-|__|\s/u.test(str)) {
|
|
51
61
|
return false;
|
|
52
62
|
}
|
|
53
63
|
return true;
|
|
54
64
|
}
|
|
55
|
-
exports.isSnakeCase = isSnakeCase;
|
|
56
65
|
function screamingSnakeCase(str) {
|
|
57
66
|
let res = str.replace(/-/gu, "_");
|
|
58
67
|
if (hasLower(res)) {
|
|
@@ -60,14 +69,12 @@ function screamingSnakeCase(str) {
|
|
|
60
69
|
}
|
|
61
70
|
return res.toUpperCase();
|
|
62
71
|
}
|
|
63
|
-
exports.screamingSnakeCase = screamingSnakeCase;
|
|
64
72
|
function isScreamingSnakeCase(str) {
|
|
65
73
|
if (hasLower(str) || hasSymbols(str) || /-|__|\s/u.test(str)) {
|
|
66
74
|
return false;
|
|
67
75
|
}
|
|
68
76
|
return true;
|
|
69
77
|
}
|
|
70
|
-
exports.isScreamingSnakeCase = isScreamingSnakeCase;
|
|
71
78
|
function camelCase(str) {
|
|
72
79
|
if (isPascalCase(str)) {
|
|
73
80
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
@@ -78,7 +85,6 @@ function camelCase(str) {
|
|
|
78
85
|
}
|
|
79
86
|
return s.replace(/[-_](\w)/gu, (_, c) => (c ? c.toUpperCase() : ""));
|
|
80
87
|
}
|
|
81
|
-
exports.camelCase = camelCase;
|
|
82
88
|
function isCamelCase(str) {
|
|
83
89
|
if (hasSymbols(str) ||
|
|
84
90
|
/^[A-Z]/u.test(str) ||
|
|
@@ -87,11 +93,9 @@ function isCamelCase(str) {
|
|
|
87
93
|
}
|
|
88
94
|
return true;
|
|
89
95
|
}
|
|
90
|
-
exports.isCamelCase = isCamelCase;
|
|
91
96
|
function pascalCase(str) {
|
|
92
97
|
return capitalize(camelCase(str));
|
|
93
98
|
}
|
|
94
|
-
exports.pascalCase = pascalCase;
|
|
95
99
|
function isPascalCase(str) {
|
|
96
100
|
if (hasSymbols(str) ||
|
|
97
101
|
/^[a-z]/u.test(str) ||
|
|
@@ -100,7 +104,6 @@ function isPascalCase(str) {
|
|
|
100
104
|
}
|
|
101
105
|
return true;
|
|
102
106
|
}
|
|
103
|
-
exports.isPascalCase = isPascalCase;
|
|
104
107
|
const convertersMap = {
|
|
105
108
|
"kebab-case": kebabCase,
|
|
106
109
|
snake_case: snakeCase,
|
|
@@ -118,11 +121,9 @@ const checkersMap = {
|
|
|
118
121
|
function getChecker(name) {
|
|
119
122
|
return checkersMap[name] || isPascalCase;
|
|
120
123
|
}
|
|
121
|
-
exports.getChecker = getChecker;
|
|
122
124
|
function getConverter(name) {
|
|
123
125
|
return convertersMap[name] || pascalCase;
|
|
124
126
|
}
|
|
125
|
-
exports.getConverter = getConverter;
|
|
126
127
|
function getExactConverter(name) {
|
|
127
128
|
const converter = getConverter(name);
|
|
128
129
|
const checker = getChecker(name);
|
|
@@ -131,4 +132,3 @@ function getExactConverter(name) {
|
|
|
131
132
|
return checker(result) ? result : str;
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
|
-
exports.getExactConverter = getExactConverter;
|
package/lib/utils/compat.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSourceCode = getSourceCode;
|
|
4
|
+
exports.getFilename = getFilename;
|
|
4
5
|
const eslint_compat_utils_1 = require("eslint-compat-utils");
|
|
5
6
|
function getSourceCode(context) {
|
|
6
7
|
return (0, eslint_compat_utils_1.getSourceCode)(context);
|
|
7
8
|
}
|
|
8
|
-
exports.getSourceCode = getSourceCode;
|
|
9
9
|
function getFilename(context) {
|
|
10
10
|
return (0, eslint_compat_utils_1.getFilename)(context);
|
|
11
11
|
}
|
|
12
|
-
exports.getFilename = getFilename;
|
package/lib/utils/index.js
CHANGED
|
@@ -26,13 +26,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createRule =
|
|
29
|
+
exports.createRule = createRule;
|
|
30
30
|
const tomlESLintParser = __importStar(require("toml-eslint-parser"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const compat_1 = require("./compat");
|
|
33
33
|
function createRule(ruleName, rule) {
|
|
34
34
|
return {
|
|
35
|
-
meta:
|
|
35
|
+
meta: {
|
|
36
|
+
...rule.meta,
|
|
37
|
+
docs: {
|
|
38
|
+
...rule.meta.docs,
|
|
39
|
+
url: `https://ota-meshi.github.io/eslint-plugin-toml/rules/${ruleName}.html`,
|
|
40
|
+
ruleId: `toml/${ruleName}`,
|
|
41
|
+
ruleName,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
36
44
|
create(context) {
|
|
37
45
|
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
38
46
|
if (typeof sourceCode.parserServices.defineCustomBlocksVisitor ===
|
|
@@ -53,4 +61,3 @@ function createRule(ruleName, rule) {
|
|
|
53
61
|
},
|
|
54
62
|
};
|
|
55
63
|
}
|
|
56
|
-
exports.createRule = createRule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-toml",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for TOML.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"build:meta": "ts-node --transpile-only ./tools/update-meta.ts",
|
|
16
16
|
"build:ts": "tsc --project ./tsconfig.build.json",
|
|
17
17
|
"clean": "rimraf .nyc_output dist coverage",
|
|
18
|
-
"lint": "eslint . --
|
|
19
|
-
"eslint-fix": "eslint . --
|
|
18
|
+
"lint": "eslint . --ignore-pattern playground",
|
|
19
|
+
"eslint-fix": "eslint . --ignore-pattern playground --fix",
|
|
20
20
|
"pretest:base": "cross-env DEBUG=eslint-plugin-toml*",
|
|
21
21
|
"test:base": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
|
|
22
22
|
"test": "npm run test:base",
|
|
@@ -59,57 +59,59 @@
|
|
|
59
59
|
"debug": "^4.1.1",
|
|
60
60
|
"eslint-compat-utils": "^0.5.0",
|
|
61
61
|
"lodash": "^4.17.19",
|
|
62
|
-
"toml-eslint-parser": "^0.
|
|
62
|
+
"toml-eslint-parser": "^0.10.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@changesets/changelog-github": "^0.5.0",
|
|
66
|
-
"@changesets/cli": "^2.
|
|
67
|
-
"@
|
|
68
|
-
"@ota-meshi/
|
|
69
|
-
"@
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/eslint
|
|
72
|
-
"@types/eslint-
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/
|
|
78
|
-
"@
|
|
79
|
-
"@typescript-eslint/
|
|
80
|
-
"
|
|
66
|
+
"@changesets/cli": "^2.27.5",
|
|
67
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
68
|
+
"@ota-meshi/eslint-plugin": "^0.17.4",
|
|
69
|
+
"@ota-meshi/site-kit-eslint-editor-vue": "^0.2.1",
|
|
70
|
+
"@types/debug": "^4.1.12",
|
|
71
|
+
"@types/eslint": "^8.56.10",
|
|
72
|
+
"@types/eslint-scope": "^3.7.7",
|
|
73
|
+
"@types/eslint-visitor-keys": "^3.3.0",
|
|
74
|
+
"@types/estree": "^1.0.5",
|
|
75
|
+
"@types/lodash": "^4.17.5",
|
|
76
|
+
"@types/mocha": "^10.0.7",
|
|
77
|
+
"@types/node": "^20.14.8",
|
|
78
|
+
"@types/semver": "^7.5.8",
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
|
80
|
+
"@typescript-eslint/parser": "^7.13.1",
|
|
81
|
+
"cross-env": "^7.0.3",
|
|
81
82
|
"env-cmd": "^10.1.0",
|
|
82
|
-
"esbuild": "^0.
|
|
83
|
-
"eslint": "^
|
|
84
|
-
"eslint-config-prettier": "^9.
|
|
85
|
-
"eslint-plugin-eslint-
|
|
86
|
-
"eslint-plugin-
|
|
87
|
-
"eslint-plugin-json-schema-validator": "^5.
|
|
88
|
-
"eslint-plugin-jsonc": "^2.
|
|
89
|
-
"eslint-plugin-markdown": "^
|
|
90
|
-
"eslint-plugin-n": "^
|
|
91
|
-
"eslint-plugin-
|
|
92
|
-
"eslint-plugin-
|
|
93
|
-
"eslint-plugin-
|
|
94
|
-
"eslint-plugin-
|
|
95
|
-
"eslint-plugin-
|
|
96
|
-
"
|
|
83
|
+
"esbuild": "^0.21.0",
|
|
84
|
+
"eslint": "^9.5.0",
|
|
85
|
+
"eslint-config-prettier": "^9.1.0",
|
|
86
|
+
"eslint-plugin-eslint-plugin": "^6.1.0",
|
|
87
|
+
"eslint-plugin-jsdoc": "^48.2.15",
|
|
88
|
+
"eslint-plugin-json-schema-validator": "^5.1.1",
|
|
89
|
+
"eslint-plugin-jsonc": "^2.16.0",
|
|
90
|
+
"eslint-plugin-markdown": "^5.0.0",
|
|
91
|
+
"eslint-plugin-n": "^17.9.0",
|
|
92
|
+
"eslint-plugin-node-dependencies": "^0.12.0",
|
|
93
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
94
|
+
"eslint-plugin-regexp": "^2.6.0",
|
|
95
|
+
"eslint-plugin-toml": "^0.11.0",
|
|
96
|
+
"eslint-plugin-vue": "^9.26.0",
|
|
97
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
97
98
|
"events": "^3.3.0",
|
|
98
|
-
"mocha": "^10.
|
|
99
|
-
"nyc": "^
|
|
99
|
+
"mocha": "^10.4.0",
|
|
100
|
+
"nyc": "^17.0.0",
|
|
100
101
|
"pako": "^2.1.0",
|
|
101
|
-
"prettier": "^3.
|
|
102
|
-
"semver": "^7.
|
|
103
|
-
"stylelint": "^16.
|
|
104
|
-
"stylelint-config-recommended-vue": "^1.
|
|
105
|
-
"stylelint-config-standard": "^36.0.
|
|
102
|
+
"prettier": "^3.3.2",
|
|
103
|
+
"semver": "^7.6.2",
|
|
104
|
+
"stylelint": "^16.6.1",
|
|
105
|
+
"stylelint-config-recommended-vue": "^1.5.0",
|
|
106
|
+
"stylelint-config-standard": "^36.0.1",
|
|
106
107
|
"stylelint-config-standard-vue": "^1.0.0",
|
|
107
108
|
"stylelint-stylus": "^1.0.0",
|
|
108
|
-
"ts-node": "^10.
|
|
109
|
-
"typescript": "~5.
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
109
|
+
"ts-node": "^10.9.2",
|
|
110
|
+
"typescript": "~5.5.0",
|
|
111
|
+
"typescript-eslint": "^7.13.1",
|
|
112
|
+
"vite-plugin-eslint4b": "^0.4.6",
|
|
113
|
+
"vitepress": "^1.2.3",
|
|
114
|
+
"vue-eslint-parser": "^9.4.3"
|
|
113
115
|
},
|
|
114
116
|
"publishConfig": {
|
|
115
117
|
"access": "public"
|