@@ -13,6 +13,7 @@ import {
1313import { getDecoratorParameters , isDecoratorNamed } from './decorator-utils' ;
1414
1515export const eventDecoratorsToStatic = (
16+ config : d . ValidatedConfig ,
1617 diagnostics : d . Diagnostic [ ] ,
1718 decoratedProps : ts . ClassElement [ ] ,
1819 typeChecker : ts . TypeChecker ,
@@ -22,7 +23,7 @@ export const eventDecoratorsToStatic = (
2223) => {
2324 const events = decoratedProps
2425 . filter ( ts . isPropertyDeclaration )
25- . map ( ( prop ) => parseEventDecorator ( diagnostics , typeChecker , program , prop , decoratorName ) )
26+ . map ( ( prop ) => parseEventDecorator ( config , diagnostics , typeChecker , program , prop , decoratorName ) )
2627 . filter ( ( ev ) => ! ! ev ) ;
2728
2829 if ( events . length > 0 ) {
@@ -33,6 +34,7 @@ export const eventDecoratorsToStatic = (
3334/**
3435 * Parse a single instance of Stencil's `@Event()` decorator and generate metadata for the class member that is
3536 * decorated
37+ * @param config a user-supplied Stencil config
3638 * @param diagnostics a list of diagnostics used as a part of the parsing process. Any parse errors/warnings shall be
3739 * added to this collection
3840 * @param typeChecker an instance of the TypeScript type checker, used to generate information about the `@Event()` and
@@ -43,6 +45,7 @@ export const eventDecoratorsToStatic = (
4345 * @returns generated metadata for the class member decorated by `@Event()`, or `null` if none could be derived
4446 */
4547const parseEventDecorator = (
48+ config : d . ValidatedConfig ,
4649 diagnostics : d . Diagnostic [ ] ,
4750 typeChecker : ts . TypeChecker ,
4851 program : ts . Program ,
@@ -64,7 +67,7 @@ const parseEventDecorator = (
6467 const symbol = typeChecker . getSymbolAtLocation ( prop . name ) ;
6568 const eventName = getEventName ( eventOpts , memberName ) ;
6669
67- validateEventName ( diagnostics , prop . name , eventName ) ;
70+ validateEventName ( config , diagnostics , prop . name , eventName ) ;
6871
6972 const eventMeta = {
7073 method : memberName ,
@@ -130,12 +133,18 @@ const getEventType = (type: ts.TypeNode): ts.TypeNode | null => {
130133 *
131134 * This function assumes that the name of the event has been determined prior to calling it
132135 *
136+ * @param config a user-supplied Stencil config
133137 * @param diagnostics a list of diagnostics used as a part of the validation process. Any parse errors/warnings shall be
134138 * added to this collection
135- * @param node the node in the AT containing the class member decorated with `@Event()`
139+ * @param node the node in the AST containing the class member decorated with `@Event()`
136140 * @param eventName the name of the event
137141 */
138- const validateEventName = ( diagnostics : d . Diagnostic [ ] , node : ts . Node , eventName : string ) : void => {
142+ const validateEventName = (
143+ config : d . ValidatedConfig ,
144+ diagnostics : d . Diagnostic [ ] ,
145+ node : ts . Node ,
146+ eventName : string ,
147+ ) : void => {
139148 // this regex checks for a string that begins with a capital letter - e.g. 'AskJeeves', 'Zoo', 'Spotify'
140149 if ( / ^ [ A - Z ] / . test ( eventName ) ) {
141150 const diagnostic = buildWarn ( diagnostics ) ;
@@ -157,7 +166,7 @@ const validateEventName = (diagnostics: d.Diagnostic[], node: ts.Node, eventName
157166 return ;
158167 }
159168
160- if ( DOM_EVENT_NAMES . has ( eventName . toLowerCase ( ) ) ) {
169+ if ( ! config . suppressReservedEventNameWarnings && DOM_EVENT_NAMES . has ( eventName . toLowerCase ( ) ) ) {
161170 const diagnostic = buildWarn ( diagnostics ) ;
162171 diagnostic . messageText = `The event name conflicts with the "${ eventName } " native DOM event name.` ;
163172 augmentDiagnosticWithNode ( diagnostic , node ) ;
0 commit comments