eslint-plugin-toml 0.1.0 → 0.3.1

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/README.md CHANGED
@@ -40,7 +40,7 @@ npm install --save-dev eslint eslint-plugin-toml
40
40
  > **Requirements**
41
41
  >
42
42
  > - ESLint v6.0.0 and above
43
- > - Node.js v8.10.0 and above
43
+ > - Node.js v12.22.x, v14.17.x, v16.x and above
44
44
 
45
45
  <!--DOCS_IGNORE_END-->
46
46
 
@@ -82,7 +82,7 @@ For example, the following style rules can also be used in TOML.
82
82
  {
83
83
  "rules": {
84
84
  "comma-spacing": "error",
85
- "no-multi-spaces": "error",
85
+ "no-multi-spaces": ["error", { "exceptions": { "TOMLKeyValue": true } }],
86
86
  "no-multiple-empty-lines": "error",
87
87
  "no-trailing-spaces": "error"
88
88
  }
@@ -91,6 +91,29 @@ For example, the following style rules can also be used in TOML.
91
91
 
92
92
  See [the rule list](https://ota-meshi.github.io/eslint-plugin-toml/rules/) to get the `rules` that this plugin provides.
93
93
 
94
+ #### Parser Configuration
95
+
96
+ If you have specified a parser, you need to configure a parser for `.toml`.
97
+
98
+ For example, if you are using the `"@babel/eslint-parser"`, configure it as follows:
99
+
100
+ ```js
101
+ module.exports = {
102
+ // ...
103
+ extends: ["plugin:toml/standard"],
104
+ // ...
105
+ parser: "@babel/eslint-parser",
106
+ // Add an `overrides` section to add a parser configuration for TOML.
107
+ overrides: [
108
+ {
109
+ files: ["*.toml"],
110
+ parser: "toml-eslint-parser",
111
+ },
112
+ ],
113
+ // ...
114
+ };
115
+ ```
116
+
94
117
  ### Running ESLint from the command line
95
118
 
96
119
  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.
@@ -149,7 +172,6 @@ The rules with the following star :star: are included in the configs.
149
172
  | [toml/precision-of-fractional-seconds](https://ota-meshi.github.io/eslint-plugin-toml/rules/precision-of-fractional-seconds.html) | disallow precision of fractional seconds greater than the specified value. | | :star: | :star: |
150
173
  | [toml/precision-of-integer](https://ota-meshi.github.io/eslint-plugin-toml/rules/precision-of-integer.html) | disallow precision of integer greater than the specified value. | | :star: | :star: |
151
174
  | [toml/quoted-keys](https://ota-meshi.github.io/eslint-plugin-toml/rules/quoted-keys.html) | require or disallow quotes around keys | :wrench: | | :star: |
152
- | [toml/space-eq-sign](https://ota-meshi.github.io/eslint-plugin-toml/rules/space-eq-sign.html) | require spacing around equals sign | :wrench: | | :star: |
153
175
  | [toml/tables-order](https://ota-meshi.github.io/eslint-plugin-toml/rules/tables-order.html) | disallow defining tables out-of-order | :wrench: | | :star: |
154
176
  | [toml/vue-custom-block/no-parsing-error](https://ota-meshi.github.io/eslint-plugin-toml/rules/vue-custom-block/no-parsing-error.html) | disallow parsing errors in Vue custom blocks | | :star: | :star: |
155
177
 
@@ -162,9 +184,19 @@ The rules with the following star :star: are included in the configs.
162
184
  | [toml/array-element-newline](https://ota-meshi.github.io/eslint-plugin-toml/rules/array-element-newline.html) | enforce line breaks between array elements | :wrench: | | :star: |
163
185
  | [toml/comma-style](https://ota-meshi.github.io/eslint-plugin-toml/rules/comma-style.html) | enforce consistent comma style in array | :wrench: | | :star: |
164
186
  | [toml/inline-table-curly-spacing](https://ota-meshi.github.io/eslint-plugin-toml/rules/inline-table-curly-spacing.html) | enforce consistent spacing inside braces | :wrench: | | :star: |
187
+ | [toml/key-spacing](https://ota-meshi.github.io/eslint-plugin-toml/rules/key-spacing.html) | enforce consistent spacing between keys and values in key/value pairs | :wrench: | | :star: |
165
188
  | [toml/spaced-comment](https://ota-meshi.github.io/eslint-plugin-toml/rules/spaced-comment.html) | enforce consistent spacing after the `#` in a comment | :wrench: | | :star: |
166
189
  | [toml/table-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-toml/rules/table-bracket-spacing.html) | enforce consistent spacing inside table brackets | :wrench: | | :star: |
167
190
 
191
+ ## Deprecated
192
+
193
+ - :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
194
+ - :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.
195
+
196
+ | Rule ID | Replaced by |
197
+ |:--------|:------------|
198
+ | [toml/space-eq-sign](https://ota-meshi.github.io/eslint-plugin-toml/rules/space-eq-sign.html) | [toml/key-spacing](https://ota-meshi.github.io/eslint-plugin-toml/rules/key-spacing.html.md) |
199
+
168
200
  <!--RULES_TABLE_END-->
169
201
  <!--RULES_SECTION_END-->
170
202
 
@@ -191,6 +223,7 @@ This plugin uses [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-p
191
223
 
192
224
  - [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) ... ESLint plugin for JSON, JSON with comments (JSONC) and JSON5.
193
225
  - [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) ... ESLint plugin for YAML.
226
+ - [eslint-plugin-json-schema-validator](https://github.com/ota-meshi/eslint-plugin-json-schema-validator) ... ESLint plugin that validates data using JSON Schema Validator.
194
227
  - [jsonc-eslint-parser](https://github.com/ota-meshi/jsonc-eslint-parser) ... JSON, JSONC and JSON5 parser for use with ESLint plugins.
195
228
  - [yaml-eslint-parser](https://github.com/ota-meshi/yaml-eslint-parser) ... YAML parser for use with ESLint plugins.
196
229
  - [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser) ... TOML parser for use with ESLint plugins.
@@ -7,6 +7,7 @@ declare const _default: {
7
7
  "toml/comma-style": string;
8
8
  "toml/indent": string;
9
9
  "toml/inline-table-curly-spacing": string;
10
+ "toml/key-spacing": string;
10
11
  "toml/keys-order": string;
11
12
  "toml/no-space-dots": string;
12
13
  "toml/no-unreadable-number-separator": string;
@@ -15,7 +16,6 @@ declare const _default: {
15
16
  "toml/precision-of-fractional-seconds": string;
16
17
  "toml/precision-of-integer": string;
17
18
  "toml/quoted-keys": string;
18
- "toml/space-eq-sign": string;
19
19
  "toml/spaced-comment": string;
20
20
  "toml/table-bracket-spacing": string;
21
21
  "toml/tables-order": string;
@@ -14,6 +14,7 @@ module.exports = {
14
14
  "toml/comma-style": "error",
15
15
  "toml/indent": "error",
16
16
  "toml/inline-table-curly-spacing": "error",
17
+ "toml/key-spacing": "error",
17
18
  "toml/keys-order": "error",
18
19
  "toml/no-space-dots": "error",
19
20
  "toml/no-unreadable-number-separator": "error",
@@ -22,7 +23,6 @@ module.exports = {
22
23
  "toml/precision-of-fractional-seconds": "error",
23
24
  "toml/precision-of-integer": "error",
24
25
  "toml/quoted-keys": "error",
25
- "toml/space-eq-sign": "error",
26
26
  "toml/spaced-comment": "error",
27
27
  "toml/table-bracket-spacing": "error",
28
28
  "toml/tables-order": "error",
package/lib/index.d.ts CHANGED
@@ -30,6 +30,7 @@ declare const _default: {
30
30
  "toml/comma-style": string;
31
31
  "toml/indent": string;
32
32
  "toml/inline-table-curly-spacing": string;
33
+ "toml/key-spacing": string;
33
34
  "toml/keys-order": string;
34
35
  "toml/no-space-dots": string;
35
36
  "toml/no-unreadable-number-separator": string;
@@ -38,7 +39,6 @@ declare const _default: {
38
39
  "toml/precision-of-fractional-seconds": string;
39
40
  "toml/precision-of-integer": string;
40
41
  "toml/quoted-keys": string;
41
- "toml/space-eq-sign": string;
42
42
  "toml/spaced-comment": string;
43
43
  "toml/table-bracket-spacing": string;
44
44
  "toml/tables-order": string;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("array-bracket-newline");
5
- exports.default = utils_1.createRule("array-bracket-newline", {
4
+ const coreRule = (0, utils_1.getCoreRule)("array-bracket-newline");
5
+ exports.default = (0, utils_1.createRule)("array-bracket-newline", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce linebreaks after opening and before closing array brackets",
@@ -10,17 +10,18 @@ exports.default = utils_1.createRule("array-bracket-newline", {
10
10
  extensionRule: "array-bracket-newline",
11
11
  },
12
12
  fixable: coreRule.meta.fixable,
13
+ hasSuggestions: coreRule.meta.hasSuggestions,
13
14
  schema: coreRule.meta.schema,
14
15
  messages: coreRule.meta.messages,
15
16
  type: coreRule.meta.type,
16
17
  },
17
18
  create(context) {
18
- return utils_1.defineWrapperListener(coreRule, context, {
19
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
19
20
  options: context.options,
20
21
  createListenerProxy(listener) {
21
22
  return {
22
23
  TOMLArray(node) {
23
- listener.ArrayExpression(utils_1.convertESNode(node));
24
+ listener.ArrayExpression((0, utils_1.convertESNode)(node));
24
25
  },
25
26
  };
26
27
  },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("array-bracket-spacing");
5
- exports.default = utils_1.createRule("array-bracket-spacing", {
4
+ const coreRule = (0, utils_1.getCoreRule)("array-bracket-spacing");
5
+ exports.default = (0, utils_1.createRule)("array-bracket-spacing", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent spacing inside array brackets",
@@ -10,12 +10,13 @@ exports.default = utils_1.createRule("array-bracket-spacing", {
10
10
  extensionRule: "array-bracket-spacing",
11
11
  },
12
12
  fixable: coreRule.meta.fixable,
13
+ hasSuggestions: coreRule.meta.hasSuggestions,
13
14
  schema: coreRule.meta.schema,
14
15
  messages: coreRule.meta.messages,
15
16
  type: coreRule.meta.type,
16
17
  },
17
18
  create(context) {
18
- return utils_1.defineWrapperListener(coreRule, context, {
19
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
19
20
  options: [
20
21
  context.options[0] || "always",
21
22
  ...context.options.slice(1),
@@ -23,7 +24,7 @@ exports.default = utils_1.createRule("array-bracket-spacing", {
23
24
  createListenerProxy(listener) {
24
25
  return {
25
26
  TOMLArray(node) {
26
- listener.ArrayExpression(utils_1.convertESNode(node));
27
+ listener.ArrayExpression((0, utils_1.convertESNode)(node));
27
28
  },
28
29
  };
29
30
  },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("array-element-newline");
5
- exports.default = utils_1.createRule("array-element-newline", {
4
+ const coreRule = (0, utils_1.getCoreRule)("array-element-newline");
5
+ exports.default = (0, utils_1.createRule)("array-element-newline", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce line breaks between array elements",
@@ -10,17 +10,18 @@ exports.default = utils_1.createRule("array-element-newline", {
10
10
  extensionRule: "array-element-newline",
11
11
  },
12
12
  fixable: coreRule.meta.fixable,
13
+ hasSuggestions: coreRule.meta.hasSuggestions,
13
14
  schema: coreRule.meta.schema,
14
15
  messages: coreRule.meta.messages,
15
16
  type: coreRule.meta.type,
16
17
  },
17
18
  create(context) {
18
- return utils_1.defineWrapperListener(coreRule, context, {
19
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
19
20
  options: context.options,
20
21
  createListenerProxy(listener) {
21
22
  return {
22
23
  TOMLArray(node) {
23
- listener.ArrayExpression(utils_1.convertESNode(node));
24
+ listener.ArrayExpression((0, utils_1.convertESNode)(node));
24
25
  },
25
26
  };
26
27
  },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("comma-style");
5
- exports.default = utils_1.createRule("comma-style", {
4
+ const coreRule = (0, utils_1.getCoreRule)("comma-style");
5
+ exports.default = (0, utils_1.createRule)("comma-style", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent comma style in array",
@@ -10,6 +10,7 @@ exports.default = utils_1.createRule("comma-style", {
10
10
  extensionRule: "comma-style",
11
11
  },
12
12
  fixable: coreRule.meta.fixable,
13
+ hasSuggestions: coreRule.meta.hasSuggestions,
13
14
  schema: coreRule.meta.schema,
14
15
  messages: coreRule.meta.messages,
15
16
  type: coreRule.meta.type,
@@ -18,12 +19,12 @@ exports.default = utils_1.createRule("comma-style", {
18
19
  if (!context.parserServices.isTOML) {
19
20
  return {};
20
21
  }
21
- return utils_1.defineWrapperListener(coreRule, context, {
22
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
22
23
  options: [context.options[0]],
23
24
  createListenerProxy(listener) {
24
25
  return {
25
26
  TOMLArray(node) {
26
- listener.ArrayExpression(utils_1.convertESNode(node));
27
+ listener.ArrayExpression((0, utils_1.convertESNode)(node));
27
28
  },
28
29
  };
29
30
  },
@@ -18,7 +18,7 @@ function buildIndentUtility(optionValue) {
18
18
  };
19
19
  }
20
20
  exports.buildIndentUtility = buildIndentUtility;
21
- exports.default = utils_1.createRule("indent", {
21
+ exports.default = (0, utils_1.createRule)("indent", {
22
22
  meta: {
23
23
  docs: {
24
24
  description: "enforce consistent indentation",
@@ -159,7 +159,7 @@ exports.default = utils_1.createRule("indent", {
159
159
  }
160
160
  }
161
161
  if (body.type === "TOMLTable") {
162
- const keys = toml_eslint_parser_1.getStaticTOMLValue(body.key);
162
+ const keys = (0, toml_eslint_parser_1.getStaticTOMLValue)(body.key);
163
163
  const offset = getTableOffset(keys);
164
164
  tableKeyStack.push({ keys, offset });
165
165
  if (bodyFirstToken !== first) {
@@ -293,7 +293,7 @@ exports.default = utils_1.createRule("indent", {
293
293
  continue;
294
294
  }
295
295
  const line = lineIndent.line;
296
- if (ast_utils_1.isCommentToken(lineIndent.firstToken)) {
296
+ if ((0, ast_utils_1.isCommentToken)(lineIndent.firstToken)) {
297
297
  const last = commentLines[commentLines.length - 1];
298
298
  if (last && last.range[1] === line - 1) {
299
299
  last.range[1] = line;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("object-curly-spacing");
5
- exports.default = utils_1.createRule("inline-table-curly-spacing", {
4
+ const coreRule = (0, utils_1.getCoreRule)("object-curly-spacing");
5
+ exports.default = (0, utils_1.createRule)("inline-table-curly-spacing", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent spacing inside braces",
@@ -10,12 +10,13 @@ exports.default = utils_1.createRule("inline-table-curly-spacing", {
10
10
  extensionRule: "object-curly-spacing",
11
11
  },
12
12
  fixable: coreRule.meta.fixable,
13
+ hasSuggestions: coreRule.meta.hasSuggestions,
13
14
  schema: coreRule.meta.schema,
14
15
  messages: coreRule.meta.messages,
15
16
  type: coreRule.meta.type,
16
17
  },
17
18
  create(context) {
18
- return utils_1.defineWrapperListener(coreRule, context, {
19
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
19
20
  options: [
20
21
  context.options[0] || "always",
21
22
  ...context.options.slice(1),
@@ -23,7 +24,7 @@ exports.default = utils_1.createRule("inline-table-curly-spacing", {
23
24
  createListenerProxy(listener) {
24
25
  return {
25
26
  TOMLInlineTable(node) {
26
- listener.ObjectExpression(utils_1.convertESNode(node));
27
+ listener.ObjectExpression((0, utils_1.convertESNode)(node));
27
28
  },
28
29
  };
29
30
  },
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../types").RuleModule;
2
+ export default _default;