From 24022a1d3cb812b7d15f98e90590b2afcd77d627 Mon Sep 17 00:00:00 2001 From: jason lim <50891910+Sxxov@users.noreply.github.com> Date: Tue, 16 Mar 2021 15:39:23 +0800 Subject: [PATCH 1/3] Consider @typescript/eslint's rules for invalid message --- src/postprocess.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/postprocess.js b/src/postprocess.js index 875806f..77f63e9 100644 --- a/src/postprocess.js +++ b/src/postprocess.js @@ -92,12 +92,14 @@ const get_identifier = str => (str && str.match(/^[^\s!"#%&\\'()*+,\-./:;<=>?@[\ const is_valid_message = (block, message, translation) => { switch (message.ruleId) { case 'eol-last': return false; + case '@typescript-eslint/indent': case 'indent': return !translation.options.template; case 'linebreak-style': return message.line !== translation.end; case 'no-labels': return get_identifier(get_referenced_string(block, message)) !== '$'; case 'no-restricted-syntax': return message.nodeType !== 'LabeledStatement' || get_identifier(get_referenced_string(block, message)) !== '$'; case 'no-self-assign': return !state.var_names.has(get_identifier(get_referenced_string(block, message))); case 'no-unused-labels': return get_referenced_string(block, message) !== '$'; + case '@typescript-eslint/quotes': case 'quotes': return !translation.options.in_quoted_attribute; } return true; From 28fc32e387fd889a1a1fcbce8f270eeb4d6a91f5 Mon Sep 17 00:00:00 2001 From: jason lim <50891910+Sxxov@users.noreply.github.com> Date: Tue, 16 Mar 2021 16:57:22 +0800 Subject: [PATCH 2/3] Add tests for @typescript-eslint/indent, quotes --- .../typescript-indentation/.eslintrc.js | 11 +++++++ .../typescript-indentation/Input.svelte | 6 ++++ .../typescript-indentation/expected.json | 31 +++++++++++++++++++ .../typescript-template-quotes/.eslintrc.js | 10 ++++++ .../typescript-template-quotes/Input.svelte | 4 +++ .../typescript-template-quotes/expected.json | 24 ++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 test/samples/typescript-indentation/.eslintrc.js create mode 100644 test/samples/typescript-indentation/Input.svelte create mode 100644 test/samples/typescript-indentation/expected.json create mode 100644 test/samples/typescript-template-quotes/.eslintrc.js create mode 100644 test/samples/typescript-template-quotes/Input.svelte create mode 100644 test/samples/typescript-template-quotes/expected.json diff --git a/test/samples/typescript-indentation/.eslintrc.js b/test/samples/typescript-indentation/.eslintrc.js new file mode 100644 index 0000000..b46af0a --- /dev/null +++ b/test/samples/typescript-indentation/.eslintrc.js @@ -0,0 +1,11 @@ +module.exports = { + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + rules: { + indent: 'off', + '@typescript-eslint/indent': ['error', 'tab'], + semi: 'error', + }, +}; \ No newline at end of file diff --git a/test/samples/typescript-indentation/Input.svelte b/test/samples/typescript-indentation/Input.svelte new file mode 100644 index 0000000..e58dedb --- /dev/null +++ b/test/samples/typescript-indentation/Input.svelte @@ -0,0 +1,6 @@ + + +
{foo}
diff --git a/test/samples/typescript-indentation/expected.json b/test/samples/typescript-indentation/expected.json new file mode 100644 index 0000000..374119a --- /dev/null +++ b/test/samples/typescript-indentation/expected.json @@ -0,0 +1,31 @@ +[ + { + "ruleId": "semi", + "line": 2, + "column": 9, + "fix": { + "range": [27, 27], + "text": ";" + } + }, + { + "ruleId": "@typescript-eslint/indent", + "line": 3, + "column": 2, + "endLine": 3, + "endColumn": 3, + "fix": { + "range": [29, 30], + "text": "" + } + }, + { + "ruleId": "semi", + "line": 3, + "column": 10, + "fix": { + "range": [37, 37], + "text": ";" + } + } +] diff --git a/test/samples/typescript-template-quotes/.eslintrc.js b/test/samples/typescript-template-quotes/.eslintrc.js new file mode 100644 index 0000000..2960738 --- /dev/null +++ b/test/samples/typescript-template-quotes/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + rules: { + quotes: 'off', + '@typescript-eslint/quotes': ['error', 'single'] + }, +}; diff --git a/test/samples/typescript-template-quotes/Input.svelte b/test/samples/typescript-template-quotes/Input.svelte new file mode 100644 index 0000000..ac70805 --- /dev/null +++ b/test/samples/typescript-template-quotes/Input.svelte @@ -0,0 +1,4 @@ +{'foo'} +{"bar"} +
+
diff --git a/test/samples/typescript-template-quotes/expected.json b/test/samples/typescript-template-quotes/expected.json new file mode 100644 index 0000000..3c413ea --- /dev/null +++ b/test/samples/typescript-template-quotes/expected.json @@ -0,0 +1,24 @@ +[ + { + "ruleId": "@typescript-eslint/quotes", + "line": 2, + "column": 2, + "endLine": 2, + "endColumn": 7, + "fix": { + "range": [9, 14], + "text": "'bar'" + } + }, + { + "ruleId": "@typescript-eslint/quotes", + "line": 3, + "column": 13, + "endLine": 3, + "endColumn": 19, + "fix": { + "range": [28, 34], + "text": "'baz1'" + } + } +] From 837acf38ced65dbb250658d99b166003dc6d69a8 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 23 Apr 2021 15:44:20 -0400 Subject: [PATCH 3/3] formatting --- test/samples/typescript-indentation/.eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/samples/typescript-indentation/.eslintrc.js b/test/samples/typescript-indentation/.eslintrc.js index b46af0a..a790a92 100644 --- a/test/samples/typescript-indentation/.eslintrc.js +++ b/test/samples/typescript-indentation/.eslintrc.js @@ -8,4 +8,4 @@ module.exports = { '@typescript-eslint/indent': ['error', 'tab'], semi: 'error', }, -}; \ No newline at end of file +};