From 956e651b7b6feb329726747102a5ce25541be158 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Thu, 8 Apr 2021 19:48:59 +0200 Subject: [PATCH] Support TypeScript triple-slash directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TypeScript uses triple-slash directives [1] (single-line comments containing a single XML tag) to define compiler directives. The `@arcticicestudio/eslint-config-base` configures the ESLint core rule `spaced-comment` [2] and already defines exceptions and comment markers for special use cases, but did not support triple-slash directives. When running `eslint --fix` these comments in `*.d.ts` files got malformed (`///` → `// /`) which resulted in invalid TypeScript syntax. To support triple-slash directives, the `/` marker has been added to the `line` field. [1]: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html [2]: https://eslint.org/docs/rules/spaced-comment Co-authored-by: Sven Greb GH-50 --- .../@arcticicestudio/eslint-config-base/rules/style.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@arcticicestudio/eslint-config-base/rules/style.js b/packages/@arcticicestudio/eslint-config-base/rules/style.js index c0584e5..c239bf8 100644 --- a/packages/@arcticicestudio/eslint-config-base/rules/style.js +++ b/packages/@arcticicestudio/eslint-config-base/rules/style.js @@ -701,7 +701,14 @@ module.exports = { { line: { exceptions: ["+-"], - markers: ["!"], + markers: [ + "!", + /* + * Support for TypeScript triple-slash directives. + * See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html for more details. + */ + "/", + ], }, block: { exceptions: ["+-"],