-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move decorators to their own folder
- Loading branch information
Showing
10 changed files
with
86 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/@lwc/ssr-compiler/src/compile-js/decorators/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
import { DecoratorErrors } from '@lwc/errors'; | ||
import { generateError } from '../errors'; | ||
import { isApiDecorator } from './api'; | ||
import { isTrackDecorator } from './track'; | ||
import { isWireDecorator } from './wire'; | ||
import type { Decorator as EsDecorator } from 'estree'; | ||
|
||
export function validateUniqueDecorator(decorators: EsDecorator[]) { | ||
if (decorators.length < 2) { | ||
return; | ||
} | ||
|
||
const hasWire = decorators.some(isWireDecorator); | ||
const hasApi = decorators.some(isApiDecorator); | ||
const hasTrack = decorators.some(isTrackDecorator); | ||
|
||
if (hasWire) { | ||
if (hasApi) { | ||
throw generateError(DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'api'); | ||
} | ||
|
||
if (hasTrack) { | ||
throw generateError(DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'track'); | ||
} | ||
} | ||
|
||
if (hasApi && hasTrack) { | ||
throw generateError(DecoratorErrors.API_AND_TRACK_DECORATOR_CONFLICT); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters