eslint-plugin-toml 1.0.2 → 1.0.4

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.
@@ -1,6 +1,6 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __exportAll = (all, symbols) => {
3
+ var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
5
  for (var name in all) {
6
6
  __defProp(target, name, {
@@ -8,7 +8,7 @@ var __exportAll = (all, symbols) => {
8
8
  enumerable: true
9
9
  });
10
10
  }
11
- if (symbols) {
11
+ if (!no_symbols) {
12
12
  __defProp(target, Symbol.toStringTag, { value: "Module" });
13
13
  }
14
14
  return target;
package/lib/index.d.mts CHANGED
@@ -12,7 +12,6 @@ declare const name: string;
12
12
  declare const version: string;
13
13
  //#endregion
14
14
  //#region src/language/token-store.d.ts
15
-
16
15
  type FilterPredicate = (tokenOrComment: TOMLToken) => boolean;
17
16
  type CursorWithSkipOptions = number | FilterPredicate | {
18
17
  includeComments?: boolean;
@@ -116,6 +115,11 @@ declare class TOMLSourceCode extends TextSourceCodeBase<{
116
115
  * @deprecated TOML does not have scopes
117
116
  */
118
117
  getScope(node?: AST.TOMLNode): Scope.Scope | null;
118
+ /**
119
+ * Compatibility for ESLint's SourceCode API
120
+ * @deprecated TOML does not have scopes
121
+ */
122
+ get scopeManager(): Scope.ScopeManager | null;
119
123
  /**
120
124
  * Compatibility for ESLint's SourceCode API
121
125
  * @deprecated
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./chunk-15K8U1wQ.mjs";
1
+ import { t as __exportAll } from "./chunk-DQk6qfdC.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";
@@ -257,7 +257,7 @@ var array_bracket_newline_default = createRule("array-bracket-newline", {
257
257
  const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true });
258
258
  const lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true });
259
259
  const first = sourceCode.getTokenAfter(openBracket);
260
- const last$1 = sourceCode.getTokenBefore(closeBracket);
260
+ const last = sourceCode.getTokenBefore(closeBracket);
261
261
  /**
262
262
  * Use tokens or comments to check multiline or not.
263
263
  * But use only tokens to check whether linebreaks are needed.
@@ -268,10 +268,10 @@ var array_bracket_newline_default = createRule("array-bracket-newline", {
268
268
  */
269
269
  if (elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && openBracket.loc.end.line !== first.loc.start.line) {
270
270
  if (isTokenOnSameLine(openBracket, first)) reportRequiredBeginningLinebreak(node, openBracket);
271
- if (isTokenOnSameLine(last$1, closeBracket)) reportRequiredEndingLinebreak(node, closeBracket);
271
+ if (isTokenOnSameLine(last, closeBracket)) reportRequiredEndingLinebreak(node, closeBracket);
272
272
  } else {
273
273
  if (!isTokenOnSameLine(openBracket, first)) reportNoBeginningLinebreak(node, openBracket);
274
- if (!isTokenOnSameLine(last$1, closeBracket)) reportNoEndingLinebreak(node, closeBracket);
274
+ if (!isTokenOnSameLine(last, closeBracket)) reportNoEndingLinebreak(node, closeBracket);
275
275
  }
276
276
  }
277
277
  return { TOMLArray: check };
@@ -433,18 +433,18 @@ var array_bracket_spacing_default = createRule("array-bracket-spacing", {
433
433
  function validateArraySpacing(node) {
434
434
  if (options.spaced && node.elements.length === 0) return;
435
435
  const first = sourceCode.getFirstToken(node);
436
- const last$1 = sourceCode.getLastToken(node);
436
+ const last = sourceCode.getLastToken(node);
437
437
  const second = sourceCode.getTokenAfter(first, { includeComments: true });
438
- const penultimate = sourceCode.getTokenBefore(last$1, { includeComments: true });
438
+ const penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
439
439
  if (isTokenOnSameLine(first, second)) {
440
440
  if (options.isOpeningBracketMustBeSpaced(node)) {
441
441
  if (!sourceCode.isSpaceBetween(first, second)) reportRequiredBeginningSpace(node, first);
442
442
  } else if (sourceCode.isSpaceBetween(first, second)) reportNoBeginningSpace(node, first);
443
443
  }
444
- if (first !== penultimate && isTokenOnSameLine(penultimate, last$1)) {
444
+ if (first !== penultimate && isTokenOnSameLine(penultimate, last)) {
445
445
  if (options.isClosingBracketMustBeSpaced(node)) {
446
- if (!sourceCode.isSpaceBetween(penultimate, last$1)) reportRequiredEndingSpace(node, last$1);
447
- } else if (sourceCode.isSpaceBetween(penultimate, last$1)) reportNoEndingSpace(node, last$1);
446
+ if (!sourceCode.isSpaceBetween(penultimate, last)) reportRequiredEndingSpace(node, last);
447
+ } else if (sourceCode.isSpaceBetween(penultimate, last)) reportNoEndingSpace(node, last);
448
448
  }
449
449
  }
450
450
  return { TOMLArray: validateArraySpacing };
@@ -809,8 +809,8 @@ function buildIndentUtility(optionValue) {
809
809
  const textIndent = typeof indent === "number" ? " ".repeat(indent) : " ";
810
810
  return {
811
811
  getIndentText: (offset) => offset === 1 ? textIndent : textIndent.repeat(offset),
812
- outdent(indent$1) {
813
- return indent$1.slice(0, -textIndent.length);
812
+ outdent(indent) {
813
+ return indent.slice(0, -textIndent.length);
814
814
  }
815
815
  };
816
816
  }
@@ -913,16 +913,16 @@ var indent_default = createRule("indent", {
913
913
  let tableKeyStack = [];
914
914
  /** Get offset from given table keys */
915
915
  function getTableOffset(keys) {
916
- let last$1 = tableKeyStack.pop();
917
- while (last$1) {
918
- if (last$1.keys.length && last$1.keys.length <= keys.length && last$1.keys.every((k, i) => k === keys[i])) {
919
- if (last$1.keys.length < keys.length) {
920
- tableKeyStack.push(last$1);
921
- return last$1.offset + subTablesOffset;
916
+ let last = tableKeyStack.pop();
917
+ while (last) {
918
+ if (last.keys.length && last.keys.length <= keys.length && last.keys.every((k, i) => k === keys[i])) {
919
+ if (last.keys.length < keys.length) {
920
+ tableKeyStack.push(last);
921
+ return last.offset + subTablesOffset;
922
922
  }
923
- return last$1.offset;
923
+ return last.offset;
924
924
  }
925
- last$1 = tableKeyStack.pop();
925
+ last = tableKeyStack.pop();
926
926
  }
927
927
  return 0;
928
928
  }
@@ -1038,10 +1038,10 @@ var indent_default = createRule("indent", {
1038
1038
  if (!lineIndent) continue;
1039
1039
  const line = lineIndent.line;
1040
1040
  if (isCommentToken(lineIndent.firstToken)) {
1041
- const last$1 = commentLines[commentLines.length - 1];
1042
- if (last$1 && last$1.range[1] === line - 1) {
1043
- last$1.range[1] = line;
1044
- last$1.commentLineIndents.push(lineIndent);
1041
+ const last = commentLines[commentLines.length - 1];
1042
+ if (last && last.range[1] === line - 1) {
1043
+ last.range[1] = line;
1044
+ last.commentLineIndents.push(lineIndent);
1045
1045
  } else commentLines.push({
1046
1046
  range: [line, line],
1047
1047
  commentLineIndents: [lineIndent]
@@ -1061,8 +1061,8 @@ var indent_default = createRule("indent", {
1061
1061
  /**
1062
1062
  * Process comments.
1063
1063
  */
1064
- function processComments(commentLines$1) {
1065
- for (const { range, commentLineIndents } of commentLines$1) {
1064
+ function processComments(commentLines) {
1065
+ for (const { range, commentLineIndents } of commentLines) {
1066
1066
  const prev = results.slice(0, range[0]).filter((data) => data).pop();
1067
1067
  const next = results.slice(range[1] + 1).filter((data) => data).shift();
1068
1068
  const expectedIndents = [];
@@ -1307,18 +1307,18 @@ var inline_table_curly_spacing_default = createRule("inline-table-curly-spacing"
1307
1307
  * @param penultimate The penultimate token to check (should be last before closing brace)
1308
1308
  * @param last The last token to check (should be closing brace)
1309
1309
  */
1310
- function validateBraceSpacing(node, first, second, penultimate, last$1) {
1310
+ function validateBraceSpacing(node, first, second, penultimate, last) {
1311
1311
  if (isTokenOnSameLine(first, second)) {
1312
1312
  const firstSpaced = sourceCode.isSpaceBetween(first, second);
1313
1313
  if (options.isOpeningCurlyBraceMustBeSpaced(second)) {
1314
1314
  if (!firstSpaced) reportRequiredBeginningSpace(node, first);
1315
1315
  } else if (firstSpaced && second.type !== "Block") reportNoBeginningSpace(node, first);
1316
1316
  }
1317
- if (isTokenOnSameLine(penultimate, last$1)) {
1318
- const lastSpaced = sourceCode.isSpaceBetween(penultimate, last$1);
1317
+ if (isTokenOnSameLine(penultimate, last)) {
1318
+ const lastSpaced = sourceCode.isSpaceBetween(penultimate, last);
1319
1319
  if (options.isClosingCurlyBraceMustBeSpaced(penultimate)) {
1320
- if (!lastSpaced) reportRequiredEndingSpace(node, last$1);
1321
- } else if (lastSpaced) reportNoEndingSpace(node, last$1);
1320
+ if (!lastSpaced) reportRequiredEndingSpace(node, last);
1321
+ } else if (lastSpaced) reportNoEndingSpace(node, last);
1322
1322
  }
1323
1323
  }
1324
1324
  /**
@@ -1343,8 +1343,8 @@ var inline_table_curly_spacing_default = createRule("inline-table-curly-spacing"
1343
1343
  function checkForObject(node) {
1344
1344
  if (node.body.length === 0) return;
1345
1345
  const first = sourceCode.getFirstToken(node);
1346
- const last$1 = getClosingBraceOfObject(node);
1347
- validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: true }), sourceCode.getTokenBefore(last$1, { includeComments: true }), last$1);
1346
+ const last = getClosingBraceOfObject(node);
1347
+ validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: true }), sourceCode.getTokenBefore(last, { includeComments: true }), last);
1348
1348
  }
1349
1349
  return { TOMLInlineTable: checkForObject };
1350
1350
  }
@@ -1659,7 +1659,7 @@ function create(context) {
1659
1659
  /**
1660
1660
  * Define alignment rule visitor
1661
1661
  */
1662
- function defineAlignmentVisitor(alignmentOptions$1) {
1662
+ function defineAlignmentVisitor(alignmentOptions) {
1663
1663
  return { "TOMLTopLevelTable, TOMLTable, TOMLInlineTable"(node) {
1664
1664
  if (isSingleLine(node)) {
1665
1665
  const body = node.body;
@@ -1674,17 +1674,17 @@ function create(context) {
1674
1674
  function verifyGroupAlignment(properties) {
1675
1675
  const length = properties.length;
1676
1676
  const widths = properties.map(getKeyWidth);
1677
- const align = alignmentOptions$1.on;
1677
+ const align = alignmentOptions.on;
1678
1678
  let targetWidth = Math.max(...widths);
1679
1679
  let beforeEqual, afterEqual, mode;
1680
- if (alignmentOptions$1 && length > 1) {
1681
- beforeEqual = alignmentOptions$1.beforeEqual ? 1 : 0;
1682
- afterEqual = alignmentOptions$1.afterEqual ? 1 : 0;
1683
- mode = alignmentOptions$1.mode;
1680
+ if (alignmentOptions && length > 1) {
1681
+ beforeEqual = alignmentOptions.beforeEqual ? 1 : 0;
1682
+ afterEqual = alignmentOptions.afterEqual ? 1 : 0;
1683
+ mode = alignmentOptions.mode;
1684
1684
  } else {
1685
1685
  beforeEqual = multiLineOptions.beforeEqual ? 1 : 0;
1686
1686
  afterEqual = multiLineOptions.afterEqual ? 1 : 0;
1687
- mode = alignmentOptions$1.mode;
1687
+ mode = alignmentOptions.mode;
1688
1688
  }
1689
1689
  targetWidth += align === "equal" ? beforeEqual : afterEqual;
1690
1690
  for (let i = 0; i < length; i++) {
@@ -2838,11 +2838,11 @@ var table_bracket_spacing_default = createRule("table-bracket-spacing", {
2838
2838
  function validateArraySpacing(node) {
2839
2839
  const key = node.key;
2840
2840
  const first = sourceCode.getTokenBefore(key);
2841
- const last$1 = sourceCode.getTokenAfter(key);
2841
+ const last = sourceCode.getTokenAfter(key);
2842
2842
  if (prefer === "always" && first.range[1] === key.range[0]) reportRequiredBeginningSpace(node, first);
2843
2843
  if (prefer === "never" && first.range[1] < key.range[0]) reportNoBeginningSpace(node, first);
2844
- if (prefer === "always" && key.range[1] === last$1.range[0]) reportRequiredEndingSpace(node, last$1);
2845
- if (prefer === "never" && key.range[1] < last$1.range[0]) reportNoEndingSpace(node, last$1);
2844
+ if (prefer === "always" && key.range[1] === last.range[0]) reportRequiredEndingSpace(node, last);
2845
+ if (prefer === "never" && key.range[1] < last.range[0]) reportNoEndingSpace(node, last);
2846
2846
  }
2847
2847
  return { TOMLTable: validateArraySpacing };
2848
2848
  }
@@ -2862,8 +2862,8 @@ function getFirst(keys) {
2862
2862
  * Get last key node
2863
2863
  */
2864
2864
  function getLast(keys) {
2865
- const last$1 = keys[keys.length - 1];
2866
- if (last$1) return getLast(last$1.keys) || last$1.node;
2865
+ const last = keys[keys.length - 1];
2866
+ if (last) return getLast(last.keys) || last.node;
2867
2867
  return null;
2868
2868
  }
2869
2869
  var tables_order_default = createRule("tables-order", {
@@ -3070,7 +3070,7 @@ var standard_default = [...base_default, { rules: {
3070
3070
  //#endregion
3071
3071
  //#region package.json
3072
3072
  var name$1 = "eslint-plugin-toml";
3073
- var version$1 = "1.0.2";
3073
+ var version$1 = "1.0.4";
3074
3074
 
3075
3075
  //#endregion
3076
3076
  //#region src/meta.ts
@@ -3490,14 +3490,14 @@ var TOMLSourceCode = class extends TextSourceCodeBase {
3490
3490
  */
3491
3491
  applyInlineConfig() {
3492
3492
  const problems = [];
3493
- const configs$1 = [];
3493
+ const configs = [];
3494
3494
  this.getInlineConfigNodes().forEach((comment) => {
3495
3495
  const directive = commentParser.parseDirective(comment.value);
3496
3496
  if (!directive) return;
3497
3497
  const { label, value } = directive;
3498
3498
  if (label === "eslint") {
3499
3499
  const parseResult = commentParser.parseJSONLikeConfig(value);
3500
- if (parseResult.ok) configs$1.push({
3500
+ if (parseResult.ok) configs.push({
3501
3501
  config: { rules: parseResult.config },
3502
3502
  loc: comment.loc
3503
3503
  });
@@ -3509,7 +3509,7 @@ var TOMLSourceCode = class extends TextSourceCodeBase {
3509
3509
  }
3510
3510
  });
3511
3511
  return {
3512
- configs: configs$1,
3512
+ configs,
3513
3513
  problems
3514
3514
  };
3515
3515
  }
@@ -3525,7 +3525,7 @@ var TOMLSourceCode = class extends TextSourceCodeBase {
3525
3525
  * Finds a node that contains the given index.
3526
3526
  */
3527
3527
  function find(nodes) {
3528
- for (const node$1 of nodes) if (node$1.range[0] <= index && index < node$1.range[1]) return node$1;
3528
+ for (const node of nodes) if (node.range[0] <= index && index < node.range[1]) return node;
3529
3529
  return null;
3530
3530
  }
3531
3531
  }
@@ -3578,25 +3578,23 @@ var TOMLSourceCode = class extends TextSourceCodeBase {
3578
3578
  */
3579
3579
  getScope(node) {
3580
3580
  if (node?.type !== "Program") return null;
3581
- const fakeGlobalScope = {
3582
- type: "global",
3583
- block: node,
3584
- set: /* @__PURE__ */ new Map(),
3585
- through: [],
3586
- childScopes: [],
3587
- variableScope: null,
3588
- variables: [],
3589
- references: [],
3590
- functionExpressionScope: false,
3591
- isStrict: false,
3592
- upper: null,
3593
- implicit: {
3594
- variables: [],
3595
- set: /* @__PURE__ */ new Map()
3596
- }
3581
+ return createFakeGlobalScope(this.ast);
3582
+ }
3583
+ /**
3584
+ * Compatibility for ESLint's SourceCode API
3585
+ * @deprecated TOML does not have scopes
3586
+ */
3587
+ get scopeManager() {
3588
+ return {
3589
+ scopes: [],
3590
+ globalScope: createFakeGlobalScope(this.ast),
3591
+ acquire: (node) => {
3592
+ if (node.type === "Program") return createFakeGlobalScope(this.ast);
3593
+ return null;
3594
+ },
3595
+ getDeclaredVariables: () => [],
3596
+ addGlobals: () => {}
3597
3597
  };
3598
- fakeGlobalScope.variableScope = fakeGlobalScope;
3599
- return fakeGlobalScope;
3600
3598
  }
3601
3599
  /**
3602
3600
  * Compatibility for ESLint's SourceCode API
@@ -3629,6 +3627,31 @@ function isNode(value) {
3629
3627
  function nodesOrTokensOverlap(first, second) {
3630
3628
  return first.range[0] < second.range[1] && second.range[0] < first.range[1];
3631
3629
  }
3630
+ /**
3631
+ * Creates a fake global scope for TOML files.
3632
+ * @deprecated TOML does not have scopes
3633
+ */
3634
+ function createFakeGlobalScope(node) {
3635
+ const fakeGlobalScope = {
3636
+ type: "global",
3637
+ block: node,
3638
+ set: /* @__PURE__ */ new Map(),
3639
+ through: [],
3640
+ childScopes: [],
3641
+ variableScope: null,
3642
+ variables: [],
3643
+ references: [],
3644
+ functionExpressionScope: false,
3645
+ isStrict: false,
3646
+ upper: null,
3647
+ implicit: {
3648
+ variables: [],
3649
+ set: /* @__PURE__ */ new Map()
3650
+ }
3651
+ };
3652
+ fakeGlobalScope.variableScope = fakeGlobalScope;
3653
+ return fakeGlobalScope;
3654
+ }
3632
3655
 
3633
3656
  //#endregion
3634
3657
  //#region src/language/toml-language.ts
@@ -3648,6 +3671,7 @@ var TOMLLanguage = class {
3648
3671
  validateLanguageOptions(_languageOptions) {}
3649
3672
  normalizeLanguageOptions(languageOptions) {
3650
3673
  return {
3674
+ ecmaVersion: "latest",
3651
3675
  ...languageOptions,
3652
3676
  parserOptions: { ...languageOptions.parserOptions }
3653
3677
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-toml",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "This ESLint plugin provides linting rules for TOML.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "@eslint/core": "^1.0.1",
68
- "@eslint/plugin-kit": "^0.5.1",
68
+ "@eslint/plugin-kit": "^0.6.0",
69
69
  "debug": "^4.1.1",
70
70
  "toml-eslint-parser": "^1.0.1"
71
71
  },
@@ -73,14 +73,11 @@
73
73
  "@changesets/changelog-github": "^0.5.0",
74
74
  "@changesets/cli": "^2.27.5",
75
75
  "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
76
- "@eslint/json": "^0.14.0",
77
- "@ota-meshi/eslint-plugin": "^0.18.0",
76
+ "@eslint/json": "^1.0.0",
77
+ "@ota-meshi/eslint-plugin": "^0.20.0",
78
78
  "@ota-meshi/site-kit-eslint-editor-vue": "^0.2.1",
79
+ "@stylistic/eslint-plugin": "^5.7.1",
79
80
  "@types/debug": "^4.1.12",
80
- "@types/eslint": "^9.0.0",
81
- "@types/eslint-scope": "^8.0.0",
82
- "@types/eslint-visitor-keys": "^3.3.0",
83
- "@types/estree": "^1.0.5",
84
81
  "@types/mocha": "^10.0.7",
85
82
  "@types/node": "^24.0.0",
86
83
  "@types/semver": "^7.5.8",
@@ -89,20 +86,20 @@
89
86
  "cross-env": "^10.0.0",
90
87
  "env-cmd": "^11.0.0",
91
88
  "esbuild": "^0.27.0",
92
- "eslint": "^9.5.0",
89
+ "eslint": "^10.0.0",
93
90
  "eslint-config-prettier": "^10.0.0",
94
91
  "eslint-plugin-eslint-plugin": "^7.0.0",
95
92
  "eslint-plugin-jsdoc": "^62.0.0",
96
- "eslint-plugin-json-schema-validator": "^5.1.1",
93
+ "eslint-plugin-json-schema-validator": "^6.0.0",
97
94
  "eslint-plugin-jsonc": "^2.16.0",
98
95
  "eslint-plugin-markdown": "^5.0.0",
99
96
  "eslint-plugin-n": "^17.9.0",
100
97
  "eslint-plugin-node-dependencies": "^1.0.0",
101
98
  "eslint-plugin-prettier": "^5.1.3",
102
- "eslint-plugin-regexp": "^2.6.0",
99
+ "eslint-plugin-regexp": "^3.0.0",
103
100
  "eslint-plugin-toml": "^1.0.0",
104
101
  "eslint-plugin-vue": "^10.0.0",
105
- "eslint-plugin-yml": "^2.0.0",
102
+ "eslint-plugin-yml": "^3.0.0",
106
103
  "events": "^3.3.0",
107
104
  "mocha": "^11.0.0",
108
105
  "nyc": "^17.0.0",
@@ -114,7 +111,7 @@
114
111
  "stylelint-config-standard": "^40.0.0",
115
112
  "stylelint-config-standard-vue": "^1.0.0",
116
113
  "stylelint-stylus": "^1.0.0",
117
- "tsdown": "^0.19.0",
114
+ "tsdown": "^0.20.0",
118
115
  "tsx": "^4.21.0",
119
116
  "typescript": "~5.9.0",
120
117
  "typescript-eslint": "^8.16.0",