Skip to content

Commit

Permalink
feat: experimental support for TOML v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Nov 8, 2023
1 parent 8c27a07 commit 5972b27
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"debug": "^4.1.1",
"eslint-compat-utils": "^0.1.2",
"lodash": "^4.17.19",
"toml-eslint-parser": "^0.7.0"
"toml-eslint-parser": "^0.8.1"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 7,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 8,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 9,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 10,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 11,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 12,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 13,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 14,
"column": 1
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# {}
# https://toml.io/en/v1.1.0#inline-table
name = { first = "Tom", last = "Preston-Werner" }
point = {x=1, y=2}
animal = { type.name = "pug" }
contact = {
personal = {
name = "Donald Duck",
email = "donald@duckburg.com",
},
work = {
name = "Coin cleaner",
email = "donald@ScroogeCorp.com",
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# indent/invalid/default/inline-table-sample01-1.1-input.toml
# https://toml.io/en/v1.1.0#inline-table
name = { first = "Tom", last = "Preston-Werner" }
point = {x=1, y=2}
animal = { type.name = "pug" }
contact = {
personal = {
name = "Donald Duck",
email = "donald@duckburg.com",
},
work = {
name = "Coin cleaner",
email = "donald@ScroogeCorp.com",
},
}
2 changes: 1 addition & 1 deletion tests/src/rules/array-bracket-newline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/array-bracket-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/array-element-newline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/comma-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/indent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/inline-table-curly-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/key-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/keys-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-mixed-type-in-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-non-decimal-integer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-space-dots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unreadable-number-separator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/padding-line-between-pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/padding-line-between-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/precision-of-fractional-seconds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/precision-of-integer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import assert from "assert";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/quoted-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/space-eq-sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/spaced-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/table-bracket-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/tables-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/vue-custom-block/no-parsing-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadTestCases } from "../../../utils/utils";
const tester = new RuleTester({
parser: require.resolve("yaml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
});

Expand Down
9 changes: 7 additions & 2 deletions tests/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ export function loadTestCases(
describe(`Output test for ${ruleName}`, () => {
for (const test of invalid.filter(({ filename }) => isToml(filename))) {
it(test.filename, () => {
const input = tomlESLintParser.parseForESLint(test.code);
const output = tomlESLintParser.parseForESLint(test.output);
const input = tomlESLintParser.parseForESLint(test.code, {
tomlVersion: "1.1",
});
const output = tomlESLintParser.parseForESLint(test.output, {
tomlVersion: "1.1",
});
assert.deepStrictEqual(
tomlESLintParser.getStaticTOMLValue(input.ast),
tomlESLintParser.getStaticTOMLValue(output.ast),
Expand Down Expand Up @@ -195,6 +199,7 @@ function writeFixtures(
settings: {
toml: { indent: 8 },
},
parserOptions: { tomlVersion: "1.1" },
},
config.filename,
);
Expand Down
2 changes: 1 addition & 1 deletion tools/new-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { loadTestCases } from "../../utils/utils"
const tester = new RuleTester({
parser: require.resolve("toml-eslint-parser"),
parserOptions: {
ecmaVersion: 2020,
tomlVersion: "1.1",
},
})
Expand Down

0 comments on commit 5972b27

Please sign in to comment.