Skip to content

Commit

Permalink
use a special warning message for @@ notation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Jun 20, 2024
1 parent bc712bc commit 10d2cf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/lint/collect-header-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)/);

Check failure on line 62 in src/lint/collect-header-diagnostics.ts

View workflow job for this annotation

GitHub Actions / Check

'oldSymbolMatch' is never reassigned. Use 'const' instead
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,
Expand Down
2 changes: 1 addition & 1 deletion test/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
);
});
Expand Down

0 comments on commit 10d2cf9

Please sign in to comment.