diff --git a/README.md b/README.md index 286997599..5f98799be 100644 --- a/README.md +++ b/README.md @@ -1932,6 +1932,20 @@ function quux () { * ``` */ // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":[]}] + +/** + * @example + * ``` + * @MyDecorator({ + * myOptions: 42 + * }) + * export class MyClass {} + * ``` + */ +function MyDecorator(options: { myOptions: number }) { + return (Base: Function) => {}; +} +// "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":["example","MyDecorator"]}] ```` diff --git a/src/rules/checkIndentation.js b/src/rules/checkIndentation.js index 94d37914a..43d2ef926 100644 --- a/src/rules/checkIndentation.js +++ b/src/rules/checkIndentation.js @@ -9,7 +9,7 @@ const maskExcludedContent = (str, excludeTags) => { }; const maskCodeBlocks = (str) => { - const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@)|\/))/gu; + const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gu; return str.replace(regContent, (_match, margin, code) => { return new Array(code.match(/\n/gu).length + 1).join(margin + '\n'); diff --git a/test/rules/assertions/checkIndentation.js b/test/rules/assertions/checkIndentation.js index 688278cac..9269c818f 100644 --- a/test/rules/assertions/checkIndentation.js +++ b/test/rules/assertions/checkIndentation.js @@ -289,5 +289,27 @@ export default { excludeTags: [], }], }, + { + code: ` + /** + * @example + * \`\`\` + * @MyDecorator({ + * myOptions: 42 + * }) + * export class MyClass {} + * \`\`\` + */ + function MyDecorator(options: { myOptions: number }) { + return (Base: Function) => {}; + } + `, + options: [ + { + excludeTags: ['example', 'MyDecorator'], + }, + ], + parser: require.resolve('@typescript-eslint/parser'), + }, ], };