eslint-plugin-toml 0.13.0 → 1.0.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.
Files changed (79) hide show
  1. package/README.md +28 -75
  2. package/lib/chunk-15K8U1wQ.mjs +18 -0
  3. package/lib/index.d.mts +215 -0
  4. package/lib/index.mjs +3695 -0
  5. package/package.json +41 -32
  6. package/lib/configs/base.d.ts +0 -12
  7. package/lib/configs/base.js +0 -14
  8. package/lib/configs/flat/base.d.ts +0 -21
  9. package/lib/configs/flat/base.js +0 -55
  10. package/lib/configs/flat/recommended.d.ts +0 -26
  11. package/lib/configs/flat/recommended.js +0 -17
  12. package/lib/configs/flat/standard.d.ts +0 -41
  13. package/lib/configs/flat/standard.js +0 -32
  14. package/lib/configs/recommended.d.ts +0 -10
  15. package/lib/configs/recommended.js +0 -16
  16. package/lib/configs/standard.d.ts +0 -25
  17. package/lib/configs/standard.js +0 -31
  18. package/lib/index.d.ts +0 -138
  19. package/lib/index.js +0 -62
  20. package/lib/meta.d.ts +0 -2
  21. package/lib/meta.js +0 -5
  22. package/lib/rules/array-bracket-newline.d.ts +0 -2
  23. package/lib/rules/array-bracket-newline.js +0 -173
  24. package/lib/rules/array-bracket-spacing.d.ts +0 -2
  25. package/lib/rules/array-bracket-spacing.js +0 -178
  26. package/lib/rules/array-element-newline.d.ts +0 -2
  27. package/lib/rules/array-element-newline.js +0 -202
  28. package/lib/rules/comma-style.d.ts +0 -2
  29. package/lib/rules/comma-style.js +0 -163
  30. package/lib/rules/indent.d.ts +0 -2
  31. package/lib/rules/indent.js +0 -448
  32. package/lib/rules/inline-table-curly-spacing.d.ts +0 -2
  33. package/lib/rules/inline-table-curly-spacing.js +0 -176
  34. package/lib/rules/key-spacing.d.ts +0 -2
  35. package/lib/rules/key-spacing.js +0 -396
  36. package/lib/rules/keys-order.d.ts +0 -2
  37. package/lib/rules/keys-order.js +0 -86
  38. package/lib/rules/no-mixed-type-in-array.d.ts +0 -2
  39. package/lib/rules/no-mixed-type-in-array.js +0 -110
  40. package/lib/rules/no-non-decimal-integer.d.ts +0 -2
  41. package/lib/rules/no-non-decimal-integer.js +0 -107
  42. package/lib/rules/no-space-dots.d.ts +0 -2
  43. package/lib/rules/no-space-dots.js +0 -59
  44. package/lib/rules/no-unreadable-number-separator.d.ts +0 -2
  45. package/lib/rules/no-unreadable-number-separator.js +0 -123
  46. package/lib/rules/padding-line-between-pairs.d.ts +0 -2
  47. package/lib/rules/padding-line-between-pairs.js +0 -80
  48. package/lib/rules/padding-line-between-tables.d.ts +0 -2
  49. package/lib/rules/padding-line-between-tables.js +0 -57
  50. package/lib/rules/precision-of-fractional-seconds.d.ts +0 -2
  51. package/lib/rules/precision-of-fractional-seconds.js +0 -60
  52. package/lib/rules/precision-of-integer.d.ts +0 -2
  53. package/lib/rules/precision-of-integer.js +0 -95
  54. package/lib/rules/quoted-keys.d.ts +0 -2
  55. package/lib/rules/quoted-keys.js +0 -85
  56. package/lib/rules/space-eq-sign.d.ts +0 -2
  57. package/lib/rules/space-eq-sign.js +0 -52
  58. package/lib/rules/spaced-comment.d.ts +0 -2
  59. package/lib/rules/spaced-comment.js +0 -158
  60. package/lib/rules/table-bracket-spacing.d.ts +0 -2
  61. package/lib/rules/table-bracket-spacing.js +0 -107
  62. package/lib/rules/tables-order.d.ts +0 -2
  63. package/lib/rules/tables-order.js +0 -129
  64. package/lib/rules/vue-custom-block/no-parsing-error.d.ts +0 -2
  65. package/lib/rules/vue-custom-block/no-parsing-error.js +0 -43
  66. package/lib/types.d.ts +0 -200
  67. package/lib/types.js +0 -2
  68. package/lib/utils/ast-utils.d.ts +0 -10
  69. package/lib/utils/ast-utils.js +0 -36
  70. package/lib/utils/bit.d.ts +0 -8
  71. package/lib/utils/bit.js +0 -43
  72. package/lib/utils/casing.d.ts +0 -15
  73. package/lib/utils/casing.js +0 -134
  74. package/lib/utils/compat.d.ts +0 -5
  75. package/lib/utils/compat.js +0 -11
  76. package/lib/utils/index.d.ts +0 -2
  77. package/lib/utils/index.js +0 -73
  78. package/lib/utils/rules.d.ts +0 -2
  79. package/lib/utils/rules.js +0 -52
package/README.md CHANGED
@@ -39,8 +39,8 @@ npm install --save-dev eslint eslint-plugin-toml
39
39
 
40
40
  > **Requirements**
41
41
  >
42
- > - ESLint v6.0.0 and above
43
- > - Node.js v12.22.x, v14.17.x, v16.x and above
42
+ > - ESLint v9.38.0 and above
43
+ > - Node.js v20.19.x, v22.13.x, v24.x and above
44
44
 
45
45
  <!--DOCS_IGNORE_END-->
46
46
 
@@ -51,18 +51,16 @@ npm install --save-dev eslint eslint-plugin-toml
51
51
 
52
52
  ### Configuration
53
53
 
54
- #### New Config (`eslint.config.js`)
55
-
56
- Use `eslint.config.js` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/configuration-files-new>.
54
+ Use `eslint.config.js` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/configuration-files>.
57
55
 
58
56
  Example **eslint.config.js**:
59
57
 
60
- ```mjs
58
+ ```js
61
59
  import eslintPluginToml from 'eslint-plugin-toml';
62
60
  export default [
63
61
  // add more generic rule sets here, such as:
64
62
  // js.configs.recommended,
65
- ...eslintPluginToml.configs['flat/recommended'],
63
+ ...eslintPluginToml.configs.recommended,
66
64
  {
67
65
  rules: {
68
66
  // override/add rules settings here, such as:
@@ -74,87 +72,42 @@ export default [
74
72
 
75
73
  This plugin provides configs:
76
74
 
77
- - `*.configs['flat/base']` ... Configuration to enable correct TOML parsing.
78
- - `*.configs['flat/recommended']` ... Above, plus rules to prevent errors or unintended behavior.
79
- - `*.configs['flat/standard']` ... Above, plus rules to enforce the common stylistic conventions.
80
-
81
- See [the rule list](https://ota-meshi.github.io/eslint-plugin-toml/rules/) to get the `rules` that this plugin provides.
82
-
83
- #### Legacy Config (`.eslintrc`)
84
-
85
- Use `.eslintrc.*` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/>.
86
-
87
- Example **.eslintrc.js**:
88
-
89
- ```js
90
- module.exports = {
91
- extends: [
92
- // add more generic rulesets here, such as:
93
- // 'eslint:recommended',
94
- 'plugin:toml/standard'
95
- ],
96
- rules: {
97
- // override/add rules settings here, such as:
98
- // 'toml/rule-name': 'error'
99
- }
100
- }
101
- ```
102
-
103
- This plugin provides configs:
75
+ - `*.configs.base` ... Configuration to enable correct TOML parsing.
76
+ - `*.configs.recommended` ... Above, plus rules to prevent errors or unintended behavior.
77
+ - `*.configs.standard` ... Above, plus rules to enforce the common stylistic conventions.
104
78
 
105
- - `plugin:toml/base` ... Configuration to enable correct TOML parsing.
106
- - `plugin:toml/recommended` ... Above, plus rules to prevent errors or unintended behavior.
107
- - `plugin:toml/standard` ... Above, plus rules to enforce the common stylistic conventions.
79
+ For backward compatibility, you can also use the `flat/*` namespace:
108
80
 
109
- Note that these configurations do not enable ESLint's core rules.
110
- For example, the following style rules can also be used in TOML.
111
-
112
- ```json5
113
- {
114
- "rules": {
115
- "comma-spacing": "error",
116
- "no-multi-spaces": ["error", { "exceptions": { "TOMLKeyValue": true } }],
117
- "no-multiple-empty-lines": "error",
118
- "no-trailing-spaces": "error"
119
- }
120
- }
121
- ```
81
+ - `*.configs['flat/base']`
82
+ - `*.configs['flat/recommended']`
83
+ - `*.configs['flat/standard']`
122
84
 
123
85
  See [the rule list](https://ota-meshi.github.io/eslint-plugin-toml/rules/) to get the `rules` that this plugin provides.
124
86
 
125
- #### Parser Configuration
87
+ #### Languages
88
+
89
+ This plugin provides the following language identifiers for use in ESLint configurations:
126
90
 
127
- If you have specified a parser, you need to configure a parser for `.toml`.
91
+ - `toml/toml` ... TOML files
128
92
 
129
- For example, if you are using the `"@babel/eslint-parser"`, configure it as follows:
93
+ For example, to apply settings specifically to TOML files, you can use the `language` field in your ESLint configuration:
130
94
 
131
95
  ```js
132
- module.exports = {
133
- // ...
134
- extends: ["plugin:toml/standard"],
135
- // ...
136
- parser: "@babel/eslint-parser",
137
- // Add an `overrides` section to add a parser configuration for TOML.
138
- overrides: [
139
- {
140
- files: ["*.toml"],
141
- parser: "toml-eslint-parser",
96
+ import eslintPluginToml from 'eslint-plugin-toml';
97
+ export default [
98
+ {
99
+ files: ["*.toml", "**/*.toml"],
100
+ plugins: {
101
+ toml: eslintPluginToml,
142
102
  },
143
- ],
144
- // ...
145
- };
103
+ language: "toml/toml",
104
+ }
105
+ ]
146
106
  ```
147
107
 
148
- ### Running ESLint from the command line
149
-
150
- If you want to run `eslint` from the command line, make sure you include the `.toml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.
108
+ The configuration above is included in the shareable configs provided by this plugin, so using `configs` is generally recommended.
151
109
 
152
- Examples:
153
-
154
- ```bash
155
- eslint --ext .js,.toml src
156
- eslint "src/**/*.{js,toml}"
157
- ```
110
+ See also <https://eslint.org/docs/latest/use/configure/plugins#specify-a-language>
158
111
 
159
112
  ## :computer: Editor Integrations
160
113
 
@@ -0,0 +1,18 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll as t };
@@ -0,0 +1,215 @@
1
+ import { AST, TOMLVersionOption } from "toml-eslint-parser";
2
+ import { IDirective, TextSourceCodeBase, TraversalStep } from "@eslint/plugin-kit";
3
+ import * as _eslint_core0 from "@eslint/core";
4
+ import { File, FileProblem, Language, OkParseResult, RuleDefinition, RulesConfig } from "@eslint/core";
5
+ import { Linter, Scope } from "eslint";
6
+
7
+ //#region src/meta.d.ts
8
+ declare namespace meta_d_exports {
9
+ export { name, version };
10
+ }
11
+ declare const name: string;
12
+ declare const version: string;
13
+ //#endregion
14
+ //#region src/language/token-store.d.ts
15
+
16
+ type FilterPredicate = (tokenOrComment: TOMLToken) => boolean;
17
+ type CursorWithSkipOptions = number | FilterPredicate | {
18
+ includeComments?: boolean;
19
+ filter?: FilterPredicate;
20
+ skip?: number;
21
+ };
22
+ type CursorWithCountOptions = number | FilterPredicate | {
23
+ includeComments?: boolean;
24
+ filter?: FilterPredicate;
25
+ count?: number;
26
+ };
27
+ //#endregion
28
+ //#region src/language/toml-source-code.d.ts
29
+ /**
30
+ * TOML-specific syntax element type
31
+ */
32
+ type TOMLSyntaxElement = AST.TOMLNode | AST.Token | AST.Comment;
33
+ type TOMLToken = AST.Token | AST.Comment;
34
+ /**
35
+ * TOML Source Code Object
36
+ */
37
+ declare class TOMLSourceCode extends TextSourceCodeBase<{
38
+ LangOptions: Record<never, never>;
39
+ RootNode: AST.TOMLProgram;
40
+ SyntaxElementWithLoc: TOMLSyntaxElement;
41
+ ConfigNode: AST.Comment;
42
+ }> {
43
+ #private;
44
+ readonly hasBOM: boolean;
45
+ readonly parserServices: {
46
+ isTOML?: boolean;
47
+ parseError?: unknown;
48
+ };
49
+ readonly visitorKeys: Record<string, string[]>;
50
+ private readonly tokenStore;
51
+ /**
52
+ * Creates a new instance.
53
+ */
54
+ constructor(config: {
55
+ text: string;
56
+ ast: AST.TOMLProgram;
57
+ hasBOM: boolean;
58
+ parserServices: {
59
+ isTOML: boolean;
60
+ parseError?: unknown;
61
+ };
62
+ visitorKeys?: Record<string, string[]> | null | undefined;
63
+ });
64
+ traverse(): Iterable<TraversalStep>;
65
+ /**
66
+ * Gets all tokens and comments.
67
+ */
68
+ get tokensAndComments(): TOMLToken[];
69
+ getLines(): string[];
70
+ getAllComments(): AST.Comment[];
71
+ /**
72
+ * Returns an array of all inline configuration nodes found in the source code.
73
+ * This includes eslint-disable, eslint-enable, eslint-disable-line,
74
+ * eslint-disable-next-line, and eslint (for inline config) comments.
75
+ */
76
+ getInlineConfigNodes(): AST.Comment[];
77
+ /**
78
+ * Returns directives that enable or disable rules along with any problems
79
+ * encountered while parsing the directives.
80
+ */
81
+ getDisableDirectives(): {
82
+ directives: IDirective[];
83
+ problems: FileProblem[];
84
+ };
85
+ /**
86
+ * Returns inline rule configurations along with any problems
87
+ * encountered while parsing the configurations.
88
+ */
89
+ applyInlineConfig(): {
90
+ configs: {
91
+ config: {
92
+ rules: RulesConfig;
93
+ };
94
+ loc: AST.SourceLocation;
95
+ }[];
96
+ problems: FileProblem[];
97
+ };
98
+ getNodeByRangeIndex(index: number): AST.TOMLNode | null;
99
+ getFirstToken(node: TOMLSyntaxElement): AST.Token;
100
+ getFirstToken(node: TOMLSyntaxElement, options?: CursorWithSkipOptions): TOMLToken | null;
101
+ getLastToken(node: TOMLSyntaxElement): AST.Token;
102
+ getLastToken(node: TOMLSyntaxElement, options?: CursorWithSkipOptions): TOMLToken | null;
103
+ getTokenBefore(node: TOMLSyntaxElement): AST.Token | null;
104
+ getTokenBefore(node: TOMLSyntaxElement, options?: CursorWithSkipOptions): TOMLToken | null;
105
+ getTokensBefore(node: TOMLSyntaxElement, options?: CursorWithCountOptions): TOMLToken[];
106
+ getTokenAfter(node: TOMLSyntaxElement): AST.Token | null;
107
+ getTokenAfter(node: TOMLSyntaxElement, options?: CursorWithSkipOptions): TOMLToken | null;
108
+ getFirstTokenBetween(left: TOMLSyntaxElement, right: TOMLSyntaxElement, options?: CursorWithSkipOptions): TOMLToken | null;
109
+ getTokensBetween(left: TOMLSyntaxElement, right: TOMLSyntaxElement, paddingOrOptions?: number | FilterPredicate | CursorWithCountOptions): TOMLToken[];
110
+ getTokens(node: AST.TOMLNode, options?: FilterPredicate | CursorWithCountOptions): TOMLToken[];
111
+ getCommentsBefore(nodeOrToken: TOMLSyntaxElement): AST.Comment[];
112
+ getCommentsAfter(nodeOrToken: TOMLSyntaxElement): AST.Comment[];
113
+ isSpaceBetween(first: TOMLToken, second: TOMLToken): boolean;
114
+ /**
115
+ * Compatibility for ESLint's SourceCode API
116
+ * @deprecated TOML does not have scopes
117
+ */
118
+ getScope(node?: AST.TOMLNode): Scope.Scope | null;
119
+ /**
120
+ * Compatibility for ESLint's SourceCode API
121
+ * @deprecated
122
+ */
123
+ isSpaceBetweenTokens(first: TOMLToken, second: TOMLToken): boolean;
124
+ private _getChildren;
125
+ }
126
+ //#endregion
127
+ //#region src/language/toml-language.d.ts
128
+ /**
129
+ * Parse result
130
+ */
131
+ interface TOMLParseResult {
132
+ ok: true;
133
+ ast: AST.TOMLProgram;
134
+ }
135
+ /**
136
+ * Language options for TOML
137
+ * Currently no options are defined.
138
+ */
139
+ type TOMLLanguageOptions = {
140
+ parserOptions?: {
141
+ tomlVersion?: TOMLVersionOption;
142
+ };
143
+ };
144
+ /**
145
+ * The TOML language implementation for ESLint.
146
+ */
147
+ declare class TOMLLanguage implements Language<{
148
+ LangOptions: TOMLLanguageOptions;
149
+ Code: TOMLSourceCode;
150
+ RootNode: AST.TOMLProgram;
151
+ Node: AST.TOMLNode;
152
+ }> {
153
+ /**
154
+ * The type of file to read.
155
+ */
156
+ fileType: "text";
157
+ /**
158
+ * The line number at which the parser starts counting.
159
+ */
160
+ lineStart: 1;
161
+ /**
162
+ * The column number at which the parser starts counting.
163
+ */
164
+ columnStart: 0;
165
+ /**
166
+ * The name of the key that holds the type of the node.
167
+ */
168
+ nodeTypeKey: "type";
169
+ /**
170
+ * Validates the language options.
171
+ */
172
+ validateLanguageOptions(_languageOptions: TOMLLanguageOptions): void;
173
+ normalizeLanguageOptions(languageOptions: TOMLLanguageOptions): TOMLLanguageOptions;
174
+ /**
175
+ * Parses the given file into an AST.
176
+ */
177
+ parse(file: File, context: {
178
+ languageOptions?: TOMLLanguageOptions;
179
+ }): OkParseResult<AST.TOMLProgram> | TOMLParseResult;
180
+ /**
181
+ * Creates a new SourceCode object for the given file and parse result.
182
+ */
183
+ createSourceCode(file: File, parseResult: OkParseResult<AST.TOMLProgram> | TOMLParseResult): TOMLSourceCode;
184
+ }
185
+ //#endregion
186
+ //#region src/index.d.ts
187
+ declare const configs: {
188
+ base: Linter.Config[];
189
+ recommended: Linter.Config[];
190
+ standard: Linter.Config[];
191
+ "flat/base": Linter.Config[];
192
+ "flat/recommended": Linter.Config[];
193
+ "flat/standard": Linter.Config[];
194
+ };
195
+ declare const rules: Record<string, RuleDefinition>;
196
+ declare const languages: {
197
+ toml: TOMLLanguage;
198
+ };
199
+ declare const _default: {
200
+ meta: typeof meta_d_exports;
201
+ configs: {
202
+ base: Linter.Config[];
203
+ recommended: Linter.Config[];
204
+ standard: Linter.Config[];
205
+ "flat/base": Linter.Config[];
206
+ "flat/recommended": Linter.Config[];
207
+ "flat/standard": Linter.Config[];
208
+ };
209
+ rules: Record<string, RuleDefinition<_eslint_core0.RuleDefinitionTypeOptions>>;
210
+ languages: {
211
+ toml: TOMLLanguage;
212
+ };
213
+ };
214
+ //#endregion
215
+ export { type TOMLLanguageOptions, type TOMLSourceCode, configs, _default as default, languages, meta_d_exports as meta, rules };