eslint-plugin-toml 0.11.0 → 0.12.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.
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  const parser = __importStar(require("toml-eslint-parser"));
27
37
  exports.default = [
package/lib/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
package/lib/meta.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const name: "eslint-plugin-toml";
2
- export declare const version: "0.11.0";
1
+ export declare const name = "eslint-plugin-toml";
2
+ export declare const version = "0.12.0";
package/lib/meta.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = "eslint-plugin-toml";
5
- exports.version = "0.11.0";
5
+ exports.version = "0.12.0";
@@ -44,7 +44,7 @@ exports.default = (0, utils_1.createRule)("array-bracket-newline", {
44
44
  },
45
45
  create(context) {
46
46
  const sourceCode = (0, compat_1.getSourceCode)(context);
47
- if (!sourceCode.parserServices.isTOML) {
47
+ if (!sourceCode.parserServices?.isTOML) {
48
48
  return {};
49
49
  }
50
50
  function normalizeOptionValue(option) {
@@ -42,7 +42,7 @@ exports.default = (0, utils_1.createRule)("array-bracket-spacing", {
42
42
  },
43
43
  create(context) {
44
44
  const sourceCode = (0, compat_1.getSourceCode)(context);
45
- if (!sourceCode.parserServices.isTOML) {
45
+ if (!sourceCode.parserServices?.isTOML) {
46
46
  return {};
47
47
  }
48
48
  const spaced = (context.options[0] || "always") === "always";
@@ -70,7 +70,7 @@ exports.default = (0, utils_1.createRule)("array-element-newline", {
70
70
  },
71
71
  create(context) {
72
72
  const sourceCode = (0, compat_1.getSourceCode)(context);
73
- if (!sourceCode.parserServices.isTOML) {
73
+ if (!sourceCode.parserServices?.isTOML) {
74
74
  return {};
75
75
  }
76
76
  function normalizeOptionValue(providedOption) {
@@ -38,16 +38,15 @@ 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
- if (!sourceCode.parserServices.isTOML) {
42
+ if (!sourceCode.parserServices?.isTOML) {
44
43
  return {};
45
44
  }
46
45
  const style = context.options[0] || "last";
47
46
  const exceptions = {};
48
47
  if (context.options.length === 2 &&
49
48
  Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
50
- (_a = (_b = context.options)[1]) !== null && _a !== void 0 ? _a : (_b[1] = { exceptions: {} });
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++)
@@ -8,7 +8,7 @@ const ITERATION_OPTS = Object.freeze({
8
8
  includeComments: true,
9
9
  });
10
10
  function buildIndentUtility(optionValue) {
11
- const indent = optionValue !== null && optionValue !== void 0 ? optionValue : 2;
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
- if (!sourceCode.parserServices.isTOML) {
56
+ if (!sourceCode.parserServices?.isTOML) {
58
57
  return {};
59
58
  }
60
59
  const { getIndentText, outdent } = buildIndentUtility(context.options[0]);
61
- const subTablesOffset = (_b = (_a = context.options[1]) === null || _a === void 0 ? void 0 : _a.subTables) !== null && _b !== void 0 ? _b : 0;
62
- const keyValuePairsOffset = (_d = (_c = context.options[1]) === null || _c === void 0 ? void 0 : _c.keyValuePairs) !== null && _d !== void 0 ? _d : 0;
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 = (_b = (_a = expectedIndents[index + 1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : -1;
367
+ const prev = expectedIndents[index + 1]?.length ?? -1;
370
368
  return (prev < commentLineIndent.actualIndent.length &&
371
369
  commentLineIndent.actualIndent.length < indent.length);
372
370
  });
@@ -39,7 +39,7 @@ exports.default = (0, utils_1.createRule)("inline-table-curly-spacing", {
39
39
  },
40
40
  create(context) {
41
41
  const sourceCode = (0, compat_1.getSourceCode)(context);
42
- if (!sourceCode.parserServices.isTOML) {
42
+ if (!sourceCode.parserServices?.isTOML) {
43
43
  return {};
44
44
  }
45
45
  const spaced = (context.options[0] || "always") === "always";
@@ -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
- ((_a = sourceCode.getNodeByRangeIndex(penultimate.range[0])) === null || _a === void 0 ? void 0 : _a.type) ===
66
+ sourceCode.getNodeByRangeIndex(penultimate.range[0])?.type ===
68
67
  targetPenultimateType
69
68
  ? !options.spaced
70
69
  : options.spaced;
@@ -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 = Object.assign(Object.assign({}, initOptionProperty(fromOptions.align)), { on: fromOptions.align.on || "equal", mode: fromOptions.align.mode || "strict" });
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: Object.assign({ on: ON_SCHEMA }, OBJECT_WITHOUT_ON_SCHEMA.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: Object.assign({ align: {
124
+ properties: {
125
+ align: {
118
126
  anyOf: [ON_SCHEMA, ALIGN_OBJECT_SCHEMA],
119
- } }, OBJECT_WITHOUT_ON_SCHEMA.properties),
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: Object.assign({ align: {
138
+ properties: {
139
+ align: {
129
140
  anyOf: [ON_SCHEMA, ALIGN_OBJECT_SCHEMA],
130
- } }, OBJECT_WITHOUT_ON_SCHEMA.properties),
141
+ },
142
+ ...OBJECT_WITHOUT_ON_SCHEMA.properties,
143
+ },
131
144
  additionalProperties: false,
132
145
  },
133
146
  },
@@ -157,7 +170,7 @@ exports.default = (0, utils_1.createRule)("key-spacing", {
157
170
  });
158
171
  function create(context) {
159
172
  const sourceCode = (0, compat_1.getSourceCode)(context);
160
- if (!sourceCode.parserServices.isTOML) {
173
+ if (!sourceCode.parserServices?.isTOML) {
161
174
  return {};
162
175
  }
163
176
  const options = context.options[0] || {};
@@ -23,11 +23,10 @@ exports.default = (0, utils_1.createRule)("keys-order", {
23
23
  },
24
24
  create(context) {
25
25
  const sourceCode = (0, compat_1.getSourceCode)(context);
26
- if (!sourceCode.parserServices.isTOML) {
26
+ if (!sourceCode.parserServices?.isTOML) {
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 = ((_a = lodash_1.default.last(keys)) === null || _a === void 0 ? void 0 : _a.node) || null;
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
- if (!sourceCode.parserServices.isTOML) {
43
+ if (!sourceCode.parserServices?.isTOML) {
45
44
  return {};
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) || {}));
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
- if (!sourceCode.parserServices.isTOML) {
55
+ if (!sourceCode.parserServices?.isTOML) {
57
56
  return {};
58
57
  }
59
- const allowHexadecimal = Boolean((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.allowHexadecimal);
60
- const allowOctal = Boolean((_b = context.options[0]) === null || _b === void 0 ? void 0 : _b.allowOctal);
61
- const allowBinary = Boolean((_c = context.options[0]) === null || _c === void 0 ? void 0 : _c.allowBinary);
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;
@@ -19,7 +19,7 @@ exports.default = (0, utils_1.createRule)("no-space-dots", {
19
19
  },
20
20
  create(context) {
21
21
  const sourceCode = (0, compat_1.getSourceCode)(context);
22
- if (!sourceCode.parserServices.isTOML) {
22
+ if (!sourceCode.parserServices?.isTOML) {
23
23
  return {};
24
24
  }
25
25
  return {
@@ -17,7 +17,7 @@ exports.default = (0, utils_1.createRule)("no-unreadable-number-separator", {
17
17
  },
18
18
  create(context) {
19
19
  const sourceCode = (0, compat_1.getSourceCode)(context);
20
- if (!sourceCode.parserServices.isTOML) {
20
+ if (!sourceCode.parserServices?.isTOML) {
21
21
  return {};
22
22
  }
23
23
  function parseCharCounts(text, startIndex, exitChars) {
@@ -20,7 +20,7 @@ exports.default = (0, utils_1.createRule)("padding-line-between-pairs", {
20
20
  },
21
21
  create(context) {
22
22
  const sourceCode = (0, compat_1.getSourceCode)(context);
23
- if (!sourceCode.parserServices.isTOML) {
23
+ if (!sourceCode.parserServices?.isTOML) {
24
24
  return {};
25
25
  }
26
26
  function verifyPairs(prevNode, prevKeys, nextNode, nextKeys) {
@@ -19,7 +19,7 @@ exports.default = (0, utils_1.createRule)("padding-line-between-tables", {
19
19
  },
20
20
  create(context) {
21
21
  const sourceCode = (0, compat_1.getSourceCode)(context);
22
- if (!sourceCode.parserServices.isTOML) {
22
+ if (!sourceCode.parserServices?.isTOML) {
23
23
  return {};
24
24
  }
25
25
  function verifyTables(prevNode, nextNode) {
@@ -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
- if (!sourceCode.parserServices.isTOML) {
31
+ if (!sourceCode.parserServices?.isTOML) {
33
32
  return {};
34
33
  }
35
- const max = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : 3;
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 = ((_a = /^\d{4}-\d{2}-\d{2}[ t]\d{2}:\d{2}:\d{2}.(\d+)/iu.exec(text)) === null || _a === void 0 ? void 0 : _a[1]) ||
40
- ((_b = /^\d{2}:\d{2}:\d{2}.(\d+)/u.exec(text)) === null || _b === void 0 ? void 0 : _b[1]);
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
- if (!sourceCode.parserServices.isTOML) {
39
+ if (!sourceCode.parserServices?.isTOML) {
41
40
  return {};
42
41
  }
43
- const maxBit = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.maxBit) !== null && _b !== void 0 ? _b : 64;
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();
@@ -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
- if (!sourceCode.parserServices.isTOML) {
36
+ if (!sourceCode.parserServices?.isTOML) {
38
37
  return {};
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";
41
- const numbers = ((_c = context.options[0]) === null || _c === void 0 ? void 0 : _c.numbers) !== false;
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") {
@@ -20,7 +20,7 @@ exports.default = (0, utils_1.createRule)("space-eq-sign", {
20
20
  },
21
21
  create(context) {
22
22
  const sourceCode = (0, compat_1.getSourceCode)(context);
23
- if (!sourceCode.parserServices.isTOML) {
23
+ if (!sourceCode.parserServices?.isTOML) {
24
24
  return {};
25
25
  }
26
26
  function report(equalToken) {
@@ -90,7 +90,7 @@ exports.default = (0, utils_1.createRule)("spaced-comment", {
90
90
  },
91
91
  create(context) {
92
92
  const sourceCode = (0, compat_1.getSourceCode)(context);
93
- if (!sourceCode.parserServices.isTOML) {
93
+ if (!sourceCode.parserServices?.isTOML) {
94
94
  return {};
95
95
  }
96
96
  const requireSpace = context.options[0] !== "never";
@@ -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], `#${(match === null || match === void 0 ? void 0 : match[1]) ? match[1] : ""}`);
121
+ return fixer.replaceTextRange([start, end], `#${match?.[1] ? match[1] : ""}`);
122
122
  },
123
123
  messageId,
124
124
  data: { refChar },
@@ -25,7 +25,7 @@ exports.default = (0, utils_1.createRule)("table-bracket-spacing", {
25
25
  },
26
26
  create(context) {
27
27
  const sourceCode = (0, compat_1.getSourceCode)(context);
28
- if (!sourceCode.parserServices.isTOML) {
28
+ if (!sourceCode.parserServices?.isTOML) {
29
29
  return {};
30
30
  }
31
31
  const prefer = context.options[0] || "never";
@@ -38,7 +38,7 @@ exports.default = (0, utils_1.createRule)("tables-order", {
38
38
  },
39
39
  create(context) {
40
40
  const sourceCode = (0, compat_1.getSourceCode)(context);
41
- if (!sourceCode.parserServices.isTOML) {
41
+ if (!sourceCode.parserServices?.isTOML) {
42
42
  return {};
43
43
  }
44
44
  function applyKey(rootKeys, node) {
@@ -14,13 +14,12 @@ 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 = (_a = context.parserServices) !== null && _a !== void 0 ? _a : sourceCode.parserServices;
23
- const parseError = parserServices.parseError;
21
+ const parserServices = context.parserServices ?? sourceCode.parserServices;
22
+ const parseError = parserServices?.parseError;
24
23
  if (parseError) {
25
24
  let loc = undefined;
26
25
  if ("column" in parseError && "lineNumber" in parseError) {
package/lib/types.d.ts CHANGED
@@ -75,7 +75,7 @@ export interface RuleContext {
75
75
  id: string;
76
76
  options: any[];
77
77
  parserPath: string;
78
- parserServices: {
78
+ parserServices?: {
79
79
  isTOML?: true;
80
80
  parseError?: any;
81
81
  };
@@ -94,8 +94,9 @@ export interface SourceCode {
94
94
  ast: AST.TOMLProgram;
95
95
  lines: string[];
96
96
  hasBOM: boolean;
97
- parserServices: {
97
+ parserServices?: {
98
98
  isTOML?: true;
99
+ parseError?: any;
99
100
  };
100
101
  visitorKeys: {
101
102
  [nodeType: string]: string[];
@@ -1,37 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTokenOnSameLine = exports.isClosingBraceToken = exports.isClosingBracketToken = exports.isNotClosingParenToken = exports.isClosingParenToken = exports.isEqualSign = exports.isCommaToken = exports.isCommentToken = exports.LINEBREAK_MATCHER = void 0;
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
- var _a, _b;
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 = void 0;
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;
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExactConverter = exports.getConverter = exports.getChecker = exports.isPascalCase = exports.pascalCase = exports.isCamelCase = exports.camelCase = exports.isScreamingSnakeCase = exports.screamingSnakeCase = exports.isSnakeCase = exports.snakeCase = exports.isKebabCase = exports.kebabCase = exports.allowedCaseOptions = void 0;
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;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFilename = exports.getSourceCode = void 0;
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;
@@ -15,30 +15,48 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.createRule = void 0;
39
+ exports.createRule = createRule;
30
40
  const tomlESLintParser = __importStar(require("toml-eslint-parser"));
31
41
  const path_1 = __importDefault(require("path"));
32
42
  const compat_1 = require("./compat");
33
43
  function createRule(ruleName, rule) {
34
44
  return {
35
- 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 }) }),
45
+ meta: {
46
+ ...rule.meta,
47
+ docs: {
48
+ ...rule.meta.docs,
49
+ url: `https://ota-meshi.github.io/eslint-plugin-toml/rules/${ruleName}.html`,
50
+ ruleId: `toml/${ruleName}`,
51
+ ruleName,
52
+ },
53
+ },
36
54
  create(context) {
37
55
  const sourceCode = (0, compat_1.getSourceCode)(context);
38
- if (typeof sourceCode.parserServices.defineCustomBlocksVisitor ===
56
+ if (typeof sourceCode.parserServices?.defineCustomBlocksVisitor ===
39
57
  "function" &&
40
58
  path_1.default.extname((0, compat_1.getFilename)(context)) === ".vue") {
41
- return sourceCode.parserServices.defineCustomBlocksVisitor(context, tomlESLintParser, {
59
+ return sourceCode.parserServices?.defineCustomBlocksVisitor(context, tomlESLintParser, {
42
60
  target: ["toml", "toml"],
43
61
  create(blockContext) {
44
62
  return rule.create(blockContext, {
@@ -53,4 +71,3 @@ function createRule(ruleName, rule) {
53
71
  },
54
72
  };
55
73
  }
56
- exports.createRule = createRule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-toml",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "This ESLint plugin provides linting rules for TOML.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -15,13 +15,13 @@
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 . --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml --ignore-pattern playground",
19
- "eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml --ignore-pattern playground --fix",
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",
23
23
  "cover": "nyc --reporter=lcov npm run test:base",
24
- "test:debug": "mocha --require ts-node/register --inspect \"tests/src/**/*.ts\" --reporter dot",
24
+ "test:debug": "mocha --require ts-node/register/transpile-only --inspect \"tests/src/**/*.ts\" --reporter dot",
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",
@@ -57,59 +57,62 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "debug": "^4.1.1",
60
- "eslint-compat-utils": "^0.5.0",
60
+ "eslint-compat-utils": "^0.6.0",
61
61
  "lodash": "^4.17.19",
62
- "toml-eslint-parser": "^0.9.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.24.2",
67
- "@ota-meshi/eslint-plugin": "^0.15.0",
68
- "@ota-meshi/site-kit-eslint-editor-vue": "^0.1.2",
69
- "@types/debug": "^4.1.5",
70
- "@types/eslint": "^8.0.0",
71
- "@types/eslint-scope": "^3.7.0",
72
- "@types/eslint-visitor-keys": "^3.0.0",
73
- "@types/estree": "^1.0.0",
74
- "@types/lodash": "^4.14.158",
75
- "@types/mocha": "^10.0.0",
76
- "@types/node": "^20.0.0",
77
- "@types/semver": "^7.3.1",
78
- "@typescript-eslint/eslint-plugin": "^6.19.0",
79
- "@typescript-eslint/parser": "^6.19.0",
80
- "cross-env": "^7.0.2",
66
+ "@changesets/cli": "^2.27.5",
67
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
68
+ "@eslint/json": "^0.8.0",
69
+ "@ota-meshi/eslint-plugin": "^0.17.6",
70
+ "@ota-meshi/site-kit-eslint-editor-vue": "^0.2.1",
71
+ "@types/debug": "^4.1.12",
72
+ "@types/eslint": "^9.0.0",
73
+ "@types/eslint-scope": "^3.7.7",
74
+ "@types/eslint-visitor-keys": "^3.3.0",
75
+ "@types/estree": "^1.0.5",
76
+ "@types/lodash": "^4.17.5",
77
+ "@types/mocha": "^10.0.7",
78
+ "@types/node": "^22.0.0",
79
+ "@types/semver": "^7.5.8",
80
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
81
+ "@typescript-eslint/parser": "^8.16.0",
82
+ "cross-env": "^7.0.3",
81
83
  "env-cmd": "^10.1.0",
82
- "esbuild": "^0.20.0",
83
- "eslint": "^8.0.0",
84
- "eslint-config-prettier": "^9.0.0",
85
- "eslint-plugin-eslint-comments": "^3.2.0",
86
- "eslint-plugin-eslint-plugin": "^5.0.0",
87
- "eslint-plugin-json-schema-validator": "^5.0.0",
88
- "eslint-plugin-jsonc": "^2.0.0",
89
- "eslint-plugin-markdown": "^3.0.0",
90
- "eslint-plugin-n": "^16.0.0",
91
- "eslint-plugin-prettier": "^5.0.0",
92
- "eslint-plugin-regexp": "^2.0.0",
93
- "eslint-plugin-toml": "^0.10.0",
94
- "eslint-plugin-vue": "^9.0.0",
95
- "eslint-plugin-yml": "^1.0.0",
96
- "espree": "^10.0.0",
84
+ "esbuild": "^0.24.0",
85
+ "eslint": "^9.5.0",
86
+ "eslint-config-prettier": "^9.1.0",
87
+ "eslint-plugin-eslint-plugin": "^6.1.0",
88
+ "eslint-plugin-jsdoc": "^50.0.0",
89
+ "eslint-plugin-json-schema-validator": "^5.1.1",
90
+ "eslint-plugin-jsonc": "^2.16.0",
91
+ "eslint-plugin-markdown": "^5.0.0",
92
+ "eslint-plugin-n": "^17.9.0",
93
+ "eslint-plugin-node-dependencies": "^0.12.0",
94
+ "eslint-plugin-prettier": "^5.1.3",
95
+ "eslint-plugin-regexp": "^2.6.0",
96
+ "eslint-plugin-toml": "^0.11.0",
97
+ "eslint-plugin-vue": "^9.26.0",
98
+ "eslint-plugin-yml": "^1.14.0",
97
99
  "events": "^3.3.0",
98
- "mocha": "^10.0.0",
99
- "nyc": "^15.1.0",
100
+ "mocha": "^10.4.0",
101
+ "nyc": "^17.0.0",
100
102
  "pako": "^2.1.0",
101
- "prettier": "^3.0.0",
102
- "semver": "^7.3.2",
103
- "stylelint": "^16.0.0",
104
- "stylelint-config-recommended-vue": "^1.0.0",
105
- "stylelint-config-standard": "^36.0.0",
103
+ "prettier": "^3.3.2",
104
+ "semver": "^7.6.2",
105
+ "stylelint": "^16.6.1",
106
+ "stylelint-config-recommended-vue": "^1.5.0",
107
+ "stylelint-config-standard": "^36.0.1",
106
108
  "stylelint-config-standard-vue": "^1.0.0",
107
109
  "stylelint-stylus": "^1.0.0",
108
- "ts-node": "^10.0.0",
109
- "typescript": "~5.0.0",
110
- "vite-plugin-eslint4b": "^0.2.1",
111
- "vitepress": "^1.0.0-rc.17",
112
- "vue-eslint-parser": "^9.0.0"
110
+ "ts-node": "^10.9.2",
111
+ "typescript": "~5.7.0",
112
+ "typescript-eslint": "^8.16.0",
113
+ "vite-plugin-eslint4b": "^0.5.0",
114
+ "vitepress": "^1.2.3",
115
+ "vue-eslint-parser": "^9.4.3"
113
116
  },
114
117
  "publishConfig": {
115
118
  "access": "public"