diff --git a/packages/jsts/src/rules/S6849/cb.fixture.tsx b/packages/jsts/src/rules/S6849/cb.fixture.tsx index 425e795ed3a..5bb6b926239 100644 --- a/packages/jsts/src/rules/S6849/cb.fixture.tsx +++ b/packages/jsts/src/rules/S6849/cb.fixture.tsx @@ -1,2 +1,4 @@ -; // Noncompliant {{ elements must have the lang prop.}} -; // Noncompliant {{lang attribute must have a valid value.}} + ; // Noncompliant {{ elements must have the lang prop.}} +// ^^^^ + ; // Noncompliant {{lang attribute must have a valid value.}} +// ^^^^^^^^^^^ diff --git a/packages/jsts/src/rules/S6849/rule.ts b/packages/jsts/src/rules/S6849/rule.ts index adfeeb80790..cbb9d79376b 100644 --- a/packages/jsts/src/rules/S6849/rule.ts +++ b/packages/jsts/src/rules/S6849/rule.ts @@ -19,25 +19,35 @@ */ // https://sonarsource.github.io/rspec/#/rspec/S6849/javascript +import { TSESTree } from '@typescript-eslint/experimental-utils'; import { Rule } from 'eslint'; import { rules as jsxA11yRules } from 'eslint-plugin-jsx-a11y'; -import { mergeRules } from '../helpers'; +import { interceptReport, mergeRules } from '../helpers'; const langRule = jsxA11yRules['lang']; const htmlHasLangRule = jsxA11yRules['html-has-lang']; +const decoratedHasLangRule = decorate(htmlHasLangRule); + +export function decorate(rule: Rule.RuleModule): Rule.RuleModule { + return interceptReport(rule, (context, reportDescriptor) => { + const node = (reportDescriptor as any).node as TSESTree.JSXOpeningElement; + (reportDescriptor as any).node = node.name; + context.report(reportDescriptor); + }); +} export const rule: Rule.RuleModule = { meta: { hasSuggestions: true, messages: { ...langRule.meta!.messages, - ...htmlHasLangRule.meta!.messages, + ...decoratedHasLangRule.meta!.messages, }, }, create(context: Rule.RuleContext) { const langListener: Rule.RuleListener = langRule.create(context); - const htmlHasLangListener: Rule.RuleListener = htmlHasLangRule.create(context); + const htmlHasLangListener: Rule.RuleListener = decoratedHasLangRule.create(context); return mergeRules(langListener, htmlHasLangListener); },