eslint-plugin-toml 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/lib/index.mjs +34 -24
  2. package/package.json +8 -7
package/lib/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./chunk-15K8U1wQ.mjs";
2
2
  import * as tomlESLintParser from "toml-eslint-parser";
3
- import { VisitorKeys, getStaticTOMLValue, parseForESLint, traverseNodes } from "toml-eslint-parser";
3
+ import { VisitorKeys, getStaticTOMLValue, parseTOML, traverseNodes } from "toml-eslint-parser";
4
4
  import path from "path";
5
5
  import { CallMethodStep, ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep } from "@eslint/plugin-kit";
6
6
 
@@ -178,7 +178,7 @@ var array_bracket_newline_default = createRule("array-bracket-newline", {
178
178
  * @param options An option value to parse.
179
179
  * @returns Normalized option object.
180
180
  */
181
- function normalizeOptions$1(options) {
181
+ function normalizeOptions(options) {
182
182
  return { TOMLArray: normalizeOptionValue(options) };
183
183
  }
184
184
  /**
@@ -251,7 +251,7 @@ var array_bracket_newline_default = createRule("array-bracket-newline", {
251
251
  */
252
252
  function check(node) {
253
253
  const elements = node.elements;
254
- const options = normalizeOptions$1(context.options[0])[node.type];
254
+ const options = normalizeOptions(context.options[0])[node.type];
255
255
  const openBracket = sourceCode.getFirstToken(node);
256
256
  const closeBracket = sourceCode.getLastToken(node);
257
257
  const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true });
@@ -531,7 +531,7 @@ var array_element_newline_default = createRule("array-element-newline", {
531
531
  * @param options An option value to parse.
532
532
  * @returns Normalized option object.
533
533
  */
534
- function normalizeOptions$1(options) {
534
+ function normalizeOptions(options) {
535
535
  if (options && (options.ArrayExpression || options.TOMLArray)) {
536
536
  let expressionOptions;
537
537
  if (options.ArrayExpression) expressionOptions = normalizeOptionValue(options.ArrayExpression);
@@ -598,7 +598,7 @@ var array_element_newline_default = createRule("array-element-newline", {
598
598
  */
599
599
  function check(node) {
600
600
  const elements = node.elements;
601
- const options = normalizeOptions$1(context.options[0])[node.type];
601
+ const options = normalizeOptions(context.options[0])[node.type];
602
602
  if (!options) return;
603
603
  let elementBreak = false;
604
604
  /**
@@ -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.0";
3073
+ var version$1 = "1.0.2";
3074
3074
 
3075
3075
  //#endregion
3076
3076
  //#region src/meta.ts
@@ -3117,20 +3117,29 @@ function getLastIndex(tokens, indexMap, endLoc) {
3117
3117
  /**
3118
3118
  * Normalizes the options for cursor methods.
3119
3119
  */
3120
- function normalizeOptions(options) {
3120
+ function normalizeSkipOptions(options) {
3121
3121
  if (typeof options === "number") return {
3122
- includeComments: false,
3123
- filter: null,
3122
+ filter: isNotComment,
3124
3123
  skip: options
3125
3124
  };
3126
3125
  if (typeof options === "function") return {
3127
- includeComments: false,
3128
- filter: options,
3126
+ filter: (n) => {
3127
+ if (isComment(n)) return false;
3128
+ return options(n);
3129
+ },
3129
3130
  skip: 0
3130
3131
  };
3132
+ let filter;
3133
+ if (options?.includeComments) filter = options?.filter ?? (() => true);
3134
+ else if (options?.filter) {
3135
+ const baseFilter = options?.filter;
3136
+ filter = (token) => {
3137
+ if (isComment(token)) return false;
3138
+ return baseFilter(token);
3139
+ };
3140
+ } else filter = isNotComment;
3131
3141
  return {
3132
- includeComments: options?.includeComments ?? false,
3133
- filter: options?.filter ?? null,
3142
+ filter,
3134
3143
  skip: options?.skip ?? 0
3135
3144
  };
3136
3145
  }
@@ -3161,16 +3170,17 @@ function normalizeCountOptions(options) {
3161
3170
  },
3162
3171
  count: 0
3163
3172
  };
3164
- let filter = options?.filter;
3165
- if (!options?.includeComments) if (filter) {
3166
- const baseFilter = filter;
3173
+ let filter;
3174
+ if (options?.includeComments) filter = options?.filter ?? (() => true);
3175
+ else if (options?.filter) {
3176
+ const baseFilter = options?.filter;
3167
3177
  filter = (token) => {
3168
3178
  if (isComment(token)) return false;
3169
3179
  return baseFilter(token);
3170
3180
  };
3171
3181
  } else filter = isNotComment;
3172
3182
  return {
3173
- filter: filter ?? null,
3183
+ filter,
3174
3184
  count: options?.count ?? 0
3175
3185
  };
3176
3186
  }
@@ -3186,7 +3196,7 @@ var TokenStore = class {
3186
3196
  * Gets the first token of the given node.
3187
3197
  */
3188
3198
  getFirstToken(node, options) {
3189
- const { filter, skip } = normalizeOptions(options);
3199
+ const { filter, skip } = normalizeSkipOptions(options);
3190
3200
  const startIndex = getFirstIndex(this.allTokens, this.tokenStartToIndex, node.range[0]);
3191
3201
  const endIndex = getLastIndex(this.allTokens, this.tokenStartToIndex, node.range[1]);
3192
3202
  let skipped = 0;
@@ -3205,7 +3215,7 @@ var TokenStore = class {
3205
3215
  * Gets the last token of the given node.
3206
3216
  */
3207
3217
  getLastToken(node, options) {
3208
- const { filter, skip } = normalizeOptions(options);
3218
+ const { filter, skip } = normalizeSkipOptions(options);
3209
3219
  const startIndex = getFirstIndex(this.allTokens, this.tokenStartToIndex, node.range[0]);
3210
3220
  const endIndex = getLastIndex(this.allTokens, this.tokenStartToIndex, node.range[1]);
3211
3221
  let skipped = 0;
@@ -3224,7 +3234,7 @@ var TokenStore = class {
3224
3234
  * Gets the first token between two non-overlapping nodes.
3225
3235
  */
3226
3236
  getFirstTokenBetween(left, right, options) {
3227
- const { filter, skip } = normalizeOptions(options);
3237
+ const { filter, skip } = normalizeSkipOptions(options);
3228
3238
  const startIndex = getFirstIndex(this.allTokens, this.tokenStartToIndex, left.range[1]);
3229
3239
  const endIndex = getLastIndex(this.allTokens, this.tokenStartToIndex, right.range[0]);
3230
3240
  let skipped = 0;
@@ -3243,7 +3253,7 @@ var TokenStore = class {
3243
3253
  * Gets the token that precedes a given node or token.
3244
3254
  */
3245
3255
  getTokenBefore(node, options) {
3246
- const { filter, skip } = normalizeOptions(options);
3256
+ const { filter, skip } = normalizeSkipOptions(options);
3247
3257
  const endIndex = getLastIndex(this.allTokens, this.tokenStartToIndex, node.range[0]);
3248
3258
  let skipped = 0;
3249
3259
  for (let i = endIndex; i >= 0; i--) {
@@ -3261,7 +3271,7 @@ var TokenStore = class {
3261
3271
  * Gets the token that follows a given node or token.
3262
3272
  */
3263
3273
  getTokenAfter(node, options) {
3264
- const { filter, skip } = normalizeOptions(options);
3274
+ const { filter, skip } = normalizeSkipOptions(options);
3265
3275
  const startIndex = getFirstIndex(this.allTokens, this.tokenStartToIndex, node.range[1]);
3266
3276
  let skipped = 0;
3267
3277
  for (let i = startIndex; i < this.allTokens.length; i++) {
@@ -3649,10 +3659,10 @@ var TOMLLanguage = class {
3649
3659
  const text = file.body;
3650
3660
  return {
3651
3661
  ok: true,
3652
- ast: parseForESLint(text, {
3662
+ ast: parseTOML(text, {
3653
3663
  filePath: file.path,
3654
3664
  tomlVersion: context.languageOptions?.parserOptions?.tomlVersion
3655
- }).ast
3665
+ })
3656
3666
  };
3657
3667
  }
3658
3668
  /**
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "eslint-plugin-toml",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "This ESLint plugin provides linting rules for TOML.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
+ "types": "./lib/index.d.mts",
8
9
  "import": "./lib/index.mjs",
9
- "types": "./lib/index.d.mts"
10
+ "default": "./lib/index.mjs"
10
11
  },
11
12
  "./package.json": "./package.json"
12
13
  },
@@ -99,18 +100,18 @@
99
100
  "eslint-plugin-node-dependencies": "^1.0.0",
100
101
  "eslint-plugin-prettier": "^5.1.3",
101
102
  "eslint-plugin-regexp": "^2.6.0",
102
- "eslint-plugin-toml": "^0.13.0",
103
- "eslint-plugin-vue": "^9.26.0",
104
- "eslint-plugin-yml": "^1.14.0",
103
+ "eslint-plugin-toml": "^1.0.0",
104
+ "eslint-plugin-vue": "^10.0.0",
105
+ "eslint-plugin-yml": "^2.0.0",
105
106
  "events": "^3.3.0",
106
107
  "mocha": "^11.0.0",
107
108
  "nyc": "^17.0.0",
108
109
  "pako": "^2.1.0",
109
110
  "prettier": "^3.3.2",
110
111
  "semver": "^7.6.2",
111
- "stylelint": "^16.6.1",
112
+ "stylelint": "^17.0.0",
112
113
  "stylelint-config-recommended-vue": "^1.5.0",
113
- "stylelint-config-standard": "^39.0.0",
114
+ "stylelint-config-standard": "^40.0.0",
114
115
  "stylelint-config-standard-vue": "^1.0.0",
115
116
  "stylelint-stylus": "^1.0.0",
116
117
  "tsdown": "^0.19.0",