From 10d2cf94cfede5c7814af916a5bdac19f07cb987 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 20 Jun 2024 12:38:28 -0600 Subject: [PATCH] use a special warning message for @@ notation --- src/lint/collect-header-diagnostics.ts | 9 ++++++--- test/lint.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lint/collect-header-diagnostics.ts b/src/lint/collect-header-diagnostics.ts index f786833d..d276ca80 100644 --- a/src/lint/collect-header-diagnostics.ts +++ b/src/lint/collect-header-diagnostics.ts @@ -58,12 +58,15 @@ export function collectHeaderDiagnostics( if (!nameMatches) { const { line, column } = offsetToLineAndColumn(contents, 0); + let message = `expected operation to have a name like 'Example', 'Runtime Semantics: Foo', 'Example.prop', etc, but found ${JSON.stringify(name)}`; + let oldSymbolMatch = name.match(/@@([a-z][a-zA-Z]+)/); + if (oldSymbolMatch != null) { + message = `found use of unsupported legacy well-known Symbol notation ${oldSymbolMatch[0]}; use %Symbol.${oldSymbolMatch[1]}% instead`; + } report({ type: 'contents', ruleId, - message: `expected operation to have a name like 'Example', 'Runtime Semantics: Foo', 'Example.prop', etc, but found ${JSON.stringify( - name, - )}`, + message, node: element, nodeRelativeLine: line, nodeRelativeColumn: column, diff --git a/test/lint.js b/test/lint.js index ad4d6dd0..5ef89cbb 100644 --- a/test/lint.js +++ b/test/lint.js @@ -299,7 +299,7 @@ describe('linting whole program', () => { ruleId: 'header-format', nodeType: 'h1', message: - "expected operation to have a name like 'Example', 'Runtime Semantics: Foo', 'Example.prop', etc, but found \"Example [ @@baz ] \"", + 'found use of unsupported legacy well-known Symbol notation @@baz; use %Symbol.baz% instead', }, ); });