eslint-plugin-toml 0.5.0 → 0.6.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/meta.d.ts +1 -1
- package/lib/meta.js +1 -1
- package/lib/rules/comma-style.js +3 -1
- package/lib/rules/indent.js +3 -2
- package/lib/rules/key-spacing.js +3 -2
- package/lib/rules/keys-order.js +3 -2
- package/lib/rules/no-mixed-type-in-array.js +3 -1
- package/lib/rules/no-non-decimal-integer.js +3 -1
- package/lib/rules/no-space-dots.js +3 -2
- package/lib/rules/no-unreadable-number-separator.js +3 -2
- package/lib/rules/padding-line-between-pairs.js +3 -2
- package/lib/rules/padding-line-between-tables.js +3 -2
- package/lib/rules/precision-of-fractional-seconds.js +3 -1
- package/lib/rules/precision-of-integer.js +3 -1
- package/lib/rules/quoted-keys.js +3 -1
- package/lib/rules/space-eq-sign.js +3 -2
- package/lib/rules/spaced-comment.js +3 -2
- package/lib/rules/table-bracket-spacing.js +3 -2
- package/lib/rules/tables-order.js +3 -2
- package/lib/rules/vue-custom-block/no-parsing-error.js +5 -1
- package/lib/utils/compat.d.ts +5 -0
- package/lib/utils/compat.js +12 -0
- package/lib/utils/index.js +7 -5
- package/package.json +21 -17
package/lib/meta.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name: "eslint-plugin-toml";
|
|
2
|
-
export declare const version: "0.
|
|
2
|
+
export declare const version: "0.6.0";
|
package/lib/meta.js
CHANGED
package/lib/rules/comma-style.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
const coreRule = (0, utils_1.getCoreRule)("comma-style");
|
|
5
6
|
exports.default = (0, utils_1.createRule)("comma-style", {
|
|
6
7
|
meta: {
|
|
@@ -16,7 +17,8 @@ exports.default = (0, utils_1.createRule)("comma-style", {
|
|
|
16
17
|
type: coreRule.meta.type,
|
|
17
18
|
},
|
|
18
19
|
create(context) {
|
|
19
|
-
|
|
20
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
21
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
20
22
|
return {};
|
|
21
23
|
}
|
|
22
24
|
return (0, utils_1.defineWrapperListener)(coreRule, context, {
|
package/lib/rules/indent.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.buildIndentUtility = void 0;
|
|
|
4
4
|
const toml_eslint_parser_1 = require("toml-eslint-parser");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
7
|
+
const compat_1 = require("../utils/compat");
|
|
7
8
|
const ITERATION_OPTS = Object.freeze({
|
|
8
9
|
includeComments: true,
|
|
9
10
|
});
|
|
@@ -54,13 +55,13 @@ exports.default = (0, utils_1.createRule)("indent", {
|
|
|
54
55
|
},
|
|
55
56
|
create(context) {
|
|
56
57
|
var _a, _b, _c, _d;
|
|
57
|
-
|
|
58
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
59
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
58
60
|
return {};
|
|
59
61
|
}
|
|
60
62
|
const { getIndentText, outdent } = buildIndentUtility(context.options[0]);
|
|
61
63
|
const subTablesOffset = (_b = (_a = context.options[1]) === null || _a === void 0 ? void 0 : _a.subTables) !== null && _b !== void 0 ? _b : 0;
|
|
62
64
|
const keyValuePairsOffset = (_d = (_c = context.options[1]) === null || _c === void 0 ? void 0 : _c.keyValuePairs) !== null && _d !== void 0 ? _d : 0;
|
|
63
|
-
const sourceCode = context.getSourceCode();
|
|
64
65
|
const offsets = new Map();
|
|
65
66
|
function setOffset(token, offset, baseToken) {
|
|
66
67
|
if (token == null) {
|
package/lib/rules/key-spacing.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
4
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
5
|
+
const compat_1 = require("../utils/compat");
|
|
5
6
|
function containsLineTerminator(str) {
|
|
6
7
|
return /[\n\r\u2028\u2029]/u.test(str);
|
|
7
8
|
}
|
|
@@ -155,12 +156,12 @@ exports.default = (0, utils_1.createRule)("key-spacing", {
|
|
|
155
156
|
create,
|
|
156
157
|
});
|
|
157
158
|
function create(context) {
|
|
158
|
-
|
|
159
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
160
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
159
161
|
return {};
|
|
160
162
|
}
|
|
161
163
|
const options = context.options[0] || {};
|
|
162
164
|
const { multiLine: multiLineOptions, singleLine: singleLineOptions, align: alignmentOptions, } = initOptions(options);
|
|
163
|
-
const sourceCode = context.getSourceCode();
|
|
164
165
|
function isKeyValueProperty(property) {
|
|
165
166
|
return property.type === "TOMLKeyValue";
|
|
166
167
|
}
|
package/lib/rules/keys-order.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const toml_eslint_parser_1 = require("toml-eslint-parser");
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const compat_1 = require("../utils/compat");
|
|
9
10
|
exports.default = (0, utils_1.createRule)("keys-order", {
|
|
10
11
|
meta: {
|
|
11
12
|
docs: {
|
|
@@ -21,10 +22,10 @@ exports.default = (0, utils_1.createRule)("keys-order", {
|
|
|
21
22
|
type: "suggestion",
|
|
22
23
|
},
|
|
23
24
|
create(context) {
|
|
24
|
-
|
|
25
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
26
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
25
27
|
return {};
|
|
26
28
|
}
|
|
27
|
-
const sourceCode = context.getSourceCode();
|
|
28
29
|
function applyKey(tableKeys, node) {
|
|
29
30
|
var _a;
|
|
30
31
|
const keyNames = (0, toml_eslint_parser_1.getStaticTOMLValue)(node.key);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("no-mixed-type-in-array", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -39,7 +40,8 @@ exports.default = (0, utils_1.createRule)("no-mixed-type-in-array", {
|
|
|
39
40
|
},
|
|
40
41
|
create(context) {
|
|
41
42
|
var _a;
|
|
42
|
-
|
|
43
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
44
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
43
45
|
return {};
|
|
44
46
|
}
|
|
45
47
|
const typeMap = Object.assign({ string: "String", integer: "Integer", float: "Float", boolean: "Boolean", offsetDateTime: "Datetime", localDateTime: "Datetime", localDate: "Datetime", localTime: "Datetime", array: "Array", inlineTable: "Inline Table" }, (((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.typeMap) || {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
function toDecimalText(str, radix) {
|
|
5
6
|
const digits = [0];
|
|
6
7
|
for (const c of str) {
|
|
@@ -51,7 +52,8 @@ exports.default = (0, utils_1.createRule)("no-non-decimal-integer", {
|
|
|
51
52
|
},
|
|
52
53
|
create(context) {
|
|
53
54
|
var _a, _b, _c;
|
|
54
|
-
|
|
55
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
56
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
55
57
|
return {};
|
|
56
58
|
}
|
|
57
59
|
const allowHexadecimal = Boolean((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.allowHexadecimal);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("no-space-dots", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -17,10 +18,10 @@ exports.default = (0, utils_1.createRule)("no-space-dots", {
|
|
|
17
18
|
type: "layout",
|
|
18
19
|
},
|
|
19
20
|
create(context) {
|
|
20
|
-
|
|
21
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
22
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
21
23
|
return {};
|
|
22
24
|
}
|
|
23
|
-
const sourceCode = context.getSourceCode();
|
|
24
25
|
return {
|
|
25
26
|
TOMLKey(node) {
|
|
26
27
|
for (let index = 0; index < node.keys.length - 1; index++) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("no-unreadable-number-separator", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -15,10 +16,10 @@ exports.default = (0, utils_1.createRule)("no-unreadable-number-separator", {
|
|
|
15
16
|
type: "suggestion",
|
|
16
17
|
},
|
|
17
18
|
create(context) {
|
|
18
|
-
|
|
19
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
20
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
19
21
|
return {};
|
|
20
22
|
}
|
|
21
|
-
const sourceCode = context.getSourceCode();
|
|
22
23
|
function parseCharCounts(text, startIndex, exitChars) {
|
|
23
24
|
let start = startIndex;
|
|
24
25
|
let count = 0;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const toml_eslint_parser_1 = require("toml-eslint-parser");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const compat_1 = require("../utils/compat");
|
|
5
6
|
exports.default = (0, utils_1.createRule)("padding-line-between-pairs", {
|
|
6
7
|
meta: {
|
|
7
8
|
docs: {
|
|
@@ -18,10 +19,10 @@ exports.default = (0, utils_1.createRule)("padding-line-between-pairs", {
|
|
|
18
19
|
type: "layout",
|
|
19
20
|
},
|
|
20
21
|
create(context) {
|
|
21
|
-
|
|
22
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
23
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
22
24
|
return {};
|
|
23
25
|
}
|
|
24
|
-
const sourceCode = context.getSourceCode();
|
|
25
26
|
function verifyPairs(prevNode, prevKeys, nextNode, nextKeys) {
|
|
26
27
|
const needPadding = nextKeys.length !== prevKeys.length ||
|
|
27
28
|
nextKeys.slice(0, -1).some((key, index) => key !== prevKeys[index]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("padding-line-between-tables", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -17,10 +18,10 @@ exports.default = (0, utils_1.createRule)("padding-line-between-tables", {
|
|
|
17
18
|
type: "layout",
|
|
18
19
|
},
|
|
19
20
|
create(context) {
|
|
20
|
-
|
|
21
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
22
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
21
23
|
return {};
|
|
22
24
|
}
|
|
23
|
-
const sourceCode = context.getSourceCode();
|
|
24
25
|
function verifyTables(prevNode, nextNode) {
|
|
25
26
|
const tokens = sourceCode.getTokensBetween(prevNode, nextNode, {
|
|
26
27
|
includeComments: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("precision-of-fractional-seconds", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -27,7 +28,8 @@ exports.default = (0, utils_1.createRule)("precision-of-fractional-seconds", {
|
|
|
27
28
|
},
|
|
28
29
|
create(context) {
|
|
29
30
|
var _a, _b;
|
|
30
|
-
|
|
31
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
32
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
31
33
|
return {};
|
|
32
34
|
}
|
|
33
35
|
const max = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : 3;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.maxBitToMaxValues = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const compat_1 = require("../utils/compat");
|
|
5
6
|
const cacheMaxValues = {};
|
|
6
7
|
function maxBitToMaxValues(maxBit) {
|
|
7
8
|
const binaryMax = [];
|
|
@@ -76,7 +77,8 @@ exports.default = (0, utils_1.createRule)("precision-of-integer", {
|
|
|
76
77
|
},
|
|
77
78
|
create(context) {
|
|
78
79
|
var _a, _b;
|
|
79
|
-
|
|
80
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
81
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
80
82
|
return {};
|
|
81
83
|
}
|
|
82
84
|
const maxBit = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.maxBit) !== null && _b !== void 0 ? _b : 64;
|
package/lib/rules/quoted-keys.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("quoted-keys", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -32,7 +33,8 @@ exports.default = (0, utils_1.createRule)("quoted-keys", {
|
|
|
32
33
|
},
|
|
33
34
|
create(context) {
|
|
34
35
|
var _a, _b, _c;
|
|
35
|
-
|
|
36
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
37
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
36
38
|
return {};
|
|
37
39
|
}
|
|
38
40
|
const prefer = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.prefer) !== null && _b !== void 0 ? _b : "as-needed";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("space-eq-sign", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -18,10 +19,10 @@ exports.default = (0, utils_1.createRule)("space-eq-sign", {
|
|
|
18
19
|
type: "layout",
|
|
19
20
|
},
|
|
20
21
|
create(context) {
|
|
21
|
-
|
|
22
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
23
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
22
24
|
return {};
|
|
23
25
|
}
|
|
24
|
-
const sourceCode = context.getSourceCode();
|
|
25
26
|
function report(equalToken) {
|
|
26
27
|
context.report({
|
|
27
28
|
loc: equalToken.loc,
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const compat_1 = require("../utils/compat");
|
|
8
9
|
function escapeText(s) {
|
|
9
10
|
return `(?:${lodash_1.default.escapeRegExp(s)})`;
|
|
10
11
|
}
|
|
@@ -88,10 +89,10 @@ exports.default = (0, utils_1.createRule)("spaced-comment", {
|
|
|
88
89
|
type: "suggestion",
|
|
89
90
|
},
|
|
90
91
|
create(context) {
|
|
91
|
-
|
|
92
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
93
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
92
94
|
return {};
|
|
93
95
|
}
|
|
94
|
-
const sourceCode = context.getSourceCode();
|
|
95
96
|
const requireSpace = context.options[0] !== "never";
|
|
96
97
|
const config = context.options[1] || {};
|
|
97
98
|
const markers = config.markers || [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
+
const compat_1 = require("../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("table-bracket-spacing", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -23,10 +24,10 @@ exports.default = (0, utils_1.createRule)("table-bracket-spacing", {
|
|
|
23
24
|
type: "layout",
|
|
24
25
|
},
|
|
25
26
|
create(context) {
|
|
26
|
-
|
|
27
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
28
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
27
29
|
return {};
|
|
28
30
|
}
|
|
29
|
-
const sourceCode = context.getSourceCode();
|
|
30
31
|
const prefer = context.options[0] || "never";
|
|
31
32
|
function reportRequiredBeginningSpace(node, token) {
|
|
32
33
|
context.report({
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const toml_eslint_parser_1 = require("toml-eslint-parser");
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const compat_1 = require("../utils/compat");
|
|
9
10
|
function getFirst(keys) {
|
|
10
11
|
const first = keys[0];
|
|
11
12
|
if (first) {
|
|
@@ -36,10 +37,10 @@ exports.default = (0, utils_1.createRule)("tables-order", {
|
|
|
36
37
|
type: "suggestion",
|
|
37
38
|
},
|
|
38
39
|
create(context) {
|
|
39
|
-
|
|
40
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
41
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
40
42
|
return {};
|
|
41
43
|
}
|
|
42
|
-
const sourceCode = context.getSourceCode();
|
|
43
44
|
function applyKey(rootKeys, node) {
|
|
44
45
|
const keyNames = [...node.resolvedKey];
|
|
45
46
|
let before = null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../../utils");
|
|
4
|
+
const compat_1 = require("../../utils/compat");
|
|
4
5
|
exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
|
|
5
6
|
meta: {
|
|
6
7
|
docs: {
|
|
@@ -13,10 +14,13 @@ exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
|
|
|
13
14
|
type: "problem",
|
|
14
15
|
},
|
|
15
16
|
create(context, { customBlock }) {
|
|
17
|
+
var _a;
|
|
16
18
|
if (!customBlock) {
|
|
17
19
|
return {};
|
|
18
20
|
}
|
|
19
|
-
const
|
|
21
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
22
|
+
const parserServices = (_a = context.parserServices) !== null && _a !== void 0 ? _a : sourceCode.parserServices;
|
|
23
|
+
const parseError = parserServices.parseError;
|
|
20
24
|
if (parseError) {
|
|
21
25
|
let loc = undefined;
|
|
22
26
|
if ("column" in parseError && "lineNumber" in parseError) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuleContext, SourceCode } from "../types";
|
|
2
|
+
import type { Rule, SourceCode as ESLintSourceCode } from "eslint";
|
|
3
|
+
export declare function getSourceCode(context: RuleContext): SourceCode;
|
|
4
|
+
export declare function getSourceCode(context: Rule.RuleContext): ESLintSourceCode;
|
|
5
|
+
export declare function getFilename(context: RuleContext | Rule.RuleContext): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilename = exports.getSourceCode = void 0;
|
|
4
|
+
const eslint_compat_utils_1 = require("eslint-compat-utils");
|
|
5
|
+
function getSourceCode(context) {
|
|
6
|
+
return (0, eslint_compat_utils_1.getSourceCode)(context);
|
|
7
|
+
}
|
|
8
|
+
exports.getSourceCode = getSourceCode;
|
|
9
|
+
function getFilename(context) {
|
|
10
|
+
return (0, eslint_compat_utils_1.getFilename)(context);
|
|
11
|
+
}
|
|
12
|
+
exports.getFilename = getFilename;
|
package/lib/utils/index.js
CHANGED
|
@@ -30,15 +30,17 @@ exports.getCoreRule = exports.convertESNode = exports.getProxyNode = exports.def
|
|
|
30
30
|
const tomlESLintParser = __importStar(require("toml-eslint-parser"));
|
|
31
31
|
const debug_1 = __importDefault(require("debug"));
|
|
32
32
|
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const compat_1 = require("./compat");
|
|
33
34
|
const log = (0, debug_1.default)("eslint-plugin-toml:utils/index");
|
|
34
35
|
function createRule(ruleName, rule) {
|
|
35
36
|
return {
|
|
36
37
|
meta: Object.assign(Object.assign({}, rule.meta), { docs: Object.assign(Object.assign({}, rule.meta.docs), { url: `https://ota-meshi.github.io/eslint-plugin-toml/rules/${ruleName}.html`, ruleId: `toml/${ruleName}`, ruleName }) }),
|
|
37
38
|
create(context) {
|
|
38
|
-
|
|
39
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
40
|
+
if (typeof sourceCode.parserServices.defineCustomBlocksVisitor ===
|
|
39
41
|
"function" &&
|
|
40
|
-
path_1.default.extname(
|
|
41
|
-
return
|
|
42
|
+
path_1.default.extname((0, compat_1.getFilename)(context)) === ".vue") {
|
|
43
|
+
return sourceCode.parserServices.defineCustomBlocksVisitor(context, tomlESLintParser, {
|
|
42
44
|
target: ["toml", "toml"],
|
|
43
45
|
create(blockContext) {
|
|
44
46
|
return rule.create(blockContext, {
|
|
@@ -56,10 +58,10 @@ function createRule(ruleName, rule) {
|
|
|
56
58
|
exports.createRule = createRule;
|
|
57
59
|
function defineWrapperListener(coreRule, context, proxyOptions) {
|
|
58
60
|
var _a, _b;
|
|
59
|
-
|
|
61
|
+
const sourceCode = (0, compat_1.getSourceCode)(context);
|
|
62
|
+
if (!sourceCode.parserServices.isTOML) {
|
|
60
63
|
return {};
|
|
61
64
|
}
|
|
62
|
-
const sourceCode = context.getSourceCode();
|
|
63
65
|
const proxySourceCode = Object.assign({ __proto__: sourceCode }, ["getNodeByRangeIndex"].reduce((obj, key) => {
|
|
64
66
|
obj[key] = (...args) => {
|
|
65
67
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-toml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for TOML.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"update": "node --require ts-node/register ./tools/update.ts && npm run eslint-fix",
|
|
26
26
|
"new": "ts-node ./tools/new-rule.ts",
|
|
27
27
|
"predocs:watch": "npm run build:ts",
|
|
28
|
-
"docs:watch": "
|
|
29
|
-
"docs:build": "npm run build:ts &&
|
|
28
|
+
"docs:watch": "vitepress dev docs",
|
|
29
|
+
"docs:build": "npm run build:ts && vitepress build docs",
|
|
30
30
|
"preversion": "npm test && git add .",
|
|
31
31
|
"version": "env-cmd -e version npm run update && git add .",
|
|
32
32
|
"version:ci": "env-cmd -e version-ci npm run update && changeset version",
|
|
@@ -57,13 +57,15 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"debug": "^4.1.1",
|
|
60
|
+
"eslint-compat-utils": "^0.1.2",
|
|
60
61
|
"lodash": "^4.17.19",
|
|
61
62
|
"toml-eslint-parser": "^0.6.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@changesets/changelog-github": "^0.4.6",
|
|
65
66
|
"@changesets/cli": "^2.24.2",
|
|
66
|
-
"@ota-meshi/eslint-plugin": "^0.
|
|
67
|
+
"@ota-meshi/eslint-plugin": "^0.15.0",
|
|
68
|
+
"@ota-meshi/site-kit-eslint-editor-vue": "^0.1.2",
|
|
67
69
|
"@types/debug": "^4.1.5",
|
|
68
70
|
"@types/eslint": "^8.0.0",
|
|
69
71
|
"@types/eslint-scope": "^3.7.0",
|
|
@@ -73,38 +75,40 @@
|
|
|
73
75
|
"@types/mocha": "^10.0.0",
|
|
74
76
|
"@types/node": "^18.0.0",
|
|
75
77
|
"@types/semver": "^7.3.1",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
77
|
-
"@typescript-eslint/parser": "^
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
79
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
78
80
|
"cross-env": "^7.0.2",
|
|
79
81
|
"env-cmd": "^10.1.0",
|
|
82
|
+
"esbuild": "^0.19.3",
|
|
80
83
|
"eslint": "^8.0.0",
|
|
81
|
-
"eslint-config-prettier": "^
|
|
84
|
+
"eslint-config-prettier": "^9.0.0",
|
|
82
85
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
83
86
|
"eslint-plugin-eslint-plugin": "^5.0.0",
|
|
84
|
-
"eslint-plugin-json-schema-validator": "^4.
|
|
87
|
+
"eslint-plugin-json-schema-validator": "^4.6.1",
|
|
85
88
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
86
89
|
"eslint-plugin-markdown": "^3.0.0",
|
|
87
|
-
"eslint-plugin-
|
|
88
|
-
"eslint-plugin-prettier": "^
|
|
90
|
+
"eslint-plugin-n": "^16.0.0",
|
|
91
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
89
92
|
"eslint-plugin-regexp": "^1.0.0",
|
|
90
93
|
"eslint-plugin-vue": "^9.0.0",
|
|
91
94
|
"eslint-plugin-yml": "^1.0.0",
|
|
92
|
-
"eslint4b": "^7.3.1",
|
|
93
95
|
"espree": "^9.0.0",
|
|
96
|
+
"events": "^3.3.0",
|
|
94
97
|
"mocha": "^10.0.0",
|
|
95
98
|
"nyc": "^15.1.0",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
99
|
+
"pako": "^2.1.0",
|
|
100
|
+
"prettier": "^3.0.0",
|
|
98
101
|
"semver": "^7.3.2",
|
|
99
102
|
"stylelint": "^15",
|
|
100
103
|
"stylelint-config-recommended-vue": "^1.0.0",
|
|
101
|
-
"stylelint-config-standard": "^
|
|
104
|
+
"stylelint-config-standard": "^34.0.0",
|
|
105
|
+
"stylelint-config-standard-vue": "^1.0.0",
|
|
102
106
|
"stylelint-stylus": "^0.18.0",
|
|
103
107
|
"ts-node": "^10.0.0",
|
|
104
108
|
"typescript": "~5.0.0",
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
109
|
+
"vite-plugin-eslint4b": "^0.2.1",
|
|
110
|
+
"vitepress": "^1.0.0-rc.17",
|
|
111
|
+
"vue-eslint-parser": "^9.0.0"
|
|
108
112
|
},
|
|
109
113
|
"publishConfig": {
|
|
110
114
|
"access": "public"
|