From f31be2155fc6cc9bb4dd9f40360b9d3adeab89b3 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Thu, 18 Nov 2021 15:37:34 +0900 Subject: [PATCH] Update indent rule to support typescript v4.5 (#71) * Update indent rule to support typescript v4.5 * update * update --- .eslintignore | 1 + package.json | 10 +- src/rules/indent-helpers/es.ts | 92 ++++++++++++-- src/rules/indent-helpers/ts.ts | 21 ++++ .../ts-v5/ts-import-assertion01-errors.json | 32 +++++ .../ts-v5/ts-import-assertion01-input.svelte | 11 ++ .../ts-v5/ts-import-assertion01-output.svelte | 11 ++ .../ts-v5/ts-import-assertion02-errors.json | 62 ++++++++++ .../ts-v5/ts-import-assertion02-input.svelte | 17 +++ .../ts-v5/ts-import-assertion02-output.svelte | 17 +++ .../ts-v5/ts-import-assertion03-errors.json | 37 ++++++ .../ts-v5/ts-import-assertion03-input.svelte | 12 ++ .../ts-v5/ts-import-assertion03-output.svelte | 12 ++ .../ts-v5/ts-import-assertion04-errors.json | 37 ++++++ .../ts-v5/ts-import-assertion04-input.svelte | 12 ++ .../ts-v5/ts-import-assertion04-output.svelte | 12 ++ .../ts-type-only-import-export01-errors.json | 72 +++++++++++ .../ts-type-only-import-export01-input.svelte | 20 +++ ...ts-type-only-import-export01-output.svelte | 20 +++ .../ts-type-only-import-export02-errors.json | 102 +++++++++++++++ .../ts-type-only-import-export02-input.svelte | 25 ++++ ...ts-type-only-import-export02-output.svelte | 25 ++++ .../ts-type-only-import-export03-errors.json | 117 ++++++++++++++++++ .../ts-type-only-import-export03-input.svelte | 28 +++++ ...ts-type-only-import-export03-output.svelte | 28 +++++ 25 files changed, 817 insertions(+), 16 deletions(-) create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-output.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-errors.json create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-input.svelte create mode 100644 tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-output.svelte diff --git a/.eslintignore b/.eslintignore index 5fc024ddd..94c64cfa6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,5 +8,6 @@ !/.github /prettier-playground /tests/fixtures/rules/indent/invalid/ts +/tests/fixtures/rules/indent/invalid/ts-v5 /tests/fixtures/rules/valid-compile/invalid/ts /tests/fixtures/rules/valid-compile/valid/ts diff --git a/package.json b/package.json index 067976dc1..cf62c0eb2 100644 --- a/package.json +++ b/package.json @@ -65,14 +65,14 @@ }, "devDependencies": { "@ota-meshi/eslint-plugin": "^0.10.0", - "@types/eslint": "^7.2.10", + "@types/eslint": "^8.0.0", "@types/eslint-scope": "^3.7.0", "@types/eslint-visitor-keys": "^1.0.0", "@types/mocha": "^9.0.0", "@types/node": "^16.0.0", - "@typescript-eslint/eslint-plugin": "^5.0.0-0", - "@typescript-eslint/parser": "^5.0.0-0", - "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@5", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "@typescript-eslint/parser": "^5.4.1-0", + "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@4", "env-cmd": "^10.1.0", "eslint": "^8.0.0", "eslint-config-prettier": "^8.3.0", @@ -101,7 +101,7 @@ "stylelint-config-standard": "^24.0.0", "svelte": "^3.37.0", "ts-node": "^10.0.0", - "typescript": "^4.4.2", + "typescript": "^4.5.2", "vue-eslint-editor": "^1.1.0", "vue-eslint-parser": "^8.0.0", "vuepress": "^1.8.2" diff --git a/src/rules/indent-helpers/es.ts b/src/rules/indent-helpers/es.ts index d8dd87f04..bdbd871e5 100644 --- a/src/rules/indent-helpers/es.ts +++ b/src/rules/indent-helpers/es.ts @@ -334,6 +334,27 @@ export function defineVisitor(context: IndentContext): NodeListener { } offsets.setOffsetToken(fromToken, 0, exportToken) offsets.setOffsetToken(afterTokens, 1, fromToken) + + // assertions + const lastToken = sourceCode.getLastToken(node)! + const assertionTokens = sourceCode.getTokensBetween( + node.source, + lastToken, + ) + if (assertionTokens.length) { + const assertToken = assertionTokens.shift()! + offsets.setOffsetToken(assertToken, 0, exportToken) + const assertionOpen = assertionTokens.shift() + if (assertionOpen) { + offsets.setOffsetToken(assertionOpen, 1, assertToken) + offsets.setOffsetElementList( + assertionTokens, + assertionOpen, + lastToken, + 1, + ) + } + } }, ExportDefaultDeclaration(node: ESTree.ExportDefaultDeclaration) { const exportToken = sourceCode.getFirstToken(node) @@ -365,10 +386,15 @@ export function defineVisitor(context: IndentContext): NodeListener { exportToken, firstSpecifier, ) - const rightBraceToken = sourceCode.getLastToken(node, { - filter: isClosingBraceToken, - includeComments: false, - })! + const rightBraceToken = node.source + ? sourceCode.getTokenBefore(node.source, { + filter: isClosingBraceToken, + includeComments: false, + })! + : sourceCode.getLastToken(node, { + filter: isClosingBraceToken, + includeComments: false, + })! offsets.setOffsetToken(leftBraceTokens, 0, exportToken) offsets.setOffsetElementList( node.specifiers, @@ -389,14 +415,41 @@ export function defineVisitor(context: IndentContext): NodeListener { 1, fromToken, ) + + // assertions + const lastToken = sourceCode.getLastToken(node)! + const assertionTokens = sourceCode.getTokensBetween( + node.source, + lastToken, + ) + if (assertionTokens.length) { + const assertToken = assertionTokens.shift()! + offsets.setOffsetToken(assertToken, 0, exportToken) + const assertionOpen = assertionTokens.shift() + if (assertionOpen) { + offsets.setOffsetToken(assertionOpen, 1, assertToken) + offsets.setOffsetElementList( + assertionTokens, + assertionOpen, + lastToken, + 1, + ) + } + } } } else { // maybe babel-eslint } } }, - ExportSpecifier(node: ESTree.ExportSpecifier) { - const [firstToken, ...tokens] = sourceCode.getTokens(node) + ExportSpecifier(node: ESTree.ExportSpecifier | ESTree.ImportSpecifier) { + const tokens = sourceCode.getTokens(node) + let firstToken = tokens.shift()! + if (firstToken.value === "type") { + const typeToken = firstToken + firstToken = tokens.shift()! + offsets.setOffsetToken(firstToken, 0, typeToken) + } offsets.setOffsetToken(tokens, 1, firstToken) }, ForInStatement(node: ESTree.ForInStatement | ESTree.ForOfStatement) { @@ -618,6 +671,27 @@ export function defineVisitor(context: IndentContext): NodeListener { offsets.setOffsetToken(fromToken, 0, importToken) offsets.setOffsetToken(afterTokens, 1, fromToken) } + + // assertions + const lastToken = sourceCode.getLastToken(node)! + const assertionTokens = sourceCode.getTokensBetween( + node.source, + lastToken, + ) + if (assertionTokens.length) { + const assertToken = assertionTokens.shift()! + offsets.setOffsetToken(assertToken, 0, importToken) + const assertionOpen = assertionTokens.shift() + if (assertionOpen) { + offsets.setOffsetToken(assertionOpen, 1, assertToken) + offsets.setOffsetElementList( + assertionTokens, + assertionOpen, + lastToken, + 1, + ) + } + } }, ImportExpression(node: ESTree.ImportExpression) { const firstToken = sourceCode.getFirstToken(node) @@ -636,11 +710,7 @@ export function defineVisitor(context: IndentContext): NodeListener { offsets.setOffsetToken(tokens, 1, firstToken) }, ImportSpecifier(node: ESTree.ImportSpecifier) { - if (node.local.range![0] !== node.imported.range![0]) { - const tokens = sourceCode.getTokens(node) - const firstToken = tokens.shift()! - offsets.setOffsetToken(tokens, 1, firstToken) - } + visitor.ExportSpecifier(node) }, LabeledStatement( node: ESTree.LabeledStatement | AST.SvelteReactiveStatement, diff --git a/src/rules/indent-helpers/ts.ts b/src/rules/indent-helpers/ts.ts index eee9cc606..ef72e0d9f 100644 --- a/src/rules/indent-helpers/ts.ts +++ b/src/rules/indent-helpers/ts.ts @@ -995,6 +995,27 @@ export function defineVisitor(context: IndentContext): NodeListener { 1, ) }, + ImportAttribute(node: TSESTree.ImportAttribute) { + const firstToken = sourceCode.getFirstToken(node) + const keyTokens = getFirstAndLastTokens(sourceCode, node.key) + const prefixTokens = sourceCode.getTokensBetween( + firstToken, + keyTokens.firstToken, + ) + offsets.setOffsetToken(prefixTokens, 0, firstToken) + + offsets.setOffsetToken(keyTokens.firstToken, 0, firstToken) + + const initToken = sourceCode.getFirstToken(node.value) + offsets.setOffsetToken( + [ + ...sourceCode.getTokensBetween(keyTokens.lastToken, initToken), + initToken, + ], + 1, + keyTokens.lastToken, + ) + }, // ---------------------------------------------------------------------- // SINGLE TOKEN NODES // ---------------------------------------------------------------------- diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-errors.json b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-errors.json new file mode 100644 index 000000000..3e2788d86 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-errors.json @@ -0,0 +1,32 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 8, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-input.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-input.svelte new file mode 100644 index 000000000..24da9983b --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-input.svelte @@ -0,0 +1,11 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-output.svelte new file mode 100644 index 000000000..ffe7b655d --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion01-output.svelte @@ -0,0 +1,11 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-errors.json b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-errors.json new file mode 100644 index 000000000..29b7b15b3 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-errors.json @@ -0,0 +1,62 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 8, + "column": 1 + }, + { + "message": "Expected indentation of 10 spaces but found 0 spaces.", + "line": 9, + "column": 1 + }, + { + "message": "Expected indentation of 12 spaces but found 0 spaces.", + "line": 10, + "column": 1 + }, + { + "message": "Expected indentation of 12 spaces but found 0 spaces.", + "line": 11, + "column": 1 + }, + { + "message": "Expected indentation of 8 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 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-input.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-input.svelte new file mode 100644 index 000000000..30ab14398 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-input.svelte @@ -0,0 +1,17 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-output.svelte new file mode 100644 index 000000000..15b9a3c9b --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion02-output.svelte @@ -0,0 +1,17 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-errors.json b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-errors.json new file mode 100644 index 000000000..323eb468f --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-errors.json @@ -0,0 +1,37 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 8, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 9, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-input.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-input.svelte new file mode 100644 index 000000000..83cf0f4c1 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-input.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-output.svelte new file mode 100644 index 000000000..df47d6b49 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion03-output.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-errors.json b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-errors.json new file mode 100644 index 000000000..323eb468f --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-errors.json @@ -0,0 +1,37 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 8 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 8, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 9, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-input.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-input.svelte new file mode 100644 index 000000000..86f749e86 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-input.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-output.svelte new file mode 100644 index 000000000..fac283133 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-assertion04-output.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-errors.json b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-errors.json new file mode 100644 index 000000000..1a862833b --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-errors.json @@ -0,0 +1,72 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 2 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 4 spaces but found 0 spaces.", + "line": 10, + "column": 1 + }, + { + "message": "Expected indentation of 6 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 2 spaces but found 0 spaces.", + "line": 13, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 14, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 16, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 17, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-input.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-input.svelte new file mode 100644 index 000000000..97cdabc4c --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-input.svelte @@ -0,0 +1,20 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-output.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-output.svelte new file mode 100644 index 000000000..97f10b731 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export01-output.svelte @@ -0,0 +1,20 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-errors.json b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-errors.json new file mode 100644 index 000000000..560dd8871 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-errors.json @@ -0,0 +1,102 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 2 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 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 15, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 16, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 17, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 18, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 19, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 20, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 21, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 22, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-input.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-input.svelte new file mode 100644 index 000000000..ef1aab715 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-input.svelte @@ -0,0 +1,25 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-output.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-output.svelte new file mode 100644 index 000000000..a749e6d22 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export02-output.svelte @@ -0,0 +1,25 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-errors.json b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-errors.json new file mode 100644 index 000000000..87e801efe --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-errors.json @@ -0,0 +1,117 @@ +[ + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 3, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 4, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 5, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 6, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 7, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 8, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 9, + "column": 1 + }, + { + "message": "Expected indentation of 4 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 2 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 4 spaces but found 0 spaces.", + "line": 14, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 15, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 16, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 17, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 18, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 19, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 20, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 21, + "column": 1 + }, + { + "message": "Expected indentation of 4 spaces but found 0 spaces.", + "line": 22, + "column": 1 + }, + { + "message": "Expected indentation of 6 spaces but found 0 spaces.", + "line": 23, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 24, + "column": 1 + }, + { + "message": "Expected indentation of 2 spaces but found 0 spaces.", + "line": 25, + "column": 1 + } +] diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-input.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-input.svelte new file mode 100644 index 000000000..c47b2eb7e --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-input.svelte @@ -0,0 +1,28 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-output.svelte b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-output.svelte new file mode 100644 index 000000000..4729b6a5d --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts/ts-type-only-import-export03-output.svelte @@ -0,0 +1,28 @@ + + + +